aboutsummaryrefslogtreecommitdiff
path: root/api/game/info.py
diff options
context:
space:
mode:
authorlonkaars <l.leblansch@gmail.com>2021-04-11 18:03:11 +0200
committerlonkaars <l.leblansch@gmail.com>2021-04-11 18:03:11 +0200
commitdeb09e5c749e3353c927d7fe94bbd35f25ff85ee (patch)
tree702ba982530aa98a96ddece365a32be842dae3c2 /api/game/info.py
parent28f104de9ae9abe4b42abafbf3865ede5687996c (diff)
dprint yapf continuation align style edit
Diffstat (limited to 'api/game/info.py')
-rw-r--r--api/game/info.py68
1 files changed, 34 insertions, 34 deletions
diff --git a/api/game/info.py b/api/game/info.py
index 869a19c..71fed2e 100644
--- a/api/game/info.py
+++ b/api/game/info.py
@@ -8,25 +8,25 @@ from ruleset import resolve_ruleset
def format_game(game_id, user_id=None):
game = cursor.execute(
- "select " + ", ".join(
- [
- "game_id", # 0
- "parent_game", # 1
- "moves", # 2
- "player_1_id", # 3
- "player_2_id", # 4
- "outcome", # 5
- "created", # 6
- "started", # 7
- "duration", # 8
- "rating_delta_player_1", # 9
- "rating_delta_player_2", # 10
- "ruleset", # 11
- "status", # 12
- "private", # 13
- ]
- ) + " from games where game_id = ?",
- [game_id]
+ "select " + ", ".join(
+ [
+ "game_id", # 0
+ "parent_game", # 1
+ "moves", # 2
+ "player_1_id", # 3
+ "player_2_id", # 4
+ "outcome", # 5
+ "created", # 6
+ "started", # 7
+ "duration", # 8
+ "rating_delta_player_1", # 9
+ "rating_delta_player_2", # 10
+ "ruleset", # 11
+ "status", # 12
+ "private", # 13
+ ]
+ ) + " from games where game_id = ?",
+ [game_id]
).fetchone()
is_player_1 = game[4] != user_id
@@ -36,30 +36,30 @@ def format_game(game_id, user_id=None):
# parse moves into list and return empty list if moves string is empty
moves = [] if len(game[2]) == 0 else [
- int(move) for move in str(game[2] + "0").split(",")
+ int(move) for move in str(game[2] + "0").split(",")
]
return {
- "id": game[0],
- "parent": game[1],
- "moves": moves,
- "opponent": None if not opponent else format_user(opponent),
- "outcome": None if not game[5] else outcome(game[5], is_player_1),
- "created": game[6],
- "started": game[7],
- "duration": game[8],
- "rating": game[9] if is_player_1 else game[10],
- "rating_opponent": game[10] if is_player_1 else game[9],
- "ruleset": resolve_ruleset(game[11]),
- "status": game[12],
- "private": bool(game[13]),
+ "id": game[0],
+ "parent": game[1],
+ "moves": moves,
+ "opponent": None if not opponent else format_user(opponent),
+ "outcome": None if not game[5] else outcome(game[5], is_player_1),
+ "created": game[6],
+ "started": game[7],
+ "duration": game[8],
+ "rating": game[9] if is_player_1 else game[10],
+ "rating_opponent": game[10] if is_player_1 else game[9],
+ "ruleset": resolve_ruleset(game[11]),
+ "status": game[12],
+ "private": bool(game[13]),
}
# check if game_id exists in database
def valid_game_id(game_id):
query = cursor.execute(
- "select game_id from games where game_id = ?", [game_id]
+ "select game_id from games where game_id = ?", [game_id]
).fetchone()
return bool(query)