Eric Botti
commited on
Commit
·
9b424c4
1
Parent(s):
ff62b8a
added rounds
Browse files- src/app.py +25 -11
src/app.py
CHANGED
@@ -43,17 +43,31 @@ class StreamlitChameleonGame(ChameleonGame):
|
|
43 |
def run_game(self):
|
44 |
"""Starts the game."""
|
45 |
|
46 |
-
if
|
47 |
-
|
48 |
-
self.game_state
|
49 |
-
|
50 |
-
|
51 |
-
self.game_state
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
self.game_state
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
|
58 |
def run_round(self):
|
59 |
"""Starts the round."""
|
|
|
43 |
def run_game(self):
|
44 |
"""Starts the game."""
|
45 |
|
46 |
+
# Check if the game has not been won
|
47 |
+
if self.game_state != "game_end":
|
48 |
+
if self.game_state == "game_start":
|
49 |
+
self.game_message(fetch_prompt("game_rules"))
|
50 |
+
self.game_state = "setup_round"
|
51 |
+
if self.game_state == "setup_round":
|
52 |
+
self.setup_round()
|
53 |
+
self.game_state = "animal_description"
|
54 |
+
if self.game_state in ["animal_description", "chameleon_guess", "herd_vote"]:
|
55 |
+
self.run_round()
|
56 |
+
if self.game_state == "resolve_round":
|
57 |
+
self.resolve_round()
|
58 |
+
|
59 |
+
points = [player.points for player in self.players]
|
60 |
+
|
61 |
+
if max(points) >= self.winning_score:
|
62 |
+
self.game_state = "game_end"
|
63 |
+
self.winner_id = self.players[points.index(max(points))].id
|
64 |
+
else:
|
65 |
+
self.game_state = "setup_round"
|
66 |
+
self.run_game()
|
67 |
+
|
68 |
+
if self.game_state == "game_end":
|
69 |
+
self.game_message(f"The game is over {self.winner_id} has won!")
|
70 |
+
|
71 |
|
72 |
def run_round(self):
|
73 |
"""Starts the round."""
|