Skip to content

Commit

Permalink
define a global time format string. this should be abstracted to a co…
Browse files Browse the repository at this point in the history
…nfig file so the analysis script can access it
  • Loading branch information
privong authored and George C. Privon committed Feb 4, 2018
1 parent 604975c commit e40ca0f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cgame.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def __init__(self):
self.conn = _sqlite3.connect('CarcassonneScore.db')
self.cur = self.conn.cursor()

self.timefmt = "%Y-%m-%dT%H:%M:%S"
self.setupGame()


Expand Down Expand Up @@ -97,7 +98,7 @@ def gameInfo(self):

location = input("Where is the game being played? ")

starttime = _datetime.utcnow().strftime("%Y-%m-%dT%H:%M")
starttime = _datetime.utcnow().strftime(self.timefmt)

self.cur.execute('INSERT INTO games (location, starttime, expansions) VALUES ("' + location + '","' + starttime + '","' + ','.join(["{0:d}".format(x) for x in self.expansionIDs]) + '")')

Expand Down Expand Up @@ -325,7 +326,7 @@ def advanceTurn(self, builder=False):
Make a new entry in the turns table
"""

cmdtime = _datetime.utcnow().strftime("%Y-%m-%dT%H:%M")
cmdtime = _datetime.utcnow().strftime(self.timefmt)

command = '''INSERT INTO turns VALUES ({0:d}, {1:d}, "'''.format(self.gameID, self.ntile)
command = command + cmdtime + '"'
Expand Down Expand Up @@ -395,7 +396,7 @@ def runGame(self):

if self.state == 2:
#game is over. write end time to the games table
time = _datetime.utcnow().strftime("%Y-%m-%dT%H:%M")
time = _datetime.utcnow().strftime(self.timefmt)
self.cur.execute('''UPDATE games SET endtime = "''' + time + '''" WHERE gameID = ''' + str(self.gameID))
self.conn.commit()

Expand Down

0 comments on commit e40ca0f

Please sign in to comment.