aboutsummaryrefslogtreecommitdiff
path: root/api/rating.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/rating.py
parent28f104de9ae9abe4b42abafbf3865ede5687996c (diff)
dprint yapf continuation align style edit
Diffstat (limited to 'api/rating.py')
-rw-r--r--api/rating.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/api/rating.py b/api/rating.py
index d2beaa3..5295f0d 100644
--- a/api/rating.py
+++ b/api/rating.py
@@ -13,9 +13,9 @@ def rating_v1(won_games): # python is a garbage language
def get_all_games(user_id):
return cursor.execute("select player_1_id, player_2_id, outcome " + \
- "from games " + \
- "where (player_1_id = ? or player_2_id = ?) " + \
- "and status = \"finished\" or status = \"resign\"", [user_id, user_id]).fetchall()
+ "from games " + \
+ "where (player_1_id = ? or player_2_id = ?) " + \
+ "and status = \"finished\" or status = \"resign\"", [user_id, user_id]).fetchall()
# simple rating function that doesn't use game analysis
@@ -24,16 +24,16 @@ def get_rating(user_id):
games = get_all_games(user_id)
# get all games for user_id and switch perspective in which user_id is player_2_id
mapped_games = [
- game if game[0] == user_id else
- (game[1], game[0], outcome(game[2], False)) for game in games
+ game if game[0] == user_id else
+ (game[1], game[0], outcome(game[2], False)) for game in games
]
counted_opponents = {}
for game in mapped_games:
# calculate sum score against user (+1 for win, -1 for lose, 0 for draw game)
counted_opponents[game[1]] = (counted_opponents.get(game[1]) or 0) + {
- "w": 1,
- "l": -1,
- "d": 0
+ "w": 1,
+ "l": -1,
+ "d": 0
}[game[2]]
for opponent in counted_opponents:
# apply the cool curve to the sum score and add to the base score of 400