diff --git a/server/game/lobby.py b/server/game/lobby.py index f25bda9..f214a06 100644 --- a/server/game/lobby.py +++ b/server/game/lobby.py @@ -66,7 +66,6 @@ class LobbyManager(ClientManager): meta = self.metadata[player.name] meta.last_announce = announce meta.fresh_announce = True - print(f"{player} announced {announce}!") async def start_game(self, players: Optional[List[Player]] = None, max_players=2): if not players: diff --git a/server/model/game.py b/server/model/game.py index 42001ac..895e367 100644 --- a/server/model/game.py +++ b/server/model/game.py @@ -78,7 +78,7 @@ class Game: current_player.give(card) print(f"{card}") - await self.message(MessageToPlayer.GiveHand, current_player, extra=current_player.hand) + await self.message(MessageToPlayer.GiveHand, current_player, extra=current_player.hand.json()) print(f"Cards sent.") # Tour @@ -143,14 +143,16 @@ class Game: print(f"| {current_player}'s turn >") if not self.current_bet: # First player, has to bet something + print("Game: First awaiting current bet") await self.message(MessageToPlayer.YourTurn, current_player, extra=self.current_bet) while not self.current_bet: # Ask a valid bet - # FIXME: Wait for player announce? Maybe just sleep 10? + print("Game: While no bet, awaiting") announce = await current_player.announce(self.current_bet) if announce.bet: self.current_bet = announce.bet print(f"{current_player} starts the round: {self.current_bet}") - await self.message(MessageToPlayer.Announce, extra={"player": current_player, "announce": announce}) + print("Game: Awaiting start announce") + await self.message(MessageToPlayer.Announce, extra={"player": current_player.name, "announce": announce.json()}) else: print(f"You cannot say Menteur on first round, {current_player}!") @@ -161,13 +163,14 @@ class Game: print("CARRE D'AS!") announce = Announce() # MENTEUR obligatoire else: + print("Game: Awaiting bet") await self.message(MessageToPlayer.YourTurn, current_player, extra=self.current_bet) - announce = current_player.announce(self.current_bet) + announce = await current_player.announce(self.current_bet) if announce.bet: while announce.bet.value() < self.current_bet.value(): # Bad announce! print(f"Invalid bet by {current_player}, {announce.bet} < {self.current_bet}!") - announce = current_player.announce(self.current_bet) + announce = await current_player.announce(self.current_bet) self.current_bet = announce.bet # Valid bet: diff --git a/server/ws.py b/server/ws.py index 23963d4..6d67f95 100644 --- a/server/ws.py +++ b/server/ws.py @@ -23,14 +23,14 @@ class ClientPlayer(Player): async def announce(self, current_bet: Optional[Hand]) -> Announce: metadata: Metadata = self.lobby.metadata[self.name] - print(f"Asking Client {self.name} for announce...", end="") + print(f"Asking Client {self.name} for announce...") while not metadata.last_announce and metadata.fresh_announce: await lobby.send_waiting_for(self) - print(".", end="") + print(f"Still waiting for {self.name}'s announce...") sleep(2) - print(f" {metadata.last_announce.bet}!") + print(f"Client announced: {metadata.last_announce.bet}!") return metadata.last_announce