From bc9db55bb97db6e69b76a4e3745b46b03fa2b4e7 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Sun, 12 Apr 2015 09:05:56 -0400 Subject: [PATCH] Clean up the accuracy tables, make them mobile friendly. --- xonstat/templates/accuracy.mako | 73 +++++++++++++++++--------------- xonstat/templates/game_info.mako | 2 +- xonstat/views/game.py | 2 +- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/xonstat/templates/accuracy.mako b/xonstat/templates/accuracy.mako index de8f084..3eea2cd 100644 --- a/xonstat/templates/accuracy.mako +++ b/xonstat/templates/accuracy.mako @@ -10,41 +10,46 @@ ## [3] = Max damage ## [4] = Hit ## [5] = Fired +## [6] = Frags - - +
+ - - - - - - - - -% for weapon_stat in weapon_stats: -<% -if weapon_stat[3] > 0: - damage_pct = round(float(weapon_stat[2])/weapon_stat[3]*100, 2) -else: - damage_pct = 0 -if weapon_stat[5] > 0: - hit_pct = round(float(weapon_stat[4])/weapon_stat[5]*100, 2) -else: - hit_pct = 0 -%> - - ## Note: the name of the image must match up with the weapon_cd - ## entry of that weapon, else this won't work - - - - - - - - - -% endfor + + + + + + + <% + total_damage = 0 + for weapon_stat in weapon_stats: + total_damage += weapon_stat[2] + if total_damage == 0: + total_damage = 1 + %> + + % for weapon_stat in weapon_stats: + <% + if weapon_stat[3] > 0: + damage_pct = round(float(weapon_stat[2])/weapon_stat[3]*100, 2) + else: + damage_pct = 0 + + if weapon_stat[5] > 0: + hit_pct = round(float(weapon_stat[4])/weapon_stat[5]*100, 2) + else: + hit_pct = 0 + %> + + ## Note: the name of the image must match up with the weapon_cd + ## entry of that weapon, else this won't work + + + + + + + % endfor
WeaponHitFiredHit %Actual DamagePotential DamageDamage %
${weapon_stat[0]}${weapon_stat[4]}${weapon_stat[5]}${hit_pct}%${weapon_stat[2]}${weapon_stat[3]}${damage_pct}%
WeaponFragsAccuracyDamage
${weapon_stat[0]}${weapon_stat[6]}${weapon_stat[4]}/${weapon_stat[5]} (${hit_pct}%)${weapon_stat[2]} (${round(float(weapon_stat[2])/total_damage*100, 2)}%)
diff --git a/xonstat/templates/game_info.mako b/xonstat/templates/game_info.mako index 786e521..3844885 100644 --- a/xonstat/templates/game_info.mako +++ b/xonstat/templates/game_info.mako @@ -136,7 +136,7 @@ % if len(pgstats) > 0 and len(pwstats) > 0:
-
+
    % for pgstat in pgstats: % if pgstat.player_game_stat_id in pwstats: diff --git a/xonstat/views/game.py b/xonstat/views/game.py index b21497c..79920c5 100644 --- a/xonstat/views/game.py +++ b/xonstat/views/game.py @@ -87,7 +87,7 @@ def _game_info_data(request): # template pwstats[pgstat.player_game_stat_id].append((weapon.descr, weapon.weapon_cd, pwstat.actual, pwstat.max, - pwstat.hit, pwstat.fired, pgstat)) + pwstat.hit, pwstat.fired, pwstat.frags, pgstat)) except Exception as inst: game = None -- 2.39.2