Add depth and maxdepth columns to the RogueGame tables.
This commit is contained in:
parent
291d5d4ffc
commit
48c1b168bc
2 changed files with 26 additions and 4 deletions
28
py/rlgall.py
28
py/rlgall.py
|
|
@ -2,6 +2,7 @@
|
|||
# Module for the Roguelike Gallery, using a postgres database
|
||||
# Requires Python 3.3
|
||||
|
||||
import re
|
||||
import os
|
||||
import psycopg2
|
||||
from datetime import datetime
|
||||
|
|
@ -303,9 +304,9 @@ class RogueGame(Game):
|
|||
self.uname = uname
|
||||
self.scores = logdir + uname + ".log"
|
||||
self.logspec = ["endt", "score", "name", "xl", "fate"]
|
||||
self.sqltypes = {"endt": "timestamptz", "score": "int",
|
||||
"name": "varchar(20)", "xl": "int", "fate": "text",
|
||||
"ttyrecs": "text ARRAY", "startt": "timestamptz"}
|
||||
self.sqltypes = {"endt": "timestamptz", "score": "int", "name": "text",
|
||||
"xl": "int", "fate": "text", "ttyrecs": "text ARRAY",
|
||||
"startt": "timestamptz", "depth": "int", "maxdepth": "int"}
|
||||
self.logdelim = " "
|
||||
self.lookback = -1500
|
||||
# Construct the insert query
|
||||
|
|
@ -375,6 +376,27 @@ class RogueGame(Game):
|
|||
conn.commit()
|
||||
cur.close()
|
||||
return
|
||||
def postprocess(self, gamelist):
|
||||
lre = re.compile("^(quit|killed by (.*)) on level ([0-9]*)( \\[max ([0-9]*)\\] with the Amulet)?$")
|
||||
wre = re.compile("^escaped with the Amulet \\[deepest level: ([0-9]*)\\]$")
|
||||
for d in gamelist:
|
||||
m = lre.match(d["fate"])
|
||||
if m:
|
||||
d["depth"] = int(m.group(3))
|
||||
if m.group(4):
|
||||
d["maxdepth"] = int(m.group(5))
|
||||
else:
|
||||
d["maxdepth"] = d["depth"]
|
||||
else:
|
||||
m = wre.match(d["fate"])
|
||||
if m:
|
||||
d["depth"] = 0
|
||||
d["maxdepth"] = int(m.group(1))
|
||||
else:
|
||||
# Something went wrong
|
||||
d["depth"] = -1
|
||||
d["maxdepth"] = -1
|
||||
Game.postprocess(self, gamelist)
|
||||
# End RogueGame class definition
|
||||
|
||||
class ARogueGame(Game):
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ dbconn = psycopg2.connect("dbname=rlg")
|
|||
dbcur = dbconn.cursor()
|
||||
|
||||
dbcur.execute("CREATE TABLE games ( gname varchar(20), offbytes int );")
|
||||
dbcur.execute("CREATE TABLE players (pname varchar(20) PRIMARY KEY);")
|
||||
dbcur.execute("CREATE TABLE players (pname text PRIMARY KEY);")
|
||||
dbconn.commit()
|
||||
|
||||
for game in rlgall.gamelist:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue