Board class

This commit is contained in:
Gérald LEBAN 2021-01-31 19:11:47 +01:00
parent 0442e04eaa
commit 88ecb3a2e2

42
marinbad/board.py Normal file
View file

@ -0,0 +1,42 @@
class Board:
def __init__(self):
pass
@staticmethod
def show_board(board):
"""
Display the board o screen
:param board: the board
:type board list
:return: None
"""
for index, val in enumerate(board):
print(f"Row {index + 1}: {val}")
@staticmethod
def nb_allumettes(board: list):
"""
Return the number of remaining allumettes
:param board: the board
:type board list
:return: int
"""
return sum(board)
@staticmethod
def retirer(board, row, stick):
"""
Computer player move on the board
:param board: the board
:type board list
:param row: the selected row to remove allumettes from
:type row: int
:param stick: the number of allumettes to remove
:type stick: int
:return: board
"""
board[int(row) - 1] = board[int(row) - 1] - int(stick)
return board