From 5efa11261059c0f105b06650b3a687c31d546d55 Mon Sep 17 00:00:00 2001 From: legonzaur Date: Sat, 20 Apr 2024 00:31:55 +0200 Subject: [PATCH] notify players when cards are initially drawn --- src/model/game.py | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/src/model/game.py b/src/model/game.py index e76f50a..8e3f40f 100644 --- a/src/model/game.py +++ b/src/model/game.py @@ -35,12 +35,12 @@ class Game(Serializable): def __init__(self): super().__init__() - self.market_stack = [] - self.market = [None for _ in range(5)] - self.gem_stack = [] - self.players = [] - self.cards = [] - self.teams = [] + self.market_stack: List[Card] = [] + self.market: List[Card] = [None for _ in range(5)] + self.gem_stack: List[Card] = [] + self.players: List[Player] = [] + self.cards: List[Card] = [] + self.teams: List[Team] = [] self.started = False @@ -179,6 +179,28 @@ class Game(Serializable): await asyncio.gather(*draws) + await self.notify_controller("update", self.serialize_guest()) + + notifications = [] + + # Send cards in hand to teams + for t in self.teams: + current_team = [p for p in self.players if p.team == t] + for p in current_team: + for o in current_team: + notifications.append( + p.notify_controller("update", o.serialize_team()) + ) + + # Send cards in hand to all others + for p in self.players: + for o in self.players: + if p.team == o.team: + continue + notifications.append(p.notify_controller("update", o.serialize_guest())) + + await asyncio.gather(*notifications) + print( "start game with " + str(len(self.players))