from sqlalchemy.orm import scoped_session
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base
+from xonstat.util import strip_colors, html_colors
DBSession = scoped_session(sessionmaker())
Base = declarative_base()
return "<PlayerGameStat(%s, %s, %s, %s)>" \
% (self.player_id, self.game_id, self.create_dt, self.stat_type)
+ def nick_stripped(self):
+ return strip_colors(self.nick)
+
+ def nick_html_colors(self):
+ return html_colors(self.nick)
+
class GameMutator(object):
def __repr__(self):
% else:
<h2>Game Detail</h2>
-<ul>
- <li>ID: ${game.game_id}</li>
- <li>Time: ${game.start_dt}</li>
- <li>Game Type: ${game.game_type_cd}</li>
- <li>Server: ${game.server_id}</li>
- <li>Map: ${game.map_id}</li>
- <li>Duration: ${game.duration}</li>
- <li>Winner: ${game.duration}</li>
-</ul>
+<p>
+Played on: ${start_dt}<br />
+Game Type: ${game_type_cd}<br />
+Server: <a href="${request.route_url("server_info", id=server_id)}" name="Server info page for ${server_name}">${server_name}</a><br />
+Map: <a href="${request.route_url("map_info", id=map_id)}" name="Map info page for ${map_name}">${map_name}</a><br />
+</p>
+
+<h2>Scoreboard</h2>
+<table border="1">
+ <tr>
+ <td>Nick</td>
+ <td>Kills</td>
+ <td>Deaths</td>
+ <td>Suicides</td>
+ <td>Captures</td>
+ <td>Returns</td>
+ <td>Flag Carrier Kills</td>
+ <td>Score</td>
+ </tr>
+% for player_game_stat in player_game_stats:
+ <tr>
+ <td>${player_game_stat.nick_html_colors()}</td>
+ <td>${player_game_stat.kills}</td>
+ <td>${player_game_stat.deaths}</td>
+ <td>${player_game_stat.suicides}</td>
+ <td>${player_game_stat.captures}</td>
+ <td>${player_game_stat.returns}</td>
+ <td>${player_game_stat.carrier_frags}</td>
+ <td>${player_game_stat.score}</td>
+ </tr>
+% endfor
+</table>
% endif
def game_info(request):
game_id = request.matchdict['id']
try:
- game = DBSession.query(Game).filter_by(game_id=game_id).one()
- except:
- game = None
- return {'game':game}
+ (start_dt, game_type_cd, server_id, server_name, map_id, map_name) = \
+ DBSession.query("start_dt", "game_type_cd", "server_id",
+ "server_name", "map_id", "map_name").\
+ from_statement("select g.start_dt, g.game_type_cd, "
+ "g.server_id, s.name as server_name, g.map_id, "
+ "m.name as map_name "
+ "from games g, servers s, maps m "
+ "where g.game_id = :game_id "
+ "and g.server_id = s.server_id "
+ "and g.map_id = m.map_id").\
+ params(game_id=game_id).one()
+
+ player_game_stats = DBSession.query(PlayerGameStat).\
+ from_statement("select * from player_game_stats "
+ "where game_id = :game_id "
+ "order by score desc").\
+ params(game_id=game_id).all()
+ except Exception as inst:
+ player_game_stats = None
+ return {'start_dt':start_dt,
+ 'game_type_cd':game_type_cd,
+ 'server_id':server_id,
+ 'server_name':server_name,
+ 'map_id':map_id,
+ 'map_name':map_name,
+ 'player_game_stats':player_game_stats}
##########################################################################