]> git.rm.cloudns.org Git - xonotic/xonstat.git/commitdiff
Clean up the accuracy tables, make them mobile friendly.
authorAnt Zucaro <azucaro@gmail.com>
Sun, 12 Apr 2015 13:05:56 +0000 (09:05 -0400)
committerAnt Zucaro <azucaro@gmail.com>
Sun, 12 Apr 2015 13:05:56 +0000 (09:05 -0400)
xonstat/templates/accuracy.mako
xonstat/templates/game_info.mako
xonstat/views/game.py

index de8f084cdc3a722da99edb899ce698ffae02611f..3eea2cdd30b2c8e19c894582985db7d50f691f23 100644 (file)
 ## [3] = Max damage
 ## [4] = Hit
 ## [5] = Fired
+## [6] = Frags
 
-<table class="table table-condensed">
-<thead>
+<table class="table-hover table-condensed">
+  <thead>
     <th></th>
-    <th>Weapon</th>
-    <th>Hit</th>
-    <th>Fired</th>
-    <th>Hit %</th>
-    <th>Actual Damage</th>
-    <th>Potential Damage</th>
-    <th>Damage %</th>
-</thead>
-% 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
-%>
-<tr>
-    ## Note: the name of the image must match up with the weapon_cd 
-    ## entry of that weapon, else this won't work
-    <td><span class="sprite sprite-${weapon_stat[1]}"></span></td>
-    <td>${weapon_stat[0]}</td>
-    <td>${weapon_stat[4]}</td>
-    <td>${weapon_stat[5]}</td>
-    <td>${hit_pct}%</td>
-    <td>${weapon_stat[2]}</td>
-    <td>${weapon_stat[3]}</td>
-    <td>${damage_pct}%</td>
-</tr>
-% endfor
+    <th class="show-for-medium-up">Weapon</th>
+    <th class="show-for-medium-up">Frags</th>
+    <th>Accuracy</th>
+    <th>Damage</th>
+  </thead>
+
+  <%
+    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
+    %>
+    <tr>
+      ## Note: the name of the image must match up with the weapon_cd 
+      ## entry of that weapon, else this won't work
+      <td><span class="sprite sprite-${weapon_stat[1]}"></span></td>
+      <td class="show-for-medium-up">${weapon_stat[0]}</td>
+      <td class="show-for-medium-up">${weapon_stat[6]}</td>
+      <td>${weapon_stat[4]}/${weapon_stat[5]} (${hit_pct}%)</td>
+      <td>${weapon_stat[2]} (${round(float(weapon_stat[2])/total_damage*100, 2)}%)</td>
+    </tr>
+  % endfor
 </table>
 </%def>
index 786e521d165c97d1876446fab4c4705c9e7cc5cc..38448855b5a5ecf48428c638bec1d4872eaf0350 100644 (file)
 
   % if len(pgstats) > 0 and len(pwstats) > 0:
     <div class="row">
-      <div class="small-12 columns">
+      <div class="small-12 medium-9 columns">
           <ul class="accordion" data-accordion>
             % for pgstat in pgstats:
               % if pgstat.player_game_stat_id in pwstats:
index b21497cc65531f4e1426ce02c865b18c58bbfb29..79920c51e606e377e625abdd1ebe8ba634be4c8d 100644 (file)
@@ -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