Я создаю игру, и у меня есть функции, которые принимают параметры и возвращают значение. Я хочу проверить, закончилась ли игра. Игра заканчивается, когда bins = [0, 0, 0, 0, 0]
. Я перепробовал все и не могу заставить gameIsOver быть верным в основной функции. Что я делаю не так?
bins = [7, 7, 7, 7, 7]
gameIsOver = False
def checkGameEnd(listOfBins):
if listOfBins[0] == 0 and listOfBins[1] == 0 and listOfBins[2] == 0 and listOfBins[3] == 0 and listOfBins[4] == 0:
gameDidEnd = True
return True
else:
gameDidEnd = False
return False
def _main_():
print(displayGame(bins))
checkGameEnd(bins)
player_1 = "Player 1"
player_2 = "Player 2"
while didEndGame == False:
turnPlayer1_bin = int(input(player_1 + ", which bin do you want to remove matches from?\t"))
turnPlayer1_matches = int(input(player_1 + ", how many matches will you remove from bin " + str(turnPlayer1_bin) + "?\t"))
removeMatches(turnPlayer1_bin, turnPlayer1_matches, bins)
print(displayGame(bins))
checkGameEnd(bins)
if didEndGame == True:
print(player_2 + ", you win!")
turnPlayer2_bin = int(input(player_2 + ", which bin do you want to remove matches from?\t"))
turnPlayer2_matches = int(input(player_2 + ", how many matches will you remove from bin " + str(turnPlayer2_bin) + "?\t"))
removeMatches(turnPlayer2_bin, turnPlayer2_matches, bins)
print(displayGame(bins))
checkGameEnd(bins)
if didEndGame == True:
print(player_1 + ", you win!")
_main_()