diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2021-12-23 19:43:47 +0100 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2021-12-23 23:15:21 +0100 |
commit | 7d39216a3bbea50223ac4a6d7a9e6343b8247886 (patch) | |
tree | 86ac5ba1b9b429bc8dfbccf65d0a80abb86c2917 /swiftstory/game.py | |
parent | 143947ad03054b7297de4da4195548860e6541f1 (diff) |
Don't store a reference to a client from the player
The only reason why we had a reference was that we were able to send
notifications back to the client.
Instead, we now store the notifications at the player level.
At the client level, we now have a coroutine that waits for
notifications from the player and sends them when available.
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'swiftstory/game.py')
-rw-r--r-- | swiftstory/game.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/swiftstory/game.py b/swiftstory/game.py index f48633b..8ed56fc 100644 --- a/swiftstory/game.py +++ b/swiftstory/game.py @@ -41,7 +41,7 @@ class Game: except IndexError: raise JoinError('not enough white cards for player') - player = Player(client) + player = Player() for card in cards: player.receive_card(card) @@ -49,6 +49,8 @@ class Game: client.player = player client.game = self + client.monitor_player() + self.players.append(player) for p in self.players: @@ -195,8 +197,6 @@ class Game: raise WrongAction('The black card has not been revealed yet') def disconnect(self, player): - player.client = None - if self.judge is player: self.judge = None |