changeset 20:c05050f78d81

Make arogue5 scores appear on the player pages too. This could probably be done in a more structured way.
author John "Elwin" Edwards <elwin@sdf.org>
date Mon, 17 Sep 2012 11:41:11 -0700
parents 78580bffc13d
children 453278a81371
files py/rlgalldb.py
diffstat 1 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/py/rlgalldb.py	Mon Sep 17 10:24:38 2012 -0700
+++ b/py/rlgalldb.py	Mon Sep 17 11:41:11 2012 -0700
@@ -436,7 +436,26 @@
   def getRecent(self, n=20):
     return []
   def getPlayer(self, player):
-    return []
+    "Gets all player's games from the database."
+    qstr = "SELECT endt, score, name, xl, class, fate FROM " + self.uname + " WHERE name = %s;"
+    conn = getconn()
+    if conn == None:
+      return []
+    cur = conn.cursor()
+    entries = []
+    cur.execute(qstr, [player])
+    for record in cur:
+      ndict = {"game": self}
+      ndict["endt"] = record[0]
+      ndict["score"] = record[1]
+      ndict["name"] = record[2]
+      ndict["xl"] = record[3]
+      ndict["class"] = record[4]
+      ndict["fate"] = record[5]
+      entries.append(ndict)
+    cur.close()
+    conn.close()
+    return entries
 
 rogue3 = RogueGame("Rogue V3", "rogue3", "r3")
 rogue4 = RogueGame("Rogue V4", "rogue4", "r4")
@@ -462,7 +481,7 @@
         in this dungeon.</div>\n")
     else:
       entries.sort(key=lambda e: e["endt"])
-      printTable(entries, RogueGame.pfields, ppagefi)
+      printTable(entries, game.pfields, ppagefi)
       scoresum = 0
       for entry in entries:
         scoresum += int(entry["score"])