Exemplo n.º 1
0
    def get(self, uid):
        """doc string"""
        player = bench[uid]
        if not player:
            print('ERROR: got request for unknown player: {}'.format(uid))
            return res_wrap(oh_no())

        game = library.checkout(player)
        if not game:
            print('ERROR: could not find game for player: {}'.format(uid))
            return res_wrap(oh_no())

        return res_wrap(json.dumps(adapter.enrich_message(game)))
Exemplo n.º 2
0
    def get(self, uid):
        """doc string"""
        player = bench[uid]
        if not player:
            print('ERROR: got request for unknown player: {}'.format(uid))
            return res_wrap(oh_no())

        game = library.checkout(player)
        if not game:
            print('ERROR: could not find game for player: {}'.format(uid))
            return res_wrap(oh_no())

        return res_wrap(json.dumps(adapter.enrich_message(game)))
Exemplo n.º 3
0
    def get(self, uid):
        """Return a game that can be played by the player with pid"""
        logging.debug('API_Game.get %s', uid)

        try:
            player = RESTPlayer(Player.load(uid).dumpd())
        except KeyError:
            logging.error('API_Game.get for unknown pid %s', uid)
            return flask.make_response(oh_no())

        # Apply any score change that results from other people moves
        score_change = Score.check_for_score_update(player.pid)
        if score_change:
            player.score += score_change
            player.save()

        game = Game.pick(player)
        return flask.make_response(json.dumps(adapter.enrich_message(game)))