Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
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]
Ejemplo n.º 4
0
 def get_events(self):
     """
     Get the list of new events for given player.
     """
     return rpc.rpc_encode(self.authenticated_player.pop_events())
Ejemplo n.º 5
0
 def player_list(self):
     """
     List all players on server.
     """
     return [rpc.rpc_encode(player) for player in self.players]
Ejemplo n.º 6
0
 def rpc_encode(self):
     return [rpc.rpc_encode(event) for event in self]
Ejemplo n.º 7
0
 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']
Ejemplo n.º 8
0
 def play_card(self, player, card):
     self.server.game.play_card(self.akey, self.game_id, rpc.rpc_encode(card))
Ejemplo n.º 9
0
 def rpc_encode(self):
     return [rpc.rpc_encode(card) for card in self]