Beispiel #1
0
 def game_play_card(self, game_id, card):
     """
     Play one card in given game, by given player.
     """
     game = self._get_game(game_id)
     player = self.authenticated_player
     game.play_card(player, rpc.rpc_decode(Card, card))
     return True
Beispiel #2
0
    def player_register(self, player):
        """
        Register a new player to the server.

        Return the player id.
        """
        player = rpc.rpc_decode(RPCProxyPlayer, player)
        return self._register_player(player)
Beispiel #3
0
    def rpc_decode(cls, rpcobj):
        """
        Decode an rpc object into an Event instance.
        """
        instance = None
        for subcls in cls.__subclasses__():
            if getattr(subcls, 'type') == rpcobj['type']:
                return rpc.rpc_decode(subcls, rpcobj)

        return cls.rpc_decode_simple(rpcobj)
Beispiel #4
0
 def rpc_decode(cls, rpcobj):
     elist = cls()
     for event in rpcobj:
         elist.append(rpc.rpc_decode(Event, event))
     return elist
Beispiel #5
0
 def get_state(self, player_id):
     state = self.server.game.get_state(self.akey, self.game_id)
     state['game_state'] = rpc.rpc_decode(GameState, state['game_state'])
     state['hand'] = rpc.rpc_decode(CardSet, state['hand'])
     return state
Beispiel #6
0
 def get_events(self, player_id):
     return rpc.rpc_decode(EventList, self.server.get_events(self.akey))
Beispiel #7
0
 def rpc_decode(cls, rpcobj):
     cset = cls()
     for card in rpcobj:
         cset.append(rpc.rpc_decode(Card, card))
     return cset
Beispiel #8
0
    def rpc_decode(cls, rpcobj):
        card = Card(rpc.rpc_decode(Suit, rpcobj["suit"]), rpcobj["value"])
        if rpcobj.has_key("played_by"):
            card.played_by = rpcobj["played_by"]

        return card