def game_get_state(self, game_id): """ Get the state of a game for given player. """ game = self._get_game(game_id) response = {} response['game_state'] = rpc.rpc_encode(game.state) response['hand'] = rpc.rpc_encode(self.authenticated_player.hand) return response
def rpc_encode(self, private=False): rpcobj = players.Player.rpc_encode(self) # don't encode the game object, just the ID if self.game: rpcobj['game_id'] = rpc.rpc_encode(self.game.id) if private: if hasattr(self, 'akey'): rpcobj['akey'] = self.akey return rpcobj
def _game_get_rpc_info(game): """ Get RPC info for a GameController instance. TODO: does not belong here. """ return [rpc.rpc_encode(player) for player in game.players]
def get_events(self): """ Get the list of new events for given player. """ return rpc.rpc_encode(self.authenticated_player.pop_events())
def player_list(self): """ List all players on server. """ return [rpc.rpc_encode(player) for player in self.players]
def rpc_encode(self): return [rpc.rpc_encode(event) for event in self]
def register_player(self, player): player.controller = self plr_data = self.server.player.register(rpc.rpc_encode(player)) player.id = plr_data['id'] self.akey = plr_data['akey']
def play_card(self, player, card): self.server.game.play_card(self.akey, self.game_id, rpc.rpc_encode(card))
def rpc_encode(self): return [rpc.rpc_encode(card) for card in self]