Randomize first player after overwritting print/input

This commit is contained in:
nemunaire 2020-03-15 13:09:20 +01:00
parent 4489c95ddc
commit 30513c6acd
2 changed files with 6 additions and 2 deletions

View File

@ -26,8 +26,6 @@ class Game():
else: else:
self.players.append(Computer(self.board)) self.players.append(Computer(self.board))
random.shuffle(self.players)
@property @property
def player1(self): def player1(self):
if type(self.players[0]) == Computer: if type(self.players[0]) == Computer:
@ -49,6 +47,10 @@ class Game():
return self.players[(self.round + 1) % 2] return self.players[(self.round + 1) % 2]
def ready(self):
random.shuffle(self.players)
def isFinished(self): def isFinished(self):
return self.board.isFinished() or self.player1.cantpioche or self.player2.cantpioche return self.board.isFinished() or self.player1.cantpioche or self.player2.cantpioche

View File

@ -184,6 +184,8 @@ while True:
game.current_player.print("\033[91m%s\033[0m" % e) game.current_player.print("\033[91m%s\033[0m" % e)
game.ready()
while not game.isFinished(): while not game.isFinished():
with open('saved_games.pickle', 'wb') as f: with open('saved_games.pickle', 'wb') as f:
ip1 = game.player1.input ip1 = game.player1.input