aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-03-09 12:35:07 +0100
committerlonkaars <l.leblansch@gmail.com>2021-03-09 12:35:07 +0100
commit8ff6187219405c62cf38755f4afccb1e7ad5b353 (patch)
tree10f4900a1509944d06d1e2685cdcf1b9e5a6cafc /api
parentdaa4c343e8ced8d7c62e94b22d4192661e75ebe4 (diff)
move ordering
Diffstat (limited to 'api')
-rw-r--r--api/game/socket.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/api/game/socket.py b/api/game/socket.py
index 78e7969..0318e0b 100644
--- a/api/game/socket.py
+++ b/api/game/socket.py
@@ -30,7 +30,11 @@ class game:
self.board.drop_fisje(column)
self.send("fieldUpdate", { "field": self.board.board })
- self.send("turnUpdate", { "player1": self.board.player_1 })
+
+ now = int( time.time() * 1000 )
+ cursor.execute("update games set last_activity = ?, moves = moves || ? || ',' where game_id = ?", [now, column, self.game_id])
+ connection.commit()
+
if len(self.board.win_positions) > 0 or self.board.board_full:
outcome = "d"
if not self.board.board_full:
@@ -41,17 +45,15 @@ class game:
"boardFull": self.board.board_full
})
self.close("finished", outcome)
+ return
- now = int( time.time() * 1000 )
- cursor.execute("update games set last_activity = ?, moves = moves || ? || ',' where game_id = ?", [now, column, self.game_id])
- connection.commit()
+ self.send("turnUpdate", { "player1": self.board.player_1 })
def resign(self):
self.board.kill_voerbak()
self.send("resign", "")
self.close("resign", "d")
-
def close(self, new_status, outcome):
cursor.execute(" ".join([
"update games set",