diff options
author | Olivier Gayot <olivier.gayot@sigexec.com> | 2020-05-15 02:39:03 +0200 |
---|---|---|
committer | Olivier Gayot <olivier.gayot@sigexec.com> | 2020-05-15 03:13:01 +0200 |
commit | 0106b23a685da72e97291771d9345aa608f8b8d4 (patch) | |
tree | 46eb0a15fc90a8afcb3c9735b76c4a97a2096226 /swiftstory/Game.py | |
parent | 0c9ee93b7381e9a198ff1efa6703d4cb68a0b58d (diff) |
Store cards as tuples (id, desc)
Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Diffstat (limited to 'swiftstory/Game.py')
-rw-r--r-- | swiftstory/Game.py | 25 |
1 files changed, 6 insertions, 19 deletions
diff --git a/swiftstory/Game.py b/swiftstory/Game.py index 7cd7d15..9fc5f17 100644 --- a/swiftstory/Game.py +++ b/swiftstory/Game.py @@ -15,8 +15,8 @@ class Game: self.white_desc = white_desc self.black_desc = black_desc - white_pick = [i for i, _ in enumerate(self.white_desc)] - black_pick = [i for i, _ in enumerate(self.black_desc)] + white_pick = [i for i in enumerate(self.white_desc)] + black_pick = [i for i in enumerate(self.black_desc)] self.state = self.WAITING_NEW_JUDGE @@ -57,7 +57,7 @@ class Game: if p is not player: await p.send_notification({'op': 'player_joined_game'}) - cards = self.__view_player_cards(player) + cards = [(idx, desc) for idx, (_, desc) in player.cards.items()] if self.state is self.WAITING_NEW_JUDGE: state = 'waiting_judge' @@ -179,33 +179,20 @@ class Game: return success(None) - def __view_player_cards(self, player): - cards = [] - - for card in player.cards: - cards.append((card, self.white_desc[player.cards[card]])) - - return cards - def try_view_player_cards(self, player): - return success(self.__view_player_cards(player)) + return success([(idx, desc) for idx, (_, desc) in player.cards.items()]) def try_view_played_cards(self, player): if self.state is not self.WAITING_DESIGNATION: return error('Not now, moron !') - cards = [] - - for card, unused in self.board.played_cards: - cards.append(self.white_desc[card]) - - return success(cards) + return success([desc for (_, desc), _ in self.board.played_cards]) def try_view_black_card(self, player): card = self.board.current_black_card if card is not None: - return success(self.black_desc[card]) + return success(card[1]) return error('The black card has not been revealed yet') |