コード例 #1
0
ファイル: db_tdm.py プロジェクト: coyote963/bman-data
def get_player(js):
    """Takes a js and returns the player account associated with that js"""
    x = json.loads(js)
    player_account = PlayerAccount(platform=x['StoreID'],
                                   profile=x['ProfileID'])
    try:
        player = Player.objects.get(profile=player_account)
    except DoesNotExist:
        print("ERROR PLAYER DOES NOT EXIST")
        return
    return player
コード例 #2
0
ファイル: db_tdm.py プロジェクト: coyote963/bman-data
def db_list_players(player_list):
    """Takes a list of player profiles and returns a list of Player objects"""
    return_list = []
    for p in player_list:
        profile = PlayerAccount(platform=p['StoreID'], profile=p['ProfileID'])
        player = Player.objects.get(profile=profile)
        if player is not None:
            return_list.append(player)
        else:
            raise Exception("Player not found")
    return return_list
コード例 #3
0
ファイル: db_svl.py プロジェクト: coyote963/bman-data
def update_svl_deaths(js):
    if js["KillerID"] in enemy_dict and js['VictimID'] in player_dict:
        victim = PlayerAccount(
            platform=player_dict[js['VictimID']]["platform"],
            profile=player_dict[js['VictimID']]["profile"])
        victim = Player.objects.get(profile=victim)
        svlDeath = SVLDeath(victim=victim,
                            enemy_rank=enemy_dict[js["KillerID"]]["EnemyRank"],
                            enemy_type=enemy_dict[js["KillerID"]]["EnemyType"],
                            current_round=current_round,
                            weapon=js["KillerWeapon"])
        svlDeath.save()
コード例 #4
0
ファイル: db_svl.py プロジェクト: coyote963/bman-data
def update_svl_kills(js):
    if js["VictimID"] in enemy_dict and js['KillerID'] in player_dict:
        killer = PlayerAccount(
            platform=player_dict[js['KillerID']]["platform"],
            profile=player_dict[js['KillerID']]["profile"])
        killer = Player.objects.get(profile=killer)
        svlkill = SVLKill(killer=killer,
                          enemy_rank=enemy_dict[js["VictimID"]]["EnemyRank"],
                          enemy_type=enemy_dict[js["VictimID"]]["EnemyType"],
                          current_round=current_round,
                          weapon=js['KillerWeapon'])
        svlkill.save()
コード例 #5
0
ファイル: db_svl.py プロジェクト: coyote963/bman-data
def update_svl_chat(js):
    x = json.loads(js['Profile'])

    profile = PlayerAccount(platform=x['StoreID'], profile=x['ProfileID'])
    try:
        player = Player.objects.get(profile=profile)
    except DoesNotExist:
        return
    svl_message = SVLMessage(message=js['Message'],
                             name=js['Name'],
                             profile=player)
    svl_message.save()
コード例 #6
0
ファイル: db_dm.py プロジェクト: coyote963/bman-data
def upsert_player(profile_id: dict):
    """Updates and returns a new Casino Player, if the underlying player object does not exist, returns with an error"""
    player_prof = PlayerAccount(platform=profile_id['StoreID'],
                                profile=profile_id['ProfileID'])
    try:
        db_player = Player.objects.get(profile=player_prof)
    except DoesNotExist:
        raise Exception(
            "The player object associated with this account does not exist:\n{}"
            .format(profile_id))
    try:
        casino_player = CasinoPlayer.objects.get(player=db_player)
    except DoesNotExist:
        casino_player = CasinoPlayer(player=db_player)
    casino_player.save()
    return [casino_player, db_player]
コード例 #7
0
ファイル: db_tdm.py プロジェクト: coyote963/bman-data
def upsert_player(profile_id):
    """Updates and returns a new TDMProfile Player, if the underlying player object does not exist, returns with an error"""
    try:
        profile_id = json.loads(profile_id)
    except:
        pass
    player_prof = PlayerAccount(platform=profile_id['StoreID'],
                                profile=profile_id['ProfileID'])
    try:
        db_player = Player.objects.get(profile=player_prof)
    except DoesNotExist:
        raise Exception(
            "The player object associated with this account does not exist:\n{}"
            .format(profile_id))
    try:
        tdm_profile = TDMProfile.objects.get(player=db_player)
    except DoesNotExist:
        tdm_profile = TDMProfile(player=db_player)
    tdm_profile.save()
    return tdm_profile
