示例#1
0
 def shutdown_loser(self):
     loser = Player.fetch(uid=self.loser_uid)
     url = loser.endpoint + "/shutdown"
     try:
         notify(url)
     except Exception:
         pass
示例#2
0
def create_player(request):
    log.debug("hello there")
    player_data = request.params
    log.debug("player_data = {}".format(player_data))

    player = Player.fetch(name=player_data['name'])
    if not player:
        player = Player(data=player_data)
        player.save()
    else:
        log.debug("Player {} already registered".format(player.name))

    ch = Championship.fetch()
    rt_dict = player.to_dict()
    rt_dict['championship_uuid'] = ch.uuid

    return json.dumps(rt_dict)
示例#3
0
    def notify_player(self, player_uid, opponent_uid, mode):
        player = Player.fetch(uid=player_uid)
        opponent = Player.fetch(uid=opponent_uid)

        data = {
            "championship_uuid": self.championship_uuid,
            "championship_name": self.championship_name,
            "game_uuid": self.game_uuid,
            "game_name": self.game_name,
            "mode": mode,
            "opponent": opponent.name,
            "stage": self.stage,
            "round_no": self.round_no,
            "defense_strength": player.defense_strength,
        }
        url = player.endpoint + "/game_info"
        notify(url, data=data)
示例#4
0
def create_player(request):
    log.debug("hello there")
    player_data = request.params
    log.debug("player_data = {}".format(player_data))

    player = Player.fetch(name=player_data['name'])
    if not player:
        player = Player(data=player_data)
        player.save()
    else:
        log.debug("Player {} already registered".format(player.name))

    ch = Championship.fetch()
    rt_dict = player.to_dict()
    rt_dict['championship_uuid'] = ch.uuid

    return json.dumps(rt_dict)
示例#5
0
def add_player_to_championship(request):

    championship_uuid = request.matchdict.get('championship_uuid')
    championship = Championship.fetch(uuid=championship_uuid)

    if len(championship.players) >= 8:
        return json.dumps({'status': 404})

    player_name = request.params.get('player_name')
    player = Player.fetch(name=player_name)

    log.debug("Champ ID: {}".format(championship.uid))
    try:
        championship.add_player(player)
        championship.save()
    except Exception:
        pass

    if len(championship.players) == 8:
        log.info("All players have registered. Starting Championship .. ")
        ChampionshipGreenlet(championship).start()

    return json.dumps({'status': 'ok'})
示例#6
0
def add_player_to_championship(request):

    championship_uuid = request.matchdict.get('championship_uuid')
    championship = Championship.fetch(uuid=championship_uuid)

    if len(championship.players) >= 8:
        return json.dumps({'status': 404})

    player_name = request.params.get('player_name')
    player = Player.fetch(name=player_name)

    log.debug("Champ ID: {}".format(championship.uid))
    try:
        championship.add_player(player)
        championship.save()
    except Exception:
        pass

    if len(championship.players) == 8:
        log.info("All players have registered. Starting Championship .. ")
        ChampionshipGreenlet(championship).start()

    return json.dumps({'status': 'ok'})
示例#7
0
def list_all_players(request):
    return json.dumps([p.to_dict() for p in Player.list()])
示例#8
0
def list_all_players(request):
    return json.dumps([p.to_dict() for p in Player.list()])