changeset 62:df7acc5653b3

Make the final depth appear in Advanced Rogue 5 tables. Along the way, "SELECT name FROM table WHERE name = ..." was removed from any queries where it had been carelessly placed.
author John "Elwin" Edwards
date Fri, 30 Jan 2015 20:24:47 -0500
parents 5b4ff5680037
children ad103f9f2e3a
files py/rlgall.py
diffstat 1 files changed, 18 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/py/rlgall.py	Fri Jan 30 09:25:32 2015 -0500
+++ b/py/rlgall.py	Fri Jan 30 20:24:47 2015 -0500
@@ -54,7 +54,8 @@
 
 # This would be more useful if we had to do translation
 headerbook = {"endt":"End time", "score":"Score", "name":"Name", "xl":"XL", 
-              "fate":"Fate", "rank":"Rank", "game":"Game", "class": "Class"}
+              "fate":"Fate", "rank":"Rank", "game":"Game", "class":"Class",
+              "depth":"Depth"}
 # Queries for the games table
 offselstr = "SELECT offbytes FROM games WHERE gname = %s;"
 newoffstr = "UPDATE games SET offbytes = %s WHERE gname = %s;"
@@ -123,6 +124,8 @@
           clist.append((thing.name, cell))
         elif field == "xl" or field == "score" or field == "rank": # Numerics
           clist.append((str(thing), rcell))
+        elif field == "depth" or field == "maxdepth":
+          clist.append((str(thing), cell))
         elif field == "name":
           clist.append((playerlink(thing), cell))
         elif field == "fate":
@@ -425,7 +428,7 @@
     return dictlist
   def getPlayer(self, player):
     "Gets all player's games from the database."
-    qstr = "SELECT endt, score, name, xl, fate, startt FROM " + self.uname + " WHERE name = %s;"
+    qstr = "SELECT endt, score, xl, fate, startt FROM " + self.uname + " WHERE name = %s;"
     conn = getconn()
     if conn == None:
       return []
@@ -434,12 +437,12 @@
     cur.execute(qstr, [player])
     for record in cur:
       ndict = {"game": self}
+      ndict["name"] = self.uname
       ndict["endt"] = record[0]
       ndict["score"] = record[1]
-      ndict["name"] = record[2]
-      ndict["xl"] = record[3]
-      ndict["fate"] = record[4]
-      ndict["startt"] = record[5]
+      ndict["xl"] = record[2]
+      ndict["fate"] = record[3]
+      ndict["startt"] = record[4]
       entries.append(ndict)
     cur.close()
     conn.close()
@@ -495,14 +498,14 @@
     self.insertq = "INSERT INTO {0} ({1}) VALUES ({2});".format(self.uname, 
                     colspec, valspec)
   # Class variables
-  fields = ["name", "score", "class", "xl", "fate", "endt"]
-  rankfields = ["rank", "score", "name", "class", "xl", "fate", "endt"]
-  pfields = ["score", "class", "xl", "fate", "endt"]
+  fields = ["name", "score", "class", "xl", "fate", "depth", "endt"]
+  rankfields = ["rank", "score", "name", "class", "xl", "fate", "depth", "endt"]
+  pfields = ["score", "class", "xl", "fate", "depth", "endt"]
   def getRecent(self, n=20):
     return []
   def getPlayer(self, player):
     "Gets all player's games from the database."
-    qstr = "SELECT endt, score, name, xl, class, fate FROM " + self.uname + " WHERE name = %s;"
+    qstr = "SELECT endt, score, xl, class, fate, depth FROM " + self.uname + " WHERE name = %s;"
     conn = getconn()
     if conn == None:
       return []
@@ -511,12 +514,13 @@
     cur.execute(qstr, [player])
     for record in cur:
       ndict = {"game": self}
+      ndict["name"] = self.uname
       ndict["endt"] = record[0]
       ndict["score"] = record[1]
-      ndict["name"] = record[2]
-      ndict["xl"] = record[3]
-      ndict["class"] = record[4]
-      ndict["fate"] = record[5]
+      ndict["xl"] = record[2]
+      ndict["class"] = record[3]
+      ndict["fate"] = record[4]
+      ndict["depth"] = record[5]
       entries.append(ndict)
     cur.close()
     conn.close()