From 1808e0c518a8597d8893bbfd93928305f74db1b8 Mon Sep 17 00:00:00 2001 From: hailwaft Date: Tue, 12 Jan 2021 02:44:10 +0800 Subject: [PATCH 1/3] Update main.py -add "Rating did not change" -refactored elo change for better efficiency --- app/main.py | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/app/main.py b/app/main.py index 65b1468..4e909c3 100644 --- a/app/main.py +++ b/app/main.py @@ -89,11 +89,11 @@ def display_match_history(): try: posts = [] for match in json_res['Matches']: - # print(match) - if match['CompetitiveMovement'] == 'MOVEMENT_UNKNOWN': + compe_movement = match['CompetitiveMovement'] + if compe_movement == 'MOVEMENT_UNKNOWN': continue - match_movement, game_outcome, main_color, gradient_color = match_movement_hash[match['CompetitiveMovement']] - lp_change = '' + print(match) + match_movement, game_outcome, main_color, gradient_color = match_movement_hash[compe_movement] game_map = 'images/maps/' + maps_hash[match['MapID']] + '.png' @@ -104,22 +104,20 @@ def display_match_history(): before = match['TierProgressBeforeUpdate'] after = match['TierProgressAfterUpdate'] + tier_after = match['TierAfterUpdate'] + tier_before = match['TierBeforeUpdate'] + tier_min = min(tier_after, tier_before) - # calculate lp change, TODO: do this more efficiently - if match['CompetitiveMovement'] == 'PROMOTED': - lp_change = '+' + str(after + 100 - before) - elif match['CompetitiveMovement'] == 'DEMOTED': - lp_change = '-' + str(before + 100 - after) - else: - if before < after: - # won - lp_change = '+' + str(after - before) - else: - # lost - lp_change = str(after - before) + # calculate lp change + lp_change = (((tier_after - tier_min) * 100) + after) - (((tier_before - tier_min) * 100) + before) + + if lp_change > 0: + lp_change = '+' + str(lp_change) + elif lp_change == 0: + match_movement = "Rating did not change" match_data = { - 'lp_change': lp_change, + 'lp_change': str(lp_change), 'current_lp': after, 'game_outcome': game_outcome, 'movement': match_movement, From fa478e3f06287f3b7e1e77420c1815c2baac9385 Mon Sep 17 00:00:00 2001 From: hailwaft Date: Tue, 12 Jan 2021 04:26:54 +0800 Subject: [PATCH 2/3] Update main.py --- app/main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/app/main.py b/app/main.py index 4e909c3..46fa0dc 100644 --- a/app/main.py +++ b/app/main.py @@ -92,7 +92,6 @@ def display_match_history(): compe_movement = match['CompetitiveMovement'] if compe_movement == 'MOVEMENT_UNKNOWN': continue - print(match) match_movement, game_outcome, main_color, gradient_color = match_movement_hash[compe_movement] game_map = 'images/maps/' + maps_hash[match['MapID']] + '.png' From 76aca0ac361855c1bf447496670300de8c44003d Mon Sep 17 00:00:00 2001 From: hailwaft Date: Tue, 12 Jan 2021 06:01:52 +0800 Subject: [PATCH 3/3] remove elif for lp_change --- app/main.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/main.py b/app/main.py index 46fa0dc..d3dd9b8 100644 --- a/app/main.py +++ b/app/main.py @@ -112,8 +112,6 @@ def display_match_history(): if lp_change > 0: lp_change = '+' + str(lp_change) - elif lp_change == 0: - match_movement = "Rating did not change" match_data = { 'lp_change': str(lp_change),