]> de.git.xonotic.org Git - xonotic/xonstat.git/blobdiff - xonstat/views/game.py
Provide an option to show elo deltas on the game info page.
[xonotic/xonstat.git] / xonstat / views / game.py
index 70bbd58c862325959f10761ac359fea1a76e95f2..f9389e0bc10821a4c73aae68324c96ee44b625c1 100644 (file)
@@ -31,7 +31,7 @@ def _game_index_data(request):
                 order_by(PlayerGameStat.rank).\
                 order_by(PlayerGameStat.score).all()
 
-    return {'games':games, 
+    return {'games':games,
             'pgstats':pgstats}
 
 
@@ -44,8 +44,23 @@ def game_index(request):
     return _game_index_data(request)
 
 
+def game_index_json(request):
+    """
+    Provides a list of current games, with the associated game stats.
+    These games are ordered by game_id, with the most current ones first.
+    Paginated. JSON.
+    """
+    return [{'status':'not implemented'}]
+
+
 def _game_info_data(request):
     game_id = request.matchdict['id']
+
+    if request.params.has_key('show_elo'):
+        show_elo = True
+    else:
+        show_elo = False
+
     try:
         notfound = False
 
@@ -60,6 +75,14 @@ def _game_info_data(request):
                 order_by(PlayerGameStat.score).\
                 all()
 
+        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).\
                 filter(PlayerWeaponStat.game_id == game_id).\
@@ -86,6 +109,8 @@ def _game_info_data(request):
         map = None
         pgstats = None
         pwstats = None
+        captimes = None
+        show_elo = False
         raise inst
 
     return {'game':game,
@@ -93,6 +118,8 @@ def _game_info_data(request):
             'map':map,
             'pgstats':pgstats,
             'pwstats':pwstats,
+            'captimes':captimes,
+            'show_elo':show_elo,
             }
 
 
@@ -103,6 +130,13 @@ def game_info(request):
     return _game_info_data(request)
 
 
+def game_info_json(request):
+    """
+    List the game stats (scoreboard) for a particular game. Paginated. JSON.
+    """
+    return [{'status':'not implemented'}]
+
+
 def _rank_index_data(request):
     if request.params.has_key('page'):
         current_page = request.params['page']
@@ -131,3 +165,10 @@ def rank_index(request):
     Provide a list of gametype ranks, paginated.
     """
     return _rank_index_data(request)
+
+
+def rank_index_json(request):
+    """
+    Provide a list of gametype ranks, paginated. JSON.
+    """
+    return [{'status':'not implemented'}]