From 5e2488695ea4d64d6d0a2d26aa099777af84dab0 Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Thu, 4 Jun 2015 04:47:05 +0100 Subject: 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 --- CAO_Player.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'CAO_Player.py') diff --git a/CAO_Player.py b/CAO_Player.py index 9501a46..94ff2cf 100644 --- a/CAO_Player.py +++ b/CAO_Player.py @@ -1,6 +1,8 @@ class CAO_Player(): - def __init__(self, client, cards): - self.cards = cards + def __init__(self, client): + self.cards = {} + self.next_idx = 0 + self.client = client self.score = 0 @@ -21,3 +23,7 @@ class CAO_Player(): def inc_score(self): self.score += 1 + + def receive_card(self, card): + self.cards[self.next_idx] = card + self.next_idx += 1 -- cgit v1.2.3