Skip to content

Commit

Permalink
Fixed breakage due to the addition of arena 13 in the lookup table. S…
Browse files Browse the repository at this point in the history
…hould be more resilient to future changes.
  • Loading branch information
AaronTraas committed Jan 28, 2019
1 parent 3c681d7 commit 1b03a31
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
2 changes: 1 addition & 1 deletion crtools/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.12.2"
__version__ = "1.13.0"
52 changes: 29 additions & 23 deletions crtools/crtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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']]

Expand Down Expand Up @@ -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 <strong>{}</strong> <strong class="bad">{}</strong>'.format(member['name'], member['score'])
debug_out(config, suggestion)
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit 1b03a31

Please sign in to comment.