Implemeting suggestions from reddit. Fixes #20
This commit is contained in:
parent
9495640c8d
commit
fcbd4cd985
73
app/quake.py
73
app/quake.py
@ -103,15 +103,17 @@ def get_favorite_champion(blob):
|
||||
for game_mode in blob['playerProfileStats']['champions'][champion]['gameModes']:
|
||||
if champion in play_times:
|
||||
play_times[champion] += blob['playerProfileStats']['champions'][champion]['gameModes'][game_mode]['timePlayed']
|
||||
play_times[champion] += blob['playerProfileStats']['champions'][champion]['gameModes'][game_mode]['rankedTimePlayed']
|
||||
else:
|
||||
play_times[champion] = blob['playerProfileStats']['champions'][champion]['gameModes'][game_mode]['timePlayed']
|
||||
play_times[champion] = blob['playerProfileStats']['champions'][champion]['gameModes'][game_mode]['rankedTimePlayed']
|
||||
|
||||
champion_play_time = max(play_times.values()) # maximum value
|
||||
champion_name = [k for k, v in play_times.items() if v == champion_play_time][0] # getting all keys containing the `maximum`
|
||||
|
||||
# Convert play_time from miliseconds to hours
|
||||
champion_play_time = round(float(champion_play_time)/(1000*60*60), 2)
|
||||
return(champion_name, champion_play_time)
|
||||
return(prettify(champion_name), champion_play_time)
|
||||
|
||||
|
||||
def get_favorite_weapon(blob):
|
||||
@ -135,7 +137,7 @@ def get_favorite_weapon(blob):
|
||||
total_kills = max(weapon_stats.values()) # maximum value
|
||||
weapon_name = [k for k, v in weapon_stats.items() if v == total_kills][0] # getting all keys containing the `maximum`
|
||||
|
||||
return(weapon_name, total_kills)
|
||||
return(prettify(weapon_name), total_kills)
|
||||
|
||||
|
||||
def get_kd(blob):
|
||||
@ -182,13 +184,76 @@ def get_match_stats(blob, target_player):
|
||||
|
||||
kill_death_ratio = round(float(match_data['battleReportPersonalStatistics'][0]['kills']) / match_data['battleReportPersonalStatistics'][0]['deaths'], 2)
|
||||
|
||||
return_blob = "Final score: {}\nK/D: {}\nFavorite Weapon {} | {}% Accuracy\nXP Eaned: {} | Favor Earned: {}".format(
|
||||
return_blob = "Final score: {}\nK/D: {}\nFavorite Weapon: {} | {}% Accuracy\nXP Earned: {} | Favor Earned: {}".format(
|
||||
match_data['teamScores'],
|
||||
kill_death_ratio,
|
||||
fav_weapon,
|
||||
prettify(fav_weapon),
|
||||
accuracy,
|
||||
earnedXp,
|
||||
earnedFavor,
|
||||
)
|
||||
|
||||
return return_blob
|
||||
|
||||
|
||||
def prettify(name):
|
||||
"""
|
||||
prettify(name)
|
||||
|
||||
Takes in an items name and returns a cleaned up / readable version
|
||||
"""
|
||||
|
||||
item_map = {
|
||||
'UNKNOWN_DAMAGE_TYPE' : 'Unknown Damage Type',
|
||||
'GAUNTLET' : 'Gauntlet',
|
||||
'MACHINEGUN' : 'Machinegun',
|
||||
'MACHINEGUN_GRADE1' : 'Heavy Machinegun',
|
||||
'SHOTGUN' : 'Basic Shotgun',
|
||||
'SHOTGUN_GRADE1' : 'Super Shotgun',
|
||||
'NAILGUN' : 'Nailgun',
|
||||
'NAILGUN_GRADE1' : 'Super Nailgun',
|
||||
'ROCKET_LAUNCHER' : 'Rocket Launcher',
|
||||
'LIGHTNING_GUN' : 'Lightning Gun',
|
||||
'RAILGUN' : 'Railgun',
|
||||
'LAGBOLT' : 'TriBolt',
|
||||
'ACID_DOMAIN' : 'Environmental Acid Death',
|
||||
'DAMAGE_DOMAIN' : 'Environmental Damage Death',
|
||||
'KILL_DOMAIN' : 'Environmental Kill Death',
|
||||
'DIRE_ORB' : 'Dire Orb',
|
||||
'DIRE_ORB_EXPLOSION' : 'Dire Orb Explosion',
|
||||
'DIRE_ORB_TELEFRAG' : 'Dire Orb Telefrag',
|
||||
'UNHOLY' : 'Galena\'s Totem',
|
||||
'TELEFRAG' : 'Telefrag',
|
||||
'FALL_DAMAGE' : 'Fall Damage',
|
||||
'PLASMA_TRAIL' : 'Slash\'s Plasma Trail',
|
||||
'PLASMA_TRAIL_EXPLOSION' : 'Slash\'s Plasma Trail Explosion',
|
||||
'MINING_LASER' : 'Mining Laser',
|
||||
'ABILITY_BERSERK' : 'Doom Slayer\'s Berserk Mode',
|
||||
'SWARM_GRENADE' : 'Swarm Grenade',
|
||||
'SB_DASH' : 'Scalbarer\'s Rush',
|
||||
'SB_STOMP' : 'Scalbarer\'s Stomp',
|
||||
'ACID_SPIT_DIRECT' : 'Acid Spit Direct',
|
||||
'VENDETTA_TELEFRAG' : 'Vendetta Telefrag',
|
||||
'ACID_DOT' : 'Sorlag\'s Acid DOT',
|
||||
'FLAME_DOT' : 'Flame DOTt',
|
||||
'FLAME' : 'Flame',
|
||||
'ACID' : 'Acid',
|
||||
'DRONE_KAMIKAZE_EXPLOSION' : 'Drone Kamikaze Explosion',
|
||||
'RECON_DRONE' : 'Recon Drone',
|
||||
'RECON_DRONE_EXPLOSION' : 'Recon Drone Explosion',
|
||||
'ANARKI': 'Anarki',
|
||||
'BJ_BLAZKOWICZ': 'BJ Blazkowicz',
|
||||
'CLUTCH': 'Clutch',
|
||||
'DOOM_SLAYER': 'Doom Slayer',
|
||||
'GALENA': 'Galena',
|
||||
'KEEL': 'Keel',
|
||||
'NYX': 'Nyx',
|
||||
'RANGER': 'Ranger',
|
||||
'SCALEBEARER': 'Scalebearer',
|
||||
'SLASH': 'Slash',
|
||||
'SORLAG': 'Sorlag',
|
||||
'STROGG': 'Strogg',
|
||||
'VISOR': 'Visor',
|
||||
}
|
||||
|
||||
return item_map[name]
|
Loading…
x
Reference in New Issue
Block a user