From: Jan Behrens Date: Sat, 17 Aug 2013 10:40:08 +0000 (+0200) Subject: Merge branch 'master' into zykure/wip X-Git-Url: https://de.git.xonotic.org/?p=xonotic%2Fxonstat.git;a=commitdiff_plain;h=51c42763989fcd89c3d213b897773005ce02c7b7 Merge branch 'master' into zykure/wip Conflicts: xonstat/static/css/app.css xonstat/static/css/app.min.css xonstat/templates/game_info.mako xonstat/templates/scoreboard.mako xonstat/views/submission.py --- 51c42763989fcd89c3d213b897773005ce02c7b7 diff --cc xonstat/views/game.py index 0198446,a0f65e8..58d48f8 --- a/xonstat/views/game.py +++ b/xonstat/views/game.py @@@ -2,9 -2,9 +2,10 @@@ import datetim import logging import re import time + from collections import OrderedDict 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 @@@ -113,50 -131,8 +134,49 @@@ def _game_info_data(request) for pgstat in pgstats: if pgstat.fastest is not None: captimes.append(pgstat) - captimes = sorted(captimes, key=lambda x:x.fastest) + teamscores = {} + for pgstat in pgstats: + if pgstat.team in [5,14,13,10]: + team = pgstat.team_html_color() + if pgstat.teamscore is not None: + if not teamscores.has_key(team): + teamscores[team] = pgstat.teamscore + else: + if teamscores[team] != pgstat.teamscore: # this should not happen! + 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).\ filter(PlayerWeaponStat.game_id == game_id).\ @@@ -183,11 -159,12 +203,13 @@@ map = None gametype = None pgstats = None + tgstats = None pwstats = None captimes = None + teams = None show_elo = False show_latency = False + stats_by_team = None raise inst return {'game':game, @@@ -195,12 -172,12 +217,14 @@@ 'map':map, 'gametype':gametype, 'pgstats':pgstats, + 'tgstats':tgstats, 'pwstats':pwstats, 'captimes':captimes, + 'teams':teams, + 'teamscores':teamscores, 'show_elo':show_elo, 'show_latency':show_latency, + 'stats_by_team':stats_by_team, }