From 048c2048e7e64bc0d0f51e60c42064161f626b1c Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Tue, 24 May 2011 22:43:47 -0400 Subject: [PATCH] Remove redundant code for scoreboard display, add proper percentages to the accuracy page. --- xonstat/templates/game_index.mako | 132 +-------------------- xonstat/templates/game_info.mako | 65 +--------- xonstat/templates/player_weapon_stats.mako | 3 +- xonstat/templates/scoreboard.mako | 2 +- 4 files changed, 8 insertions(+), 194 deletions(-) diff --git a/xonstat/templates/game_index.mako b/xonstat/templates/game_index.mako index e19a2fb..1563872 100755 --- a/xonstat/templates/game_index.mako +++ b/xonstat/templates/game_index.mako @@ -1,4 +1,5 @@ <%inherit file="base.mako"/> +<%namespace file="scoreboard.mako" import="scoreboard" /> <%block name="title"> Game Index - ${parent.title()} @@ -12,137 +13,10 @@ Game Index - ${parent.title()} % for (game, server, map) in games:

${map.name} on ${server.name} (permalink for this game) - -############################ CTF Game ############################ -% if game.game_type_cd == 'ctf': - - - - - - - - - - - +## show scoreboard using a def from another file +${scoreboard(game.game_type_cd, pgstats[game.game_id])} -% for pgstat in pgstats[game.game_id]: - - - - - - - - - - - -% endfor -% endif - - -############################ DM Game ############################ -% if game.game_type_cd == 'dm': - - - - - - - - - -% for pgstat in pgstats[game.game_id]: - - - - - - - - -% endfor -% endif - - -############################ TDM Game ############################ -% if game.game_type_cd == 'tdm': - - - - - - - - - - -% for pgstat in pgstats[game.game_id]: - - - - - - - - - -% endfor -% endif - -############################ End gametype specific stuff ############################ -
NickTeamKillsCapturesPickupsFlag Carrier KillsReturnsScoreAccuracy
- % if pgstat.player_id > 2: - - ${pgstat.nick_html_colors()} - - % else: - ${pgstat.nick_html_colors()} - % endif - ${pgstat.kills}${pgstat.captures}${pgstat.pickups}${pgstat.carrier_frags}${pgstat.returns}${pgstat.score} - % if pgstat.player_id > 1: - - View - - % endif -
NickKillsDeathsSuicidesScoreAccuracy
- % if pgstat.player_id > 2: - - ${pgstat.nick_html_colors()} - - % else: - ${pgstat.nick_html_colors()} - % endif - ${pgstat.kills}${pgstat.deaths}${pgstat.suicides}${pgstat.score} - % if pgstat.player_id > 1: - - View - - % endif -
NickTeamKillsDeathsSuicidesScoreAccuracy
- % if pgstat.player_id > 2: - - ${pgstat.nick_html_colors()} - - % else: - ${pgstat.nick_html_colors()} - % endif - ${pgstat.kills}${pgstat.deaths}${pgstat.suicides}${pgstat.score} - % if pgstat.player_id > 1: - - View - - % endif -
% endfor % endif diff --git a/xonstat/templates/game_info.mako b/xonstat/templates/game_info.mako index 1c7d580..b479645 100644 --- a/xonstat/templates/game_info.mako +++ b/xonstat/templates/game_info.mako @@ -1,4 +1,5 @@ <%inherit file="base.mako"/> +<%namespace file="scoreboard.mako" import="scoreboard" /> <%block name="title"> Game Information - ${parent.title()} @@ -18,67 +19,5 @@ Map: -% if game_type_cd == 'ctf': - - Nick - Kills - Captures - Pickups - Flag Carrier Kills - Returns - Score - Accuracy - - -% for player_game_stat in player_game_stats: - - - % if player_game_stat.player_id > 2: - - ${player_game_stat.nick_html_colors()} - - % else: - ${player_game_stat.nick_html_colors()} - % endif - - ${player_game_stat.kills} - ${player_game_stat.captures} - ${player_game_stat.pickups} - ${player_game_stat.carrier_frags} - ${player_game_stat.returns} - ${player_game_stat.score} - - % if player_game_stat.player_id > 1: - - View - - % endif - - -% endfor -% endif - -% if game_type_cd == 'dm': - - Nick - Kills - Deaths - Suicides - Score - - -% for player_game_stat in player_game_stats: - - ${player_game_stat.nick_html_colors()} - ${player_game_stat.kills} - ${player_game_stat.deaths} - ${player_game_stat.suicides} - ${player_game_stat.score} - -% endfor -% endif - +${scoreboard(game_type_cd, player_game_stats)} % endif diff --git a/xonstat/templates/player_weapon_stats.mako b/xonstat/templates/player_weapon_stats.mako index ced0a4a..84c115d 100644 --- a/xonstat/templates/player_weapon_stats.mako +++ b/xonstat/templates/player_weapon_stats.mako @@ -28,9 +28,10 @@ Accuracy Information - ${parent.title()} ${weapon.descr} ${pwstat.fired} ${pwstat.hit} - ${pwstat.hit/pwstat.fired} + ${round(float(pwstat.hit)/pwstat.fired*100, 2)}% ${pwstat.max} ${pwstat.actual} + ${round(float(pwstat.actual)/pwstat.max*100, 2)}% ${pwstat.frags} % endfor diff --git a/xonstat/templates/scoreboard.mako b/xonstat/templates/scoreboard.mako index a9d2391..3b5518e 100644 --- a/xonstat/templates/scoreboard.mako +++ b/xonstat/templates/scoreboard.mako @@ -47,7 +47,7 @@ % endif ##### DM ##### -% if game.game_type_cd == 'dm': +% if game_type_cd == 'dm': Nick Kills -- 2.39.2