From 1b03a313efd069b1e8723f1f96c39adb811e3862 Mon Sep 17 00:00:00 2001 From: Aaron Traas Date: Mon, 28 Jan 2019 13:27:55 -0500 Subject: [PATCH] Fixed breakage due to the addition of arena 13 in the lookup table. Should be more resilient to future changes. --- crtools/_version.py | 2 +- crtools/crtools.py | 52 +++++++++++++++++++++++++-------------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/crtools/_version.py b/crtools/_version.py index 858085d..9a34ccc 100644 --- a/crtools/_version.py +++ b/crtools/_version.py @@ -1 +1 @@ -__version__ = "1.12.2" +__version__ = "1.13.0" diff --git a/crtools/crtools.py b/crtools/crtools.py index 92cacd5..9e613a9 100644 --- a/crtools/crtools.py +++ b/crtools/crtools.py @@ -17,27 +17,29 @@ from ._version import __version__ ARENA_LEAGUE_LOOKUP = { - 'Arena 1' : { 'id': 'arena-1', 'collection_win': { 'bronze': 40, 'silver': 80, 'gold': 140, 'legendary': 220 } }, - 'Arena 2' : { 'id': 'arena-2', 'collection_win': { 'bronze': 50, 'silver': 100, 'gold': 175, 'legendary': 275 } }, - 'Arena 3' : { 'id': 'arena-3', 'collection_win': { 'bronze': 60, 'silver': 120, 'gold': 210, 'legendary': 330 } }, - 'Arena 4' : { 'id': 'arena-4', 'collection_win': { 'bronze': 70, 'silver': 140, 'gold': 245, 'legendary': 385 } }, - 'Arena 5' : { 'id': 'arena-5', 'collection_win': { 'bronze': 80, 'silver': 160, 'gold': 280, 'legendary': 440 } }, - 'Arena 6' : { 'id': 'arena-6', 'collection_win': { 'bronze': 90, 'silver': 180, 'gold': 315, 'legendary': 495 } }, - 'Arena 7' : { 'id': 'arena-7', 'collection_win': { 'bronze': 100, 'silver': 200, 'gold': 350, 'legendary': 550 } }, - 'Arena 8' : { 'id': 'arena-8', 'collection_win': { 'bronze': 110, 'silver': 220, 'gold': 385, 'legendary': 605 } }, - 'Arena 9' : { 'id': 'arena-9', 'collection_win': { 'bronze': 120, 'silver': 240, 'gold': 420, 'legendary': 660 } }, - 'Arena 10' : { 'id': 'arena-10', 'collection_win': { 'bronze': 130, 'silver': 260, 'gold': 455, 'legendary': 715 } }, - 'Arena 11' : { 'id': 'arena-11', 'collection_win': { 'bronze': 140, 'silver': 280, 'gold': 490, 'legendary': 770 } }, - 'Arena 12' : { 'id': 'arena-12', 'collection_win': { 'bronze': 150, 'silver': 300, 'gold': 525, 'legendary': 825 } }, - 'League 1' : { 'id': 'challenger-1', 'collection_win': { 'bronze': 160, 'silver': 320, 'gold': 560, 'legendary': 880 } }, - 'League 2' : { 'id': 'challenger-2', 'collection_win': { 'bronze': 160, 'silver': 320, 'gold': 560, 'legendary': 880 } }, - 'League 3' : { 'id': 'challenger-3', 'collection_win': { 'bronze': 160, 'silver': 320, 'gold': 560, 'legendary': 880 } }, - 'League 4' : { 'id': 'master-1', 'collection_win': { 'bronze': 170, 'silver': 340, 'gold': 595, 'legendary': 935 } }, - 'League 5' : { 'id': 'master-2', 'collection_win': { 'bronze': 170, 'silver': 340, 'gold': 595, 'legendary': 935 } }, - 'League 6' : { 'id': 'master-3', 'collection_win': { 'bronze': 170, 'silver': 340, 'gold': 595, 'legendary': 935 } }, - 'League 7' : { 'id': 'champion', 'collection_win': { 'bronze': 180, 'silver': 360, 'gold': 630, 'legendary': 990 } }, - 'League 8' : { 'id': 'grand-champion', 'collection_win': { 'bronze': 180, 'silver': 360, 'gold': 630, 'legendary': 990 } }, - 'League 9' : { 'id': 'ultimate-champion', 'collection_win': { 'bronze': 180, 'silver': 360, 'gold': 630, 'legendary': 990 } } + 'Arena Unknown' : { 'id': 'arena-unknown', 'collection_win': { 'bronze': 1, 'silver': 1, 'gold': 1, 'legendary': 1 } }, + 'Arena 1' : { 'id': 'arena-1', 'collection_win': { 'bronze': 40, 'silver': 80, 'gold': 140, 'legendary': 220 } }, + 'Arena 2' : { 'id': 'arena-2', 'collection_win': { 'bronze': 50, 'silver': 100, 'gold': 175, 'legendary': 275 } }, + 'Arena 3' : { 'id': 'arena-3', 'collection_win': { 'bronze': 60, 'silver': 120, 'gold': 210, 'legendary': 330 } }, + 'Arena 4' : { 'id': 'arena-4', 'collection_win': { 'bronze': 70, 'silver': 140, 'gold': 245, 'legendary': 385 } }, + 'Arena 5' : { 'id': 'arena-5', 'collection_win': { 'bronze': 80, 'silver': 160, 'gold': 280, 'legendary': 440 } }, + 'Arena 6' : { 'id': 'arena-6', 'collection_win': { 'bronze': 90, 'silver': 180, 'gold': 315, 'legendary': 495 } }, + 'Arena 7' : { 'id': 'arena-7', 'collection_win': { 'bronze': 100, 'silver': 200, 'gold': 350, 'legendary': 550 } }, + 'Arena 8' : { 'id': 'arena-8', 'collection_win': { 'bronze': 110, 'silver': 220, 'gold': 385, 'legendary': 605 } }, + 'Arena 9' : { 'id': 'arena-9', 'collection_win': { 'bronze': 120, 'silver': 240, 'gold': 420, 'legendary': 660 } }, + 'Arena 10' : { 'id': 'arena-10', 'collection_win': { 'bronze': 130, 'silver': 260, 'gold': 455, 'legendary': 715 } }, + 'Arena 11' : { 'id': 'arena-11', 'collection_win': { 'bronze': 140, 'silver': 280, 'gold': 490, 'legendary': 770 } }, + 'Arena 12' : { 'id': 'arena-12', 'collection_win': { 'bronze': 150, 'silver': 300, 'gold': 525, 'legendary': 825 } }, + 'Arena 13' : { 'id': 'arena-13', 'collection_win': { 'bronze': 150, 'silver': 300, 'gold': 525, 'legendary': 825 } }, + 'League 1' : { 'id': 'challenger-1', 'collection_win': { 'bronze': 160, 'silver': 320, 'gold': 560, 'legendary': 880 } }, + 'League 2' : { 'id': 'challenger-2', 'collection_win': { 'bronze': 160, 'silver': 320, 'gold': 560, 'legendary': 880 } }, + 'League 3' : { 'id': 'challenger-3', 'collection_win': { 'bronze': 160, 'silver': 320, 'gold': 560, 'legendary': 880 } }, + 'League 4' : { 'id': 'master-1', 'collection_win': { 'bronze': 170, 'silver': 340, 'gold': 595, 'legendary': 935 } }, + 'League 5' : { 'id': 'master-2', 'collection_win': { 'bronze': 170, 'silver': 340, 'gold': 595, 'legendary': 935 } }, + 'League 6' : { 'id': 'master-3', 'collection_win': { 'bronze': 170, 'silver': 340, 'gold': 595, 'legendary': 935 } }, + 'League 7' : { 'id': 'champion', 'collection_win': { 'bronze': 180, 'silver': 360, 'gold': 630, 'legendary': 990 } }, + 'League 8' : { 'id': 'grand-champion', 'collection_win': { 'bronze': 180, 'silver': 360, 'gold': 630, 'legendary': 990 } }, + 'League 9' : { 'id': 'ultimate-champion', 'collection_win': { 'bronze': 180, 'silver': 360, 'gold': 630, 'legendary': 990 } } } WAR_LEAGUE_LOOKUP = { @@ -119,7 +121,10 @@ def member_war(config, clan_member, clan, war): participation['warLeague'] = get_war_league_from_war(war, clan['tag'])['id'] - league_lookup = ARENA_LEAGUE_LOOKUP[clan_member['arena']['name']] + if clan_member['arena']['name'] in ARENA_LEAGUE_LOOKUP: + league_lookup = ARENA_LEAGUE_LOOKUP[clan_member['arena']['name']] + else: + league_lookup = ARENA_LEAGUE_LOOKUP['Arena Unknown'] collection_win_lookup = league_lookup['collection_win'] cardsPerCollectionBattleWin = collection_win_lookup[participation['warLeague']] @@ -206,7 +211,6 @@ def get_suggestions(config, members): # if we're above the minimum clan size, recommend kicking # poorly participating member. Otherwise, if member is # an Elder or higher, recommend demotion. - debug_out(config, "member #{} {} below threshold".format(index, member['name'])) if index <= len(members_by_score) - config['score']['min_clan_size']: suggestion = 'Kick {} {}'.format(member['name'], member['score']) debug_out(config, suggestion) @@ -327,6 +331,8 @@ def process_members(config, clan, warlog, current_war): if member['arena']['name'] in ARENA_LEAGUE_LOOKUP: member['arenaLeague'] = ARENA_LEAGUE_LOOKUP[member['arena']['name']]['id'] + else: + member['arenaLeague'] = ARENA_LEAGUE_LOOKUP['Arena Unknown']['id'] # Figure out whether member is on the leadership team by role if member['role'] == 'leader' or member['role'] == 'coLeader':