From 532045a6ba2b4a8ebca640735c9beadddf5a891f Mon Sep 17 00:00:00 2001 From: Jerry Wu Date: Mon, 27 Aug 2018 11:22:43 +0800 Subject: [PATCH] Main game function modified, turn bug fixed --- Game.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Game.py b/Game.py index 17413fc..a46e058 100644 --- a/Game.py +++ b/Game.py @@ -1,4 +1,5 @@ import Player, Card +from random import shuffle class Game: def __init__(self, first, second): @@ -8,7 +9,6 @@ class Game: self.turn = 0 def main(self): while self.first.hp > 0 and self.second.hp > 0: - self.turn += 1 # Poison Check if self.first.poison: print("{}因劇毒損失了{}".format(self.first.name, self.first.poison)) @@ -17,6 +17,7 @@ class Game: print("{}倒下ㄌ".format(self.first.name)) break print("========Turn {} {}========".format(self.turn//2+1, "先攻" if self.turn%2 else "後攻")) + self.turn += 1 draw = self.first.draw() if not draw: print("{}抽到了死神 吧".format(self.first.name)) @@ -66,5 +67,8 @@ class Game: winner = self.second if self.first.hp <= 0 else self.first print("{}贏了".format(winner.name)) -game = Game(Player.Keieit(), Player.Rabbit()) -game.main() \ No newline at end of file +if __name__ == "__main__": + players = [Player.Keieit(), Player.Rabbit()] + shuffle(players) + game = Game(*players) + game.main() \ No newline at end of file