diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-04-16 16:57:26 +0200 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-04-16 16:57:26 +0200 |
commit | 07c2b124e4348b15f1e5ec18c6cdfd77248c6bc8 (patch) | |
tree | e4a29123d3ebedc1d25500390c904c66b3b02489 /api/game/random.py | |
parent | aa2c999702dadba2afbcf2be9f597f890aafcc87 (diff) |
spaces > tabs in python :(
Diffstat (limited to 'api/game/random.py')
-rw-r--r-- | api/game/random.py | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/api/game/random.py b/api/game/random.py index 559c9e5..aa5383c 100644 --- a/api/game/random.py +++ b/api/game/random.py @@ -15,31 +15,31 @@ random_game = Blueprint('random', __name__) @random_game.route('/random') @auth_required("user") def index(user_id): - # get public_games (random opponent queue) - public_games = cursor.execute( - "select game_id from games where private = FALSE and status = \"wait_for_opponent\"" - ).fetchall() - - game_started = False - - # create a new public game if the queue is empty - if len(public_games) == 0: - game_id = create_game(user_id) - player_1 = True - # otherwise join a random public game - else: - game_id = random.choice(public_games)[0] - - start_game(game_id, user_id) - - player_1 = False - game_started = True - - return { - "id": game_id, - "player_1": player_1, - "game_started": game_started - }, 200 + # get public_games (random opponent queue) + public_games = cursor.execute( + "select game_id from games where private = FALSE and status = \"wait_for_opponent\"" + ).fetchall() + + game_started = False + + # create a new public game if the queue is empty + if len(public_games) == 0: + game_id = create_game(user_id) + player_1 = True + # otherwise join a random public game + else: + game_id = random.choice(public_games)[0] + + start_game(game_id, user_id) + + player_1 = False + game_started = True + + return { + "id": game_id, + "player_1": player_1, + "game_started": game_started + }, 200 dynamic_route = ["/game", random_game] |