diff options
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') |