summaryrefslogtreecommitdiff
path: root/swiftstory
diff options
context:
space:
mode:
Diffstat (limited to 'swiftstory')
-rw-r--r--swiftstory/Board.py13
-rw-r--r--swiftstory/Game.py25
2 files changed, 13 insertions, 25 deletions
diff --git a/swiftstory/Board.py b/swiftstory/Board.py
index f14df41..c9b2aee 100644
--- a/swiftstory/Board.py
+++ b/swiftstory/Board.py
@@ -6,17 +6,18 @@ class Board:
of cards '''
def __init__(self):
+ # List of tuples:
+ # (card_id, card_desc)
self.white_pick = list()
self.black_pick = list()
-
- self.white_recycled = []
- self.black_recycled = []
+ self.white_recycled = list()
+ self.black_recycled = list()
self.current_black_card = None
- # tupple of cards / player currently being played
- self.played_cards = []
-
+ # List of tuples:
+ # ((card_id, card_desc), player)
+ self.played_cards = list()
def reveal_next_black_card(self):
if self.current_black_card is not None:
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')