From 5b587a28982202ff27ebac784ba9320f523dd10c Mon Sep 17 00:00:00 2001 From: Jan Behrens Date: Sun, 21 Apr 2013 02:03:17 +0200 Subject: [PATCH] Playing around with teamscore display (uses random scores for testing) --- xonstat/static/css/app.min.css | 4 + xonstat/templates/game_info.mako | 2 +- xonstat/templates/scoreboard.mako | 150 ++++++++++++++++++------------ xonstat/views/game.py | 34 ++++++- 4 files changed, 127 insertions(+), 63 deletions(-) diff --git a/xonstat/static/css/app.min.css b/xonstat/static/css/app.min.css index 2168fc1..6938bc2 100644 --- a/xonstat/static/css/app.min.css +++ b/xonstat/static/css/app.min.css @@ -1 +1,5 @@ @font-face{font-family:'XoloniumNormal';src:url('fonts/xolonium-webfont.eot');src:url('fonts/xolonium-webfont.eot?#iefix') format('embedded-opentype'),url('fonts/xolonium-webfont.woff') format('woff'),url('fonts/xolonium-webfont.ttf') format('truetype'),url('fonts/xolonium-webfont.svg#XoloniumNormal') format('svg');font-weight:normal;font-style:normal}body{background:url("img/web_background_4.jpg") no-repeat fixed center center / cover black;background-color:black;color:#d0d0d0;font-family:"XoloniumNormal","Helvetica Neue",Helvetica,Arial,sans-serif}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;color:#999}h1{font-size:30px;line-height:36px}h1 small{font-size:18px}h2{font-size:24px;line-height:36px}h2 small{font-size:18px}h3{line-height:27px;font-size:18px}h3 small{font-size:14px}h4,h5,h6{line-height:18px}h4{font-size:14px}h4 small{font-size:12px}h5{font-size:12px}h6{font-size:11px;color:#999;text-transform:uppercase}table{background:#000;background:none repeat scroll 0 0 rgba(0,0,0,0.7);border:1px solid #436688}table th{border:1px solid #436688;background-color:#001021}table td{border:1px solid #436688;font-size:10px}.table-hover>tbody>tr:hover>td,.table-hover>tbody>tr:hover>th{background-color:#222}.table th,.table td{border:1px solid #436688}.table td{vertical-align:middle}.table .tdcenter{text-align:center}.accordion-group{border:1px solid #272525}.accordion-inner{border:0}#statline{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;position:relative;top:-25px}#xonborder{background:#000;background:none repeat scroll 0 0 rgba(0,0,0,0.5);border-radius:15px 15px 15px 15px;margin-bottom:30px;margin-left:0;padding:20px}#title{color:#08c;font-size:30px;margin-bottom:15px;position:relative;text-align:center;text-shadow:2px 2px 3px #333}.indexform{margin:20px 0 20px 0}.indexbox{width:250px}.navbar-brand{margin-left:0;padding-bottom:0;padding-top:10px;text-align:left}.navbar-inverse{background:none repeat scroll 0 0 rgba(0,0,0,0.6)}.navbar-inverse .nav>.active>a,.navbar-inverse .nav>.active>a:hover,.navbar-inverse .nav>.active>a:focus{background:none repeat scroll 0 0 rgba(49,49,49,0.6)}.navbar-inverse .nav>li>a,.navbar-brand{font-family:XoloniumNormal}.search,input[type="search"]{background-color:#606060;border:1px solid #202020;color:#aaa;width:100px}.game{float:left;margin-bottom:30px;min-width:700px;padding:10px 7px}.game a{color:#CCC}.game a:hover{color:#d95f00;text-decoration:none}.game tr{background-color:#000}.game tr.red{background-color:#4d0000}.game tr.blue{background-color:#00004d}.game tr.yellow{background-color:#4d4d00}.game tr.pink{background-color:#4d004d}.game tr:hover{background-color:#222}.teamscores td{background-color:#000;text-align:center;padding:4px;font-size:18px}.teamscores td.red{background-color:#4d0000}.teamscores td.blue{background-color:#00004d}.teamscores td.yellow{background-color:#4d4d00}.teamscores td.pink{background-color:#4d004d}.weapon-nav{height:70px;margin-bottom:20px}.weapon-nav ul{display:block;list-style:none outside none}.weapon-nav li{cursor:pointer;float:left;margin-right:10px}.weapon-nav li:hover{border-bottom:2px solid #001021}.weapon-nav .weapon-active{border-bottom:2px solid #436688}.weapon-nav p{text-align:center}.flot table,.flot td{background-color:black;border:0}#gbtabcontainer{margin-top:10px}#gbtab{font-size:12px}.tabbable p{font-size:14px}.tabs-below .nav-tabs>li>a{border-radius:4px 4px 4px 4px}.nav-tabs>.active>a,.nav-tabs>.active>a:hover{background-color:#111;color:#aaa;border-color:#222}.nav-tabs>li>a{border-radius:4px 4px 4px 4px;text-align:center}.nav-tabs>li>a:hover{background-color:#111;border-color:#333}.nav-tabs{border-bottom:0 solid #000}.table .tdcenter{text-align:center}.game-detail img{float:left;margin-right:10px;margin-bottom:5px}.game img{float:left;margin-right:5px;margin-bottom:5px}.game-detail p,.game h4{float:left}.eloup{color:green}.elodown{color:#be0000}.eloneutral{color:gray}.nostretch{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.pagination>li>a,.pagination>li>span{background-color:#111;border-color:#313131;color:#797979}.pagination>li>a:hover,.pagination>li>a:focus,.pagination>.active>a,.pagination>.active>span{background-color:#2b2222}@media(min-width:768px){.navbar-form{float:right}} + +.scoreboard-entry { width: 120px; max-width: 120px; overflow: hidden; } + +td.teamscore { font-size: 16px; text-align: center; } diff --git a/xonstat/templates/game_info.mako b/xonstat/templates/game_info.mako index 2de16f5..0bcd541 100644 --- a/xonstat/templates/game_info.mako +++ b/xonstat/templates/game_info.mako @@ -51,7 +51,7 @@ Game Information

Scoreboard

- ${scoreboard(game.game_type_cd, pgstats, show_elo, show_latency)} + ${scoreboard(game.game_type_cd, pgstats, teams, show_elo, show_latency)}
diff --git a/xonstat/templates/scoreboard.mako b/xonstat/templates/scoreboard.mako index 1f4f51f..cfcdfc3 100644 --- a/xonstat/templates/scoreboard.mako +++ b/xonstat/templates/scoreboard.mako @@ -1,22 +1,21 @@ -<%def name="scoreboard(game_type_cd, pgstats, show_elo=False, show_latency=False)"> +<%def name="scoreboard(game_type_cd, pgstats, teams=None, show_elo=False, show_latency=False)"> +##teams: { scoreboardpos : ( teamname, teamscore, playercount ) } % if teamscores: - % for team,score in sorted(teamscores.items(), key=lambda x:x[1], reverse=True): - + % endfor
${score}${team.capitalize()} Team: ${score}
% endif + ${scoreboard_header(game_type_cd, pgstats[0])} % for pgstat in pgstats: - % if show_latency and pgstat.avg_latency is not None: - % elif show_latency: - + % endif ${scoreboard_row(game_type_cd, pgstat)} % if game_type_cd != 'cts': - + % endif % if show_elo: % if pgstat.elo_delta is not None: - + % else: - + % endif % endif + ##% if teams: + ##% if teams.has_key(pgstat.scoreboardpos): + ## + ##% endif + ##% endif % endfor @@ -64,6 +68,9 @@ + ##% if teams: + ## + ##% endif % if show_elo: % endif @@ -82,6 +89,9 @@ + ##% if teams: + ## + ##% endif % if show_elo: % endif @@ -101,9 +111,9 @@ - % if show_elo: - - % endif + ##% if show_elo: + ## + ##% endif % endif @@ -134,6 +144,9 @@ + ##% if teams: + ## + ##% endif % if show_elo: % endif @@ -153,6 +166,9 @@ + ##% if teams: + ## + ##% endif % if show_elo: % endif @@ -171,6 +187,9 @@ + ##% if teams: + ## + ##% endif % if show_elo: % endif @@ -190,6 +209,9 @@ + ##% if teams: + ## + ##% endif % if show_elo: % endif @@ -213,6 +235,9 @@ + ##% if teams: + ## + ##% endif % if show_elo: % endif @@ -230,6 +255,9 @@ + ##% if teams: + ## + ##% endif % if show_elo: % endif @@ -256,98 +284,98 @@ ##### SCOREBOARD ROWS ##### <%def name="scoreboard_row(game_type_cd, pgstat)"> % if game_type_cd == 'as': - - - - + + + + % endif % if game_type_cd in 'ca' 'dm' 'duel' 'rune' 'tdm': - - - + + + % endif % if game_type_cd == 'cq': - - - - + + + + % endif % if game_type_cd == 'cts': % if pgstat.fastest is not None: - + % else: - + % endif - + % endif % if game_type_cd == 'ctf': - - - - - + + + + + % endif % if game_type_cd == 'dom': - - - - + + + + % endif % if game_type_cd in 'ft' 'freezetag': - - - + + + % endif % if game_type_cd in 'ka' 'keepaway': - - - + + + % if pgstat.time is not None: - + % else: - + % endif - + % endif % if game_type_cd == 'kh': - - - - - - - - + + + + + + + + % endif % if game_type_cd in 'nb' 'nexball': - - + + % endif % if game_type_cd == 'rc': - + % if pgstat.fastest is not None: - + % else: - + % endif % if pgstat.time is not None: - + % else: - + % endif % endif diff --git a/xonstat/views/game.py b/xonstat/views/game.py index f0fc1ce..0198446 100644 --- a/xonstat/views/game.py +++ b/xonstat/views/game.py @@ -4,11 +4,14 @@ import re import time from pyramid.response import Response from sqlalchemy import desc, func, over +from collections import namedtuple from webhelpers.paginate import Page, PageURL from xonstat.models import * from xonstat.util import page_url from xonstat.views.helpers import RecentGame, recent_games_q +import random + log = logging.getLogger(__name__) @@ -125,6 +128,34 @@ def _game_info_data(request): teamscores[team] = None if len(teamscores) == 0: teamscores = None + + ### RANDOM SCORES FOR TESTING + teams = ["red","blue","yellow","pink"] + random.shuffle(teams) + teamscores = {} + for k in range(random.randint(2,4)): + team = teams[k-1] + teamscores[team] = random.randint(-5,150) + ### END + + #TeamInfo = namedtuple('TeamInfo', ['team','scoreboardpos','playercount','teamscore']) + # + #teams = {} + #last_pgs = pgstats[0] + #for pgstat in pgstats: + # if pgstat.team != last_pgs.team: + # teams[last_pgs.scoreboardpos] = TeamInfo( + # team=last_pgs.team, + # scoreboardpos=last_pgs.scoreboardpos, + # playercount=pgstat.scoreboardpos-last_pgs.scoreboardpos, + # teamscore=last_pgs.teamscore) + # last_pgs = pgstat + #teams[last_pgs.scoreboardpos] = TeamInfo( + # team=last_pgs.team, + # scoreboardpos=last_pgs.scoreboardpos, + # playercount=pgstat.scoreboardpos-last_pgs.scoreboardpos, + # teamscore=last_pgs.teamscore) + #print teams pwstats = {} for (pwstat, pgstat, weapon) in DBSession.query(PlayerWeaponStat, PlayerGameStat, Weapon).\ @@ -154,7 +185,7 @@ def _game_info_data(request): pgstats = None pwstats = None captimes = None - teamscores = None + teams = None show_elo = False show_latency = False raise inst @@ -166,6 +197,7 @@ def _game_info_data(request): 'pgstats':pgstats, 'pwstats':pwstats, 'captimes':captimes, + 'teams':teams, 'teamscores':teamscores, 'show_elo':show_elo, 'show_latency':show_latency, -- 2.39.2
+ % if pgstat.player_id > 2: @@ -27,23 +26,28 @@ % endif + ${int(round(pgstat.avg_latency))} ${pgstat.score}${pgstat.score}${round(pgstat.elo_delta,2)}${round(pgstat.elo_delta,2)}--${teams[pgstat.scoreboardpos].teamscore}
Suicides Objectives ScoreTeamscoreElo ChangeDeaths Suicides ScoreTeamscoreElo ChangeCaptured Released ScoreElo ChangeElo Change
FCK Returns ScoreTeamscoreElo ChangeTakes Ticks ScoreTeamscoreElo ChangeDeaths Revivals ScoreTeamscoreElo ChangePickups BC Time BC KillsTeamscoreElo ChangeDestroys KC Kills ScoreTeamscoreElo ChangeGoals Faults ScoreTeamscoreElo Change${pgstat.kills}${pgstat.deaths}${pgstat.suicides}${pgstat.collects}${pgstat.kills}${pgstat.deaths}${pgstat.suicides}${pgstat.collects}${pgstat.kills}${pgstat.deaths}${pgstat.suicides}${pgstat.kills}${pgstat.deaths}${pgstat.suicides}${pgstat.kills}${pgstat.deaths}${pgstat.captures}${pgstat.drops}${pgstat.kills}${pgstat.deaths}${pgstat.captures}${pgstat.drops}${round(float(pgstat.fastest.seconds) + (pgstat.fastest.microseconds/1000000.0), 2)}${round(float(pgstat.fastest.seconds) + (pgstat.fastest.microseconds/1000000.0), 2)}--${pgstat.deaths}${pgstat.deaths}${pgstat.kills}${pgstat.captures}${pgstat.pickups}${pgstat.carrier_frags}${pgstat.returns}${pgstat.kills}${pgstat.captures}${pgstat.pickups}${pgstat.carrier_frags}${pgstat.returns}${pgstat.kills}${pgstat.deaths}${pgstat.pickups}${pgstat.drops}${pgstat.kills}${pgstat.deaths}${pgstat.pickups}${pgstat.drops}${pgstat.kills}${pgstat.deaths}${pgstat.revivals}${pgstat.kills}${pgstat.deaths}${pgstat.revivals}${pgstat.kills}${pgstat.deaths}${pgstat.pickups}${pgstat.kills}${pgstat.deaths}${pgstat.pickups}${round(float(pgstat.time.seconds) + (pgstat.time.microseconds/1000000.0), 2)}${round(float(pgstat.time.seconds) + (pgstat.time.microseconds/1000000.0), 2)}--${pgstat.fckills}${pgstat.fckills}${pgstat.kills}${pgstat.deaths}${pgstat.pickups}${pgstat.captures}${pgstat.drops}${pgstat.pushes}${pgstat.destroys}${pgstat.carrier_frags}${pgstat.kills}${pgstat.deaths}${pgstat.pickups}${pgstat.captures}${pgstat.drops}${pgstat.pushes}${pgstat.destroys}${pgstat.carrier_frags}${pgstat.captures}${pgstat.drops}${pgstat.captures}${pgstat.drops}${pgstat.laps}${pgstat.laps}${round(float(pgstat.fastest.seconds) + (pgstat.fastest.microseconds/1000000.0), 2)}${round(float(pgstat.fastest.seconds) + (pgstat.fastest.microseconds/1000000.0), 2)}--${round(float(pgstat.time.seconds) + (pgstat.time.microseconds/1000000.0), 2)}${round(float(pgstat.time.seconds) + (pgstat.time.microseconds/1000000.0), 2)}--