From 76431d4ff189b8531f7bc89dc80e9fa4b8e79bbd Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Fri, 5 Jun 2015 02:13:25 +0100 Subject: provide the state of the game to a newcomer Signed-off-by: Olivier Gayot --- CAO_Game.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'CAO_Game.py') diff --git a/CAO_Game.py b/CAO_Game.py index c12442a..aac2c57 100644 --- a/CAO_Game.py +++ b/CAO_Game.py @@ -52,7 +52,16 @@ class CAO_Game(): if p is not player: p.send_notification({'op': 'player_joined_game'}) - return self.try_view_player_cards(player) + cards = self.__view_player_cards(player) + + if self.state is self.WAITING_NEW_JUDGE: + state = 'waiting_judge' + elif self.state is self.WAITING_COLLECTION: + state = 'waiting_collection' + else: + state = 'waiting_designation' + + return cao_success({'cards': cards, 'game_state': state}) def try_become_judge(self, player): @@ -166,13 +175,16 @@ class CAO_Game(): return cao_success(None) - def try_view_player_cards(self, player): + def __view_player_cards(self, player): cards = [] for card in player.cards: cards.append((card, self.white_desc[player.cards[card]])) - return cao_success(cards) + return cards + + def try_view_player_cards(self, player): + return cao_success(self.__view_player_cards(player)) def try_view_played_cards(self, player): if self.state is not self.WAITING_DESIGNATION: -- cgit v1.2.3