import webstats_utils import os.path from webstats_utils import color as c from webstats_utils import html_et_colors as etcolor class Weapon: def __init__(self, weapon): self.weapon_id = weapon self.hits = 0 self.shots = 0 self.kills = 0 self.deaths = 0 self.headshots = 0 self.acc = 0 class PlayerStats: def __init__(self): self.weapons = [] self.total_shots = 0 self.total_hits = 0 self.total_kills = 0 self.total_deaths = 0 self.total_headshots = 0 self.damage_given = 0 self.damage_received = 0 self.team_damage_given = 0 self.team_damage_received = 0 self.gibs = 0 self.self_kills = 0 self.team_kills = 0 self.team_gibs = 0 self.efficiency = 0 self.play_time_ratio = 0 self.hit_ratio = 0 self.headshot_ratio = 0 self.xp = 0 self.has_stats = False class Player: def __init__(self, id, guid, name, rounds, team): self.id = id self.guid = guid self.name = name self.rounds = rounds self.team = webstats_utils.Team(team) self.stats = PlayerStats() class GameStats: def __init__(self): self.total_kills = 0 self.total_deaths = 0 self.total_gibs = 0 self.total_self_kills = 0 self.total_team_kills = 0 self.total_team_gibs = 0 self.total_damage_given = 0 self.total_damage_received = 0 self.total_team_damage_given = 0 self.total_team_damage_received = 0 self.total_xp = 0 self.total_play_time = 0 self.total_efficiency = 0 class GameTeams: def __init__(self, team): self.team = team self.stats = GameStats() class Game: def set(self, servername, mapname, config, round, defender, winner, timelimit, nextTimelimit, matchID): self.matchID = matchID self.servername = webstats_utils.strip_color_codes(servername) self.mapname = mapname self.config = config self.round = round self.defender = webstats_utils.Team(defender) self.winner = webstats_utils.Team(winner) self.timelimit = timelimit self.nextTimelimit = nextTimelimit self.players = [] self.teams = [] for team in webstats_utils.Team: self.teams.append(GameTeams(team)) def get_current_team (game, team1_players): # loop over all players in the current round for player in game.players: # loop over all guids stored in team1 player list for guid in team1_players: # determine whether or not any of the guids in team1 players match the guids in current round # if so, return the current team name of the player that matched the guid in team1's list if player.guid == guid: return player.team.name[5:] def get_match_totals(dir_path, roundlist, team1, team2): players_totals = {} map_round1_stats = {} roundcount = 0 current_round = 1 set_display = "" team1_players = [] team2_players = [] team1_count = 0 team2_count = 0 team1_score = 0 team2_score = 0 round1_fullhold = False round2_fullhold = False for filename in roundlist: game = get_game(dir_path, filename) roundcount += 1 # Check for fullholds in each round '''if game.winner.name[5:] == "AXIS" and game.nextTimelimit == game.timelimit: if roundcount == 1: round1_fullhold = True elif roundcount == 2: round2_fullhold = True elif roundcount == 1: round1_time = game.nextTimelimit elif roundcount == 2 and game.nextTimelimit < round1_time: allies_beat_time = True''' # Check for fullholds in each round '''if game.winner.name[5:] == game.defender.name[5:] and game.nextTimelimit == game.timelimit: if roundcount == 1: round1_fullhold = True defending_team1 = game.defender.name[5:] elif roundcount == 2: round2_fullhold = True defending_team2 = game.defender.name[5:]''' for team in game.teams[1:]: for player in game.players: #player_key = (player.name, player.guid) player_key = (player.guid) if player.team == team.team: # logic for handling round 2 cumulative data if current_round == 1: if player_key not in map_round1_stats: map_round1_stats[player_key] = { "total_kills": player.stats.total_kills, "total_deaths": player.stats.total_deaths, "damage_given": player.stats.damage_given, "damage_received": player.stats.damage_received, "team_damage_given": player.stats.team_damage_given, "team_kills": player.stats.team_kills, "self_kills": player.stats.self_kills, "xp": player.stats.xp, "playtime": player.stats.play_time_ratio, "weapons": {weapon.weapon_id: {"hits": weapon.hits, "shots": weapon.shots, "kills": weapon.kills, "deaths": weapon.deaths, "headshots": weapon.headshots} for weapon in player.stats.weapons} } elif current_round == 2: round1_stats = map_round1_stats.get(player_key) if round1_stats: player.stats.total_kills = player.stats.total_kills - round1_stats["total_kills"] player.stats.total_deaths = player.stats.total_deaths - round1_stats["total_deaths"] player.stats.damage_given = player.stats.damage_given - round1_stats["damage_given"] player.stats.damage_received = player.stats.damage_received - round1_stats["damage_received"] player.stats.team_damage_given = player.stats.team_damage_given - round1_stats["team_damage_given"] player.stats.team_kills = player.stats.team_kills - round1_stats["team_kills"] player.stats.self_kills = player.stats.self_kills - round1_stats["self_kills"] player.stats.xp = player.stats.xp - round1_stats["xp"] player.stats.play_time_ratio = player.stats.play_time_ratio # Subtract round 1 weapon data from round 2 for weapon in player.stats.weapons: weapon1 = round1_stats["weapons"].get(weapon.weapon_id) if weapon1: weapon.hits -= weapon1["hits"] weapon.shots -= weapon1["shots"] weapon.kills -= weapon1["kills"] weapon.deaths -= weapon1["deaths"] weapon.headshots -= weapon1["headshots"] # Store the aggregated stats in players_totals # initialize dictionary for a new player if player_key not in players_totals: # check config type to know how many players should be on a team # add players to their initial teams and assign the user input team display names if game.config in ["legacy6", "legacy5", "legacy3", "legacy1", "practice"]: team_limit = 5 if game.config == "legacy6" else 4 if game.config == "legacy5" else 2 if game.config == "legacy3" else 1 if team1_count <= team_limit: if player.team.name[5:] == "ALLIES": set_display = team1 team1_players.append(player.guid) team1_count += 1 else: set_display = team2 team2_players.append(player.guid) team2_count += 1 else: # Check the players already stored in the team1_players and team2_players list # and see if we can find a match of the current game team name for the new player. # There only needs to be one match to safely assume we know that the player entering # the game is on the same team as the evaluated comparison in the list. '''team1_match = any( p.team.name[5:] == player.team.name[5:] for p in game.players if p.guid in team1_players ) if team1_match: team1_players.append(player.guid) set_display = team1 team1_count += 1 else: team2_players.append(player.guid) set_display = team2 team2_count += 1''' current_team = get_current_team(game, team1_players) if player.team.name[5:] == current_team: set_display = team1 team1_players.append(player.guid) team1_count += 1 else: set_display = team2 team2_players.append(player.guid) team2_count += 1 players_totals[player_key] = { "team_name": player.team.name[5:], "total_kills": player.stats.total_kills, "efficiency": player.stats.efficiency, "gibs": player.stats.gibs, "total_deaths": player.stats.total_deaths, "damage_given": player.stats.damage_given, "damage_received": player.stats.damage_received, "team_damage_given": player.stats.team_damage_given, "team_kills": player.stats.team_kills, "self_kills": player.stats.self_kills, "xp": player.stats.xp, "playtime": player.stats.play_time_ratio, "smg_kills": 0, "knife_kills": 0, "pistol_kills": 0, "rifle_kills": 0, "spam_kills": 0, "smg_deaths": 0, "knife_deaths": 0, "pistol_deaths": 0, "rifle_deaths": 0, "spam_deaths": 0, "syringe_hits": 0, "syringe_shots": 0, "dmg_per_frag": [], "roundcount" : 1, "display_name" : set_display, "alias" : player.name } # update a current players dictionary values else: players_totals[player_key]["team_name"] = player.team.name[5:] players_totals[player_key]["total_kills"] += player.stats.total_kills players_totals[player_key]["efficiency"] += player.stats.efficiency players_totals[player_key]["gibs"] += player.stats.gibs players_totals[player_key]["total_deaths"] += player.stats.total_deaths players_totals[player_key]["damage_given"] += player.stats.damage_given players_totals[player_key]["damage_received"] += player.stats.damage_received players_totals[player_key]["team_damage_given"] += player.stats.team_damage_given players_totals[player_key]["team_kills"] += player.stats.team_kills players_totals[player_key]["self_kills"] += player.stats.self_kills players_totals[player_key]["xp"] += player.stats.xp players_totals[player_key]["playtime"] += player.stats.play_time_ratio players_totals[player_key]["dmg_per_frag"].append(player.stats.damage_given / player.stats.total_kills if player.stats.total_kills else 0) players_totals[player_key]["roundcount"] = players_totals[player_key]["roundcount"] + 1 players_totals[player_key]["alias"] = player.name # determine number of smg and splash kills per player for Lead Poisoning and Spam awards for weapon in player.stats.weapons: if webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "Thompson": players_totals[player_key]["smg_kills"] += weapon.kills players_totals[player_key]["smg_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "MP 40": players_totals[player_key]["smg_kills"] += weapon.kills players_totals[player_key]["smg_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "Knife": players_totals[player_key]["knife_kills"] += weapon.kills players_totals[player_key]["knife_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "Luger": players_totals[player_key]["pistol_kills"] += weapon.kills players_totals[player_key]["pistol_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "Colt": players_totals[player_key]["pistol_kills"] += weapon.kills players_totals[player_key]["pistol_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "Scp.Garand": players_totals[player_key]["rifle_kills"] += weapon.kills players_totals[player_key]["rifle_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "Scp.K43": players_totals[player_key]["rifle_kills"] += weapon.kills players_totals[player_key]["rifle_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "Grenade": players_totals[player_key]["spam_kills"] += weapon.kills players_totals[player_key]["spam_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "G.Launchr": players_totals[player_key]["spam_kills"] += weapon.kills players_totals[player_key]["spam_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "Artillery": players_totals[player_key]["spam_kills"] += weapon.kills players_totals[player_key]["spam_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "Airstrike": players_totals[player_key]["spam_kills"] += weapon.kills players_totals[player_key]["spam_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "Landmine": players_totals[player_key]["spam_kills"] += weapon.kills players_totals[player_key]["spam_deaths"] += weapon.deaths elif webstats_utils.weapon_stats[weapon.weapon_id]["name"] == "Syringe": players_totals[player_key]["syringe_hits"] += weapon.hits players_totals[player_key]["syringe_shots"] += weapon.shots # Update scores if game.winner.name[5:] == get_current_team(game, team1_players): team1_score += 1 else: team2_score += 1 '''# Update scores if round1_fullhold: team2_score += 1 # AXIS (team2) gets 1 point for fullhold in round 1 if round2_fullhold: team1_score += 1 # ALLIES (team1) gets 1 point for fullhold in round 2 if allies_beat_time: team1_score += 2 # ALLIES (team1) gets 2 points if they beat the time set in round 1''' # Update scores '''if roundcount == 1: # If there's no round 2 if round1_fullhold: if defending_team1 == get_current_team(game, team1_players): team1_score += 1 else: team2_score += 1 else: # If there is a round 2 if round1_fullhold: if defending_team1 == get_current_team(game, team1_players): team1_score += 1 else: team2_score += 1 if round2_fullhold: if defending_team2 == get_current_team(game, team1_players): team1_score += 1 else: team2_score += 1 if game.winner.name[5:] != game.defender.name[5:] and game.nextTimelimit < game.timelimit: if game.winner.name[5:] == get_current_team(game, team1_players): team1_score += 1 else: team2_score += 1''' # handle reset of round 1 dictionary data for next map processing current_round += 1 if current_round > 2: current_round = 1 map_round1_stats.clear() return players_totals, team1_score, team2_score def get_awards(dir_path, roundlist, team1, team2): totals = get_match_totals(dir_path, roundlist, team1, team2) players_totals = totals[0] # dictionary for match awards as found on gamestv.org awards = { "Lady Macbeth": {"player": "", "value": 0 , "description": ""}, "Accountant": {"player": "", "value": 0, "description": ""}, #"Killing Spree": {"player": "", "value": 0, "description": ""}, "He's dead, Jim!": {"player": "", "value": 0, "description": ""}, "...and stay dead!": {"player": "", "value": 0, "description": ""}, "Lead Poisoning": {"player": "", "value": 0, "description": ""}, "Spammity spam spam!": {"player": "", "value": 0, "description": ""}, "Fragstealer": {"player": "", "value": float('inf'), "description": ""}, "Die! Damn you, Die!": {"player": "", "value": 0, "description": ""}, "Red Shirt": {"player": "", "value": 0, "description": ""}, "What Objective?": {"player": "", "value": 0, "description": ""}, "Med Pack Whore": {"player": "", "value": 0, "description": ""}, "Eyes Wide Shut": {"player": "", "value": 0, "description": ""}, "Gingerbread Man": {"player": "", "value": 0, "description": ""}, "Dr. Fauci": {"player": "", "value": 0, "description": ""}, "What Spawn?": {"player": "", "value": 0, "description": ""}, "Out Full King": {"player": "", "value": 0, "description": ""} } # process the awards based on the aggregated data for player_key, player_data in players_totals.items(): # Lady Macbeth if player_data["total_kills"] > awards["Lady Macbeth"]["value"]: awards["Lady Macbeth"]["player"] = player_data["alias"] awards["Lady Macbeth"]["value"] = player_data["total_kills"] awards["Lady Macbeth"]["description"] = " kills" # Accountant kills_killed_ratio = round(player_data["efficiency"] / player_data["roundcount"] if player_data["roundcount"] else 0) if kills_killed_ratio > awards["Accountant"]["value"]: awards["Accountant"]["player"] = player_data["alias"] awards["Accountant"]["value"] = kills_killed_ratio awards["Accountant"]["description"] = "% kills/killed ratio" # Killing Spree #if player_data["longest_killing_spree"] > awards["Killing Spree"]["value"]: #awards["Killing Spree"]["player"] = player_name #awards["Killing Spree"]["value"] = player_data["longest_killing_spree"] #awards["Killing Spree"]["description"] = " frags without being killed" # He's dead, Jim! if player_data["gibs"] > awards["He's dead, Jim!"]["value"]: awards["He's dead, Jim!"]["player"] = player_data["alias"] awards["He's dead, Jim!"]["value"] = player_data["gibs"] awards["He's dead, Jim!"]["description"] = " gibs" # and stay dead... gibs_killed_ratio = round(player_data["gibs"] / player_data["total_kills"] * 100) if player_data["total_kills"] else 0 if gibs_killed_ratio > awards["...and stay dead!"]["value"]: awards["...and stay dead!"]["player"] = player_data["alias"] awards["...and stay dead!"]["value"] = gibs_killed_ratio awards["...and stay dead!"]["description"] = "% gibs/killed ratio" # Lead Poisoning smg_kills = player_data["smg_kills"] if smg_kills > awards["Lead Poisoning"]["value"]: awards["Lead Poisoning"]["player"] = player_data["alias"] awards["Lead Poisoning"]["value"] = smg_kills awards["Lead Poisoning"]["description"] = " SMG kills" # Spammity spam spam! spam_kills = player_data["spam_kills"] if spam_kills > awards["Spammity spam spam!"]["value"]: awards["Spammity spam spam!"]["player"] = player_data["alias"] awards["Spammity spam spam!"]["value"] = spam_kills awards["Spammity spam spam!"]["description"] = " SPAM kills" # Fragstealer total_damage_given = sum(player_data['dmg_per_frag']) roundcount = len(player_data['dmg_per_frag']) if roundcount > 0: avg_damage = round(total_damage_given / roundcount) if avg_damage < awards["Fragstealer"]["value"]: awards["Fragstealer"]["player"] = player_data["alias"] awards["Fragstealer"]["value"] = avg_damage awards["Fragstealer"]["description"] = " damage per frag" # Die! Damn you, Die! max_dmg_per_frag = round(player_data["damage_given"]/player_data["total_kills"]) if player_data["total_kills"] else 0 if max_dmg_per_frag > awards["Die! Damn you, Die!"]["value"]: awards["Die! Damn you, Die!"]["player"] = player_data["alias"] awards["Die! Damn you, Die!"]["value"] = max_dmg_per_frag awards["Die! Damn you, Die!"]["description"] = " damage per frag" # What Objective? if player_data["xp"] > awards["What Objective?"]["value"]: awards["What Objective?"]["player"] = player_data["alias"] awards["What Objective?"]["value"] = player_data["xp"] awards["What Objective?"]["description"] = " XP" # Red Shirt if player_data["total_deaths"] > awards["Red Shirt"]["value"]: awards["Red Shirt"]["player"] = player_data["alias"] awards["Red Shirt"]["value"] = player_data["total_deaths"] awards["Red Shirt"]["description"] = " deaths" # Med Pack Whore damage_per_death = round(player_data["damage_given"] / player_data["total_deaths"]) if player_data["total_deaths"] else 0 if damage_per_death > awards["Med Pack Whore"]["value"]: awards["Med Pack Whore"]["player"] = player_data["alias"] awards["Med Pack Whore"]["value"] = damage_per_death awards["Med Pack Whore"]["description"] = " damage per death" # Eyes Wide Shut if player_data["team_kills"] > awards["Eyes Wide Shut"]["value"]: awards["Eyes Wide Shut"]["player"] = player_data["alias"] awards["Eyes Wide Shut"]["value"] = player_data["team_kills"] awards["Eyes Wide Shut"]["description"] = " team kills..." # Gingerbread Man if player_data["self_kills"] > awards["Gingerbread Man"]["value"]: awards["Gingerbread Man"]["player"] = player_data["alias"] awards["Gingerbread Man"]["value"] = player_data["self_kills"] awards["Gingerbread Man"]["description"] = " /kills" # Dr. Fauci if player_data["syringe_hits"] > awards["Dr. Fauci"]["value"]: awards["Dr. Fauci"]["player"] = player_data["alias"] awards["Dr. Fauci"]["value"] = player_data["syringe_hits"] awards["Dr. Fauci"]["description"] = " syringe revives" # What Spawn? if roundcount > 0: avg_playtime = round(player_data['playtime'] / player_data['roundcount'], 1) if avg_playtime > awards["What Spawn?"]["value"]: awards["What Spawn?"]["player"] = player_data["alias"] awards["What Spawn?"]["value"] = avg_playtime awards["What Spawn?"]["description"] = "% time played" # Out Full King if roundcount > 0: avg_deadtime = round(100 - (player_data['playtime'] / player_data['roundcount']), 1) if avg_deadtime > awards["Out Full King"]["value"]: awards["Out Full King"]["player"] = player_data["alias"] awards["Out Full King"]["value"] = avg_deadtime awards["Out Full King"]["description"] = "% time dead" return awards def sort_by_xp(players): return players.stats.xp def get_game(arg1,arg2): filename = os.path.join(os.path.curdir, arg1, arg2) game = Game() id = 0 with open(filename) as file: header = file.readline().split('\\') game.set(header[0], header[1], header[2], header[3], int(header[4]), int(header[5]), header[6], header[7], header[8]) for line in file: arg = iter(webstats_utils.Arg()) lines = line.strip().split('\\') guid = lines[0] #name = webstats_utils.strip_color_codes(lines[1]) name = etcolor(lines[1]) rounds = lines[2] team = int(lines[3]) stats = lines[4].split(' ') player = Player(id, guid, name, rounds, team) game.players.append(player) id += 1 for k, v in webstats_utils.weapon_stats.items(): if int(stats[0]) & (1 << k): weapon = Weapon(k) player.stats.weapons.append(weapon) weapon.hits = int(stats[next(arg)]) weapon.shots = int(stats[next(arg)]) weapon.kills = int(stats[next(arg)]) weapon.deaths = int(stats[next(arg)]) weapon.headshots = int(stats[next(arg)]) weapon.acc = (weapon.hits * 100) / weapon.shots if weapon.shots > 0 else 0.0; if v["has_headshots"]: player.stats.total_shots += weapon.shots player.stats.total_hits += weapon.hits player.stats.total_headshots += weapon.headshots; player.stats.total_kills += weapon.kills; player.stats.total_deaths += weapon.deaths; player.stats.has_stats = True if player.stats.has_stats: player.stats.damage_given = int(stats[next(arg)]) player.stats.damage_received = int(stats[next(arg)]) player.stats.team_damage_given = int(stats[next(arg)]) player.stats.team_damage_received = int(stats[next(arg)]) player.stats.gibs = int(stats[next(arg)]) player.stats.self_kills = int(stats[next(arg)]) player.stats.team_kills = int(stats[next(arg)]) player.stats.team_gibs = int(stats[next(arg)]) player.stats.play_time_ratio = float(stats[next(arg)]) player.stats.xp = int(stats[next(arg)]) player.stats.efficiency = 0 if (player.stats.total_deaths + player.stats.total_kills == 0) else int(100 * player.stats.total_kills / (player.stats.total_deaths + player.stats.total_kills)) player.stats.hit_ratio = 0 if (player.stats.total_shots == 0) else (player.stats.total_hits * 100.0 / player.stats.total_shots) player.stats.headshot_ratio = 0 if (player.stats.total_hits == 0) else (player.stats.total_headshots * 100.0 / player.stats.total_hits) game.teams[player.team.value].stats.total_kills += player.stats.total_kills game.teams[player.team.value].stats.total_deaths += player.stats.total_deaths game.teams[player.team.value].stats.total_gibs += player.stats.gibs game.teams[player.team.value].stats.total_self_kills += player.stats.self_kills game.teams[player.team.value].stats.total_team_kills += player.stats.team_kills game.teams[player.team.value].stats.total_team_gibs += player.stats.team_gibs game.teams[player.team.value].stats.total_damage_given += player.stats.damage_given game.teams[player.team.value].stats.total_damage_received += player.stats.damage_received game.teams[player.team.value].stats.total_team_damage_given += player.stats.team_damage_given game.teams[player.team.value].stats.total_team_damage_received += player.stats.team_damage_received game.teams[player.team.value].stats.total_play_time += player.stats.play_time_ratio game.teams[player.team.value].stats.total_xp += player.stats.xp game.teams[player.team.value].stats.total_efficiency = 0 if (game.teams[player.team.value].stats.total_deaths + game.teams[player.team.value].stats.total_kills == 0) else int(100 * game.teams[player.team.value].stats.total_kills / (game.teams[player.team.value].stats.total_deaths + game.teams[player.team.value].stats.total_kills)) return game def get_game_stats(arg1,arg2): game = get_game(arg1,arg2) game.players.sort(key = sort_by_xp, reverse = True) gamestats = [] #stats = "\n\t\t\t\t\t\n" #stats += "\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\n\t\t\t\t\t
Round:
{}
\n".format(game.round) stats = "\n\t\t\t\t\t\n" #stats += "\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\n" stats += "\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\n" #stats += "\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t
Config:Defender:Winner:Timelimit:NextTimelimit:
Round:Winner:Time Limit:Next Time:
{}{}{}{}{}
\n\n".format(game.config, game.defender.name[5:], game.winner.name[5:], game.timelimit, game.nextTimelimit.strip()) stats += "\t\t\t\t\t\t\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t\t{}\n\t\t\t\t\t\t\n\t\t\t\t\t\n\n".format(game.round, game.winner.name[5:], game.timelimit, game.nextTimelimit.strip()) stats += "\n\t\t\t\t\t
\n\t\t\t\t\t\t\n" stats += "\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n" for team in game.teams[1:]: for player in game.players: if player.team == team.team and player.stats.has_stats: stats += "\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n".format( player.team.name[5:], player.name, player.stats.total_kills, player.stats.total_deaths, player.stats.gibs, player.stats.self_kills, player.stats.team_kills, player.stats.team_gibs, player.stats.efficiency, player.stats.damage_given, player.stats.damage_received, player.stats.team_damage_given, player.stats.team_damage_received, player.stats.xp) stats += "\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t".format( team.team.name[5:], team.stats.total_kills, team.stats.total_deaths, team.stats.total_gibs, team.stats.total_self_kills, team.stats.total_team_kills, team.stats.total_team_gibs, team.stats.total_efficiency, team.stats.total_damage_given, team.stats.total_damage_received, team.stats.total_team_damage_given, team.stats.total_team_damage_received, team.stats.total_xp) gamestats.append(stats) stats = "" stats += "\n\t\t\t\t\t
TeamPlayerKllDthGibSKTKTGEffDGDRTDGTDRScore
{}{}{}{}{}{}{}{}{}{}{}{}{}{}
{}Totals{}{}{}{}{}{}{}{}{}{}{}{}
\n\t\t\t\t
\n" gamestats.append(stats) return gamestats def get_player_stats(arg1,arg2,player): game = get_game(arg1,arg2) game.players.sort(key = sort_by_xp, reverse = True) index = int(player) if len(game.players) > index and index >= 0: for player in game.players: if player.id == index and player.stats.has_stats: stats = "\n\t\t\t\t\t
\n\n\t\t\t\t\t\t\n" stats += "\t\t\t\t\t\t\t\n".format(player.name, player.team.name[5:], player.rounds) stats += "\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n" for weapon in player.stats.weapons: stats += "\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n".format( webstats_utils.weapon_stats[weapon.weapon_id]["name"], weapon.acc, "{}/{}".format(weapon.hits, weapon.shots), weapon.kills, weapon.deaths, weapon.headshots) stats += "\t\t\t\t\t\t
Name: {} Team: {} Round: {}
WeaponAcrcyHits/ShtsKillsDeathsHeadshots
{}{:<7.1f}{}{}{}{}
\n" stats += "\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n".format(player.stats.damage_given, player.stats.team_damage_given) stats += "\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t
Damage Given:{}Team Damage Given:{}
Damage Recvd:{}Team Damage Recvd:{}
\n".format(player.stats.damage_received, player.stats.team_damage_received) stats += "\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n".format(player.stats.total_kills, player.stats.team_kills, "{0:0.1f}%".format(player.stats.hit_ratio)) stats += "\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n".format(player.stats.total_deaths, player.stats.self_kills, "{0:0.1f}%".format(player.stats.headshot_ratio)) stats += "\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n".format(player.stats.gibs, player.stats.team_gibs, "{0:0.1f}%".format(float(player.stats.play_time_ratio))) stats += "\n\t\t\t\t\t\t
Kills:{}Team Kills:{}Accuracy:{}
Deaths:{}Self Kills:{}Headshots:{}
Gibs:{}Team Gibs:{}Playtime:{}
\n\t\t\t\t\t
\n" return stats else: return "Bad argument" return "No stats for given player"