diff options
-rw-r--r-- | CAO_Game.py | 18 | ||||
-rw-r--r-- | cao-common.js | 10 | ||||
-rw-r--r-- | cao-desktop.js | 2 |
3 files changed, 21 insertions, 9 deletions
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: diff --git a/cao-common.js b/cao-common.js index cd6ec08..e46f39b 100644 --- a/cao-common.js +++ b/cao-common.js @@ -3,7 +3,7 @@ var CAO = function() { this.on_socket_close = function() { /* to override */ }; this.on_socket_error = function(evt) { /* to override */}; - this.on_join_game_ok = function() { /* to override */ }; + this.on_join_game_ok = function(state) { /* to override */ }; this.on_show_white_card = function(idx, desc) { /* to override */ }; this.on_pick_black_card_ok = function() { /* to override */ }; this.on_show_black_card = function(desc) { /* to override */ }; @@ -33,14 +33,14 @@ var CAO = function() { /* map_handle_response_ok {{{ */ map_handle_response_ok['join_game'] = function(result) { - self.on_join_game_ok(); + self.on_join_game_ok(result['state']); map_handle_response_ok['view_player_cards'](result); }; map_handle_response_ok['view_player_cards'] = function(result) { - for (var i in result) { - var idx = result[i][0]; - var desc = result[i][1]; + for (var i in result['cards']) { + var idx = result['cards'][i][0]; + var desc = result['cards'][i][1]; white_cards[idx] = desc; diff --git a/cao-desktop.js b/cao-desktop.js index 283893b..2517ef6 100644 --- a/cao-desktop.js +++ b/cao-desktop.js @@ -17,7 +17,7 @@ $(document).ready(function() { $('#btn_join').show(); }; - cao.on_join_game_ok = function() { + cao.on_join_game_ok = function(state) { $('#btn_join').hide(); $('#btn_pick_black').show(); $('#white_cards').show(); |