コード例 #8
0
def update_player(js):
    profile = PlayerAccount(platform=js['Store'], profile=js['Profile'])
    if 'IP' not in js:
        Player.objects(profile=profile).update_one(
            set__color=js['Color'],
            set__premium=js['Premium'],
            add_to_set__name=js['Name'],
            set__hat=js['Hat'],
            set__clan_id=js['ClanID'] if 'ClanID' in js else "",
            set__clan_tag=js['ClanTag'] if 'ClanTag' in js else "",
            upsert=True)
    else:
        Player.objects(profile=profile).update_one(
            set__color=js['Color'],
            set__premium=js['Premium'],
            add_to_set__name=js['Name'],
            add_to_set__ip=js['IP'],
            set__hat=js['Hat'],
            set__clan_id=js['ClanID'] if 'ClanID' in js else "",
            set__clan_tag=js['ClanTag'] if 'ClanTag' in js else "",
            upsert=True)
コード例 #9
0
def get_player(x):
    """Gets a single player from a json packet"""
    try:
        x = json.loads(x)
    except:
        pass
    if 'StoreID' in x:
        store = x['StoreID']
        profile = x['ProfileID']
    else:
        store = x['Store']
        profile = x['Profile']
    player_account = PlayerAccount(
        platform = store,
        profile = profile
    )
    try:
        player = Player.objects.get(profile = player_account)
    except DoesNotExist:
        raise Exception("Can't retrieve player")
    return player
コード例 #10
0
ファイル: db_dm.py プロジェクト: coyote963/bman-data
def update_dm_kills(js):
    killer = PlayerAccount(platform=player_dict[js['KillerID']]['platform'],
                           profile=player_dict[js['KillerID']]['profile'])
    victim = PlayerAccount(platform=player_dict[js['VictimID']]['platform'],
                           profile=player_dict[js['VictimID']]['profile'])
    try:
        dm_killer_player = Player.objects.get(profile=killer)
    except DoesNotExist:
        print("ERROR PLAYER DOES NOT EXIST")
        return
    try:
        dm_victim_player = Player.objects.get(profile=victim)
    except DoesNotExist:
        print("ERROR PLAYER DOES NOT EXIST")
        return

    try:
        dm_killer_profile = DMProfile.objects.get(player=dm_killer_player)
    except DoesNotExist:
        dm_killer_profile = DMProfile(player=dm_killer_player)

    try:
        dm_victim_profile = DMProfile.objects.get(player=dm_victim_player)
    except DoesNotExist:
        dm_victim_profile = DMProfile(player=dm_victim_player)
    if 'KillerX' in js and 'KillerY' in js:
        dm_kill = DMKill(killer=dm_killer_player,
                         killer_profile=dm_killer_profile,
                         victim_profile=dm_victim_profile,
                         victim=dm_victim_player,
                         weapon=js['KillerWeapon'],
                         killer_location=js['KillerX'] + "," + js['KillerY'],
                         victim_location=js['VictimX'] + "," + js['VictimY'],
                         match=current_match)
    else:
        dm_kill = DMKill(killer=dm_killer_player,
                         killer_profile=dm_killer_profile,
                         victim_profile=dm_victim_profile,
                         victim=dm_victim_player,
                         weapon=js['KillerWeapon'],
                         killer_location="unknown",
                         victim_location=js['VictimX'] + "," + js['VictimY'],
                         match=current_match)
    adjustment = perform_trueskill_adjustment(dm_killer_profile,
                                              dm_victim_profile)
    dm_killer_profile.mu = adjustment['killer_mu']
    dm_killer_profile.sigma = adjustment['killer_sigma']
    dm_victim_profile.mu = adjustment['victim_mu']
    dm_victim_profile.sigma = adjustment['victim_sigma']

    dm_killer_profile.kills = dm_killer_profile.kills + 1
    dm_victim_profile.deaths = dm_victim_profile.deaths + 1

    dm_killer_profile.last_updated = datetime.utcnow()
    dm_victim_profile.last_updated = datetime.utcnow()

    dm_killer_profile.save()
    dm_victim_profile.save()

    killer_rating_instance = DMRatingInstance(
        mu=adjustment['killer_mu'],
        sigma=adjustment['killer_sigma'],
        mu_delta=adjustment['killer_mu_delta'],
        sigma_delta=adjustment['killer_sigma_delta'])

    victim_rating_instance = DMRatingInstance(
        mu=adjustment['victim_mu'],
        sigma=adjustment['victim_sigma'],
        mu_delta=adjustment['victim_mu_delta'],
        sigma_delta=adjustment['victim_sigma_delta'])

    dm_kill.killer_rating = killer_rating_instance
    dm_kill.victim_rating = victim_rating_instance
    dm_kill.save()
コード例 #11
0
def update_player_array(js):
    x = json.loads(js['Profile'])
    profile = PlayerAccount(platform=x['StoreID'], profile=x['ProfileID'])
    Player.objects(profile=profile).update_one(add_to_set__ip=js['IP'], )