aboutsummaryrefslogtreecommitdiff
path: root/api
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-02-21 10:30:33 +0100
committerlonkaars <l.leblansch@gmail.com>2021-02-21 10:30:33 +0100
commit980e0ebbcff5bbb9d27394dcb4ba6f61980418b0 (patch)
treebe338a7ae6f58b9582e2342913b88c025479dc43 /api
parentff83a204a27a5c37a5061857f2bc67a3d7f05d46 (diff)
hide new game dialog while looking for game + gamebar move works
Diffstat (limited to 'api')
-rw-r--r--api/game/random.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/api/game/random.py b/api/game/random.py
index 09408e1..68ba44c 100644
--- a/api/game/random.py
+++ b/api/game/random.py
@@ -22,12 +22,13 @@ def index():
user_id = token_login(token)[0]
public_games = cursor.execute("select game_id from games where private = FALSE and status = \"wait_for_opponent\"").fetchall()
- print(public_games)
+
if len(public_games) == 0:
game_id = new_uuid("games")
cursor.execute("insert into games values (?, NULL, NULL, ?, NULL, NULL, 0, NULL, NULL, NULL, \"wait_for_opponent\", \"default\", FALSE) ", (game_id, user_id))
connection.commit()
+ player_1 = True
else:
game_id = random.choice(public_games)[0]
timestamp = int( time.time() * 1000 )
@@ -37,4 +38,6 @@ def index():
players = cursor.execute("select player_1_id, player_2_id from games where game_id = ?", [game_id]).fetchone()
games[game_id] = game(game_id, io, players[0], players[1])
- return { "id": game_id }, 200
+ player_1 = False
+
+ return { "id": game_id, "player_1": player_1 }, 200