]> de.git.xonotic.org Git - xonotic/xonstat.git/commitdiff
Show the best flag capture times on the game info page.
authorAnt Zucaro <azucaro@gmail.com>
Fri, 2 Nov 2012 01:59:21 +0000 (21:59 -0400)
committerJan Behrens <zykure@web.de>
Sun, 23 Dec 2012 14:18:33 +0000 (15:18 +0100)
The best flag capture time for each player is shown in the game
info page now. This only happens for CTF. The format shown is
seconds.milliseconds, with up to two decimal places shown.

xonstat/templates/game_info.mako
xonstat/views/game.py

index 141f3a9c65826cd435ff4068094a5f3e42b22fe3..0e3a383ba9c8eb1aa0030bc272cce393e05219ef 100644 (file)
@@ -46,6 +46,40 @@ Game Information
   </div>
 </div>
 
+% if len(captimes) > 0:
+<div class="row">
+  <div class="span6">
+    <h3>Best Flag Capture Times</h3>
+    <table class="table table-bordered table-condensed">
+      <thead>
+        <tr>
+           <th>Nick</th>
+           <th>Captime</th>
+        </tr>
+      </thead>
+      <tbody>
+      % for pgs in captimes:
+        <tr>
+          <td>
+          % if pgs.player_id > 2:
+            <a href="${request.route_url("player_info", id=pgs.player_id)}"
+             title="Go to the info page for this player">
+            <span class="nick">${pgs.nick_html_colors()|n}</span>
+            </a>
+          % else:
+            <span class="nick">${pgs.nick_html_colors()|n}</span>
+          % endif
+          </td>
+          <td>${round(float(pgs.fastest_cap.seconds) + (pgs.fastest_cap.microseconds/1000000.0), 2)}</td>
+        </tr>
+      % endfor
+      </tbody>
+    </table>
+  </div>
+</div>
+% endif
+
+
 % if len(pgstats) > 0:
 <div class="row">
   <div class="span12">
index 04774fe283c6e87c40c1c03cec571e924c60bf4a..2e088b8616282f28ff47bfcc1f5c614e6341d0ec 100644 (file)
@@ -69,12 +69,13 @@ def _game_info_data(request):
                 order_by(PlayerGameStat.score).\
                 all()
 
-        # mako is an absolute bastard when dealing with decimals, so...
-        for pgstat in pgstats:
-            try:
-                pgstat.elo_delta = "{0:+4.2f}".format(float(pgstat.elo_delta))
-            except:
-                pgstat.elo_delta = "0.00"
+        captimes = []
+        if game.game_type_cd == 'ctf':
+            for pgstat in pgstats:
+                if pgstat.fastest_cap is not None:
+                    captimes.append(pgstat)
+
+            captimes = sorted(captimes, key=lambda x:x.fastest_cap)
 
         pwstats = {}
         for (pwstat, pgstat, weapon) in DBSession.query(PlayerWeaponStat, PlayerGameStat, Weapon).\
@@ -102,6 +103,7 @@ def _game_info_data(request):
         map = None
         pgstats = None
         pwstats = None
+        captimes = None
         raise inst
 
     return {'game':game,
@@ -109,6 +111,7 @@ def _game_info_data(request):
             'map':map,
             'pgstats':pgstats,
             'pwstats':pwstats,
+            'captimes':captimes,
             }