コード例 #1
0
    def onVerifySet(self, data, response):
        cards = [CardSerializer.from_dict(card) for card in data['cards']]
        result = self.game.receive_selection(cards, self.player)

        response.update({
            'player': self.player.id,
            'found': len(self.player.found)
        })
        if result.valid == SetValidation['OK']:
            response.update({
                'valid': True,
                'cards_to_remove': [CardSerializer.to_dict(card) for card in result.old_cards],
                'cards_to_add': [CardSerializer.to_dict(card) for card in result.new_cards],
                'game_over': result.game_over
            })
        self.broadcast_as_json(response)
コード例 #2
0
ファイル: solitairegame.py プロジェクト: jharris119/set-game
    def PUT(self):
        game = cherrypy.session.get('game')

        cards = cherrypy.request.json['cards']
        result = game.receive_selection([CardSerializer.from_dict(card) for card in cards])
        response = {'result': result.name}
        if result.name == 'OK' and game.solved():
            response.update({'solved': True})
        return response