1
0
Fork 0
mirror of synced 2024-05-29 16:59:42 +12:00

Corrected issue with the update records, if no entry yet

This commit is contained in:
phxntxm 2016-08-19 01:13:03 -05:00
parent 86018bc24d
commit cfac889db8
2 changed files with 2 additions and 6 deletions

View file

@ -35,9 +35,7 @@ def user_battling(ctx, player2=None):
def update_battle_records(winner, loser):
# We're using the Harkness scale to rate
# http://opnetchessclub.wikidot.com/harkness-rating-system
battles = config.get_content('battle_records')
if battles is None:
battles = {winner.id: "1-0", loser.id: "0-1"}
battles = config.get_content('battle_records') or {}
# Start ratings at 1000 if they have no rating
winner_stats = battles.get(winner.id) or {}

View file

@ -101,9 +101,7 @@ class Board:
def update_records(winner, loser):
# This is the exact same formula as the battling update.
# The only difference is I use the word "match" instead of "battle"
matches = config.get_content('tictactoe')
if matches is None:
matches = {winner.id: "1-0", loser.id: "0-1"}
matches = config.get_content('tictactoe') or {}
winner_stats = matches.get(winner.id) or {}
winner_rating = winner_stats.get('rating') or 1000