fixed 3 bugs:
- check for timeout in gamecreation.py - game deletion did not work correctly - game creation always wrote to the first game slot.
This commit is contained in:
parent
a70d382c93
commit
a000c9dd9a
3 changed files with 20 additions and 14 deletions
22
database.py
22
database.py
|
@ -48,6 +48,7 @@ class GobanTable(SQLObject):
|
|||
|
||||
def players(self):
|
||||
"""returns both player names as a tuple"""
|
||||
print self.player1,self.player2
|
||||
return (self.player1,self.player2)
|
||||
|
||||
def set_time(self):
|
||||
|
@ -103,8 +104,9 @@ class Users(SQLObject):
|
|||
ret.append(self.game10)
|
||||
return ret
|
||||
|
||||
def removegame(self,gamename):
|
||||
def remove_game(self,gamename):
|
||||
"""removes a game whose name is given."""
|
||||
gamename = int(gamename) #sqlobject does a int(value) for self.game[1..10]
|
||||
if self.game1 == gamename: self.game1=None
|
||||
if self.game2 == gamename: self.game2=None
|
||||
if self.game3 == gamename: self.game3=None
|
||||
|
@ -133,15 +135,15 @@ class Users(SQLObject):
|
|||
def add_game(self,gamename):
|
||||
"""saves the game name into an empty slot"""
|
||||
if self.game1 == None: self.game1 = gamename
|
||||
elif self.game2 == None: self.game1 = gamename
|
||||
elif self.game3 == None: self.game1 = gamename
|
||||
elif self.game4 == None: self.game1 = gamename
|
||||
elif self.game5 == None: self.game1 = gamename
|
||||
elif self.game6 == None: self.game1 = gamename
|
||||
elif self.game7 == None: self.game1 = gamename
|
||||
elif self.game8 == None: self.game1 = gamename
|
||||
elif self.game9 == None: self.game1 = gamename
|
||||
elif self.game10 == None: self.game1 = gamename
|
||||
elif self.game2 == None: self.game2 = gamename
|
||||
elif self.game3 == None: self.game3 = gamename
|
||||
elif self.game4 == None: self.game4 = gamename
|
||||
elif self.game5 == None: self.game5 = gamename
|
||||
elif self.game6 == None: self.game6 = gamename
|
||||
elif self.game7 == None: self.game7 = gamename
|
||||
elif self.game8 == None: self.game8 = gamename
|
||||
elif self.game9 == None: self.game9 = gamename
|
||||
elif self.game10 == None: self.game10 = gamename
|
||||
else: return False
|
||||
|
||||
def set_timeout(self):
|
||||
|
|
|
@ -15,7 +15,7 @@ def main(gamename):
|
|||
#free game slots of players
|
||||
for player in players:
|
||||
myuser = database.Users.byUsername(player)
|
||||
myuser.removegame(gamename)
|
||||
myuser.remove_game(gamename)
|
||||
|
||||
#delete table
|
||||
mygame.destroySelf()
|
||||
|
|
|
@ -27,10 +27,14 @@ class GameCreation:
|
|||
manages the creation of games.
|
||||
"""
|
||||
def index(self,player1 = None, player2 = None, description = None,gobansize = None):
|
||||
try:
|
||||
username = cpg.request.sessionMap["username"]
|
||||
myuser = database.Users.byUsername(username)
|
||||
except:
|
||||
return helper.cs_render("templates/not_logged_in.cs")
|
||||
username = ""
|
||||
sessionid = cpg.request.sessionMap["_sessionId"]
|
||||
if myuser.sessionid == sessionid:
|
||||
if myuser.sessionid == sessionid and username != "":
|
||||
if player1 != None and player2 != None and gobansize != None:
|
||||
return self.process_creation_form(player1,player2,gobansize,description)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue