diff options
author | Olivier Gayot <duskcoder@gmail.com> | 2015-06-04 04:47:05 +0100 |
---|---|---|
committer | Olivier Gayot <duskcoder@gmail.com> | 2015-06-04 04:47:05 +0100 |
commit | 5e2488695ea4d64d6d0a2d26aa099777af84dab0 (patch) | |
tree | da4ec442fe56674dd4f1454d3ed399183b5c7536 /CAO_Game.py | |
parent | 8a78e43e456b57c26843f9524b4e34fcf0d5913a (diff) |
the cards of a player are stored in a map
the problem with the list is that when we take a card in the middle, the
following indexes are shifted. It is inconvenient to shift them on the
end user side's so we use a map with incremented indexes.
Signed-off-by: Olivier Gayot <duskcoder@gmail.com>
Diffstat (limited to 'CAO_Game.py')
-rw-r--r-- | CAO_Game.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/CAO_Game.py b/CAO_Game.py index 3738277..c6072a5 100644 --- a/CAO_Game.py +++ b/CAO_Game.py @@ -38,7 +38,11 @@ class CAO_Game(): except IndexError: return cao_error('no enough white cards for player') - player = CAO_Player(client, cards) + player = CAO_Player(client) + + for card in cards: + player.receive_card(card) + client.set_player(player) client.set_game(self) @@ -122,7 +126,7 @@ class CAO_Game(): # reset the state of the players for p in self.players: if p.get_has_played: - p.cards.append(self.board.pick_white_card()) + p.receive_card(self.board.pick_white_card()) p.set_has_played(False) self.board.recycle_black_card() @@ -136,7 +140,7 @@ class CAO_Game(): cards = [] for card in player.cards: - cards.append(self.white_desc[card]) + cards.append((card, self.white_desc[player.cards[card]])) return cao_success(cards) |