From 26979efc5818ab9a67ba91ccf6da57907bb6f2a0 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Thu, 1 Nov 2012 21:59:21 -0400 Subject: [PATCH] Show the best flag capture times on the game info page. 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 | 34 ++++++++++++++++++++++++++++++++ xonstat/views/game.py | 15 ++++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/xonstat/templates/game_info.mako b/xonstat/templates/game_info.mako index 141f3a9..0e3a383 100644 --- a/xonstat/templates/game_info.mako +++ b/xonstat/templates/game_info.mako @@ -46,6 +46,40 @@ Game Information +% if len(captimes) > 0: +
+
+

Best Flag Capture Times

+ + + + + + + + + % for pgs in captimes: + + + + + % endfor + +
NickCaptime
+ % if pgs.player_id > 2: + + ${pgs.nick_html_colors()|n} + + % else: + ${pgs.nick_html_colors()|n} + % endif + ${round(float(pgs.fastest_cap.seconds) + (pgs.fastest_cap.microseconds/1000000.0), 2)}
+
+
+% endif + + % if len(pgstats) > 0:
diff --git a/xonstat/views/game.py b/xonstat/views/game.py index 04774fe..2e088b8 100644 --- a/xonstat/views/game.py +++ b/xonstat/views/game.py @@ -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, } -- 2.39.2