diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-03-08 21:07:02 +0100 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-03-08 21:07:02 +0100 |
commit | febc3c4912bf8fd624d5f626e19cfdf72714ccb5 (patch) | |
tree | 9eb263d67ac83fd9024fa3eab87a98b90c7cbba5 /api/game/socket.py | |
parent | b33d057044a337f494e44ca10d461ec9f044e506 (diff) |
class based -> function based + proper game sub + good game start
Diffstat (limited to 'api/game/socket.py')
-rw-r--r-- | api/game/socket.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/api/game/socket.py b/api/game/socket.py index 69e0144..78e7969 100644 --- a/api/game/socket.py +++ b/api/game/socket.py @@ -32,20 +32,20 @@ class game: self.send("fieldUpdate", { "field": self.board.board }) self.send("turnUpdate", { "player1": self.board.player_1 }) if len(self.board.win_positions) > 0 or self.board.board_full: - winner = self.board.board[int(self.board.win_positions[0][0])] - self.close("finished", "w" if winner == "2" else "l") + outcome = "d" + if not self.board.board_full: + winner = self.board.board[int(self.board.win_positions[0][0])] + outcome = "w" if winner == "2" else "l" self.send("finish", { "winPositions": self.board.win_positions, "boardFull": self.board.board_full }) + self.close("finished", outcome) 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 self.board.board_full: - self.close("finished", "d") - def resign(self): self.board.kill_voerbak() self.send("resign", "") |