Ejemplo n.º 1
0
    def Network_response(self, data):
        client = self.get_sender(data)

        if BUYFROMPILE in data:
            try:
                self._server.game.buy_card(client.player, nwp.unpack(data[BUYFROMPILE]))
            except (NotEnoughMoneyException, PileIsEmptyException):
                pass

        if PLAYCARD in data:
            self._server.game.play_card(client.player, nwp.unpack(data[PLAYCARD]))

        if ANSWER in data:
            self._server.game.answered(client.player, nwp.unpack(data[ANSWER]), nwp.unpack(data[SUBID]))
Ejemplo n.º 2
0
 def proceed_boardcommon(self, data):
     newboardcommon = nwp.unpack(data[BOARDCOMMON])
     self.boardcommon = []
     for item in newboardcommon:
         pile = KingdomPile(item[1], item[2])
         pile.id = item[0]
         pile.calc_cost = item[3]
         self.boardcommon.append(pile)
     NewBoardCommonEvent(self.boardcommon).post(self.ev)
Ejemplo n.º 3
0
 def proceed_boardsetup(self, data):
     newboardsetup = nwp.unpack(data[BOARDSETUP])
     self.boardsetup = []
     for item in newboardsetup:
         pile = KingdomPile(item[1], item[2])
         pile.id = item[0]
         pile.calc_cost = item[3]
         self.boardsetup.append(pile)
     NewBoardSetupEvent(self.boardsetup).post(self.ev)
Ejemplo n.º 4
0
 def proceed_board(self, data):
     NewBoardEvent(nwp.unpack(data[BOARD])).post(self.ev)
Ejemplo n.º 5
0
 def proceed_hand(self, data):
     NewHandEvent(nwp.unpack(data[HAND]), nwp.unpack(data[DECK])).post(self.ev)
Ejemplo n.º 6
0
 def proceed_subid(self, data):
     if data[CLIENTID] == self.id:
         info = nwp.unpack(data[INFO]) if INFO in data else None
         self.sub_id = nwp.unpack(data[SUBID])
         SubPhaseChangedEvent(data[SUBPHASE], info, self.sub_id).post(self.ev)
Ejemplo n.º 7
0
 def proceed_playerinfo(self, data):
     PlayerInfoEvent(nwp.unpack(data[PLAYERINFO])).post(self.ev)
Ejemplo n.º 8
0
 def Network_end(self, data):
     result = nwp.unpack(data[RESULT])
     EndGameEvent(result).post(self.ev)