Skip to content

Commit 15b39bf

Browse files
committed
Add headhunter and new siege machines, and futureproof the ordered_ design
1 parent 30dfada commit 15b39bf

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

coc/enums.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ def in_game_name(self):
9393
"Lava Hound",
9494
"Bowler",
9595
"Ice Golem",
96+
"Headhunter",
9697
]
9798

9899
SIEGE_MACHINE_ORDER = [
@@ -103,10 +104,14 @@ def in_game_name(self):
103104
]
104105

105106
SUPER_TROOP_ORDER = [
106-
"Sneaky Goblin",
107107
"Super Barbarian",
108-
"Super Wall Breaker",
109108
"Super Giant",
109+
"Sneaky Goblin",
110+
"Super Wall Breaker",
111+
"Inferno Dragon",
112+
"Super Witch",
113+
"Super Archer", # not added yet but they're in the API payload for some reason
114+
"Super Valkyrie", # not added yet but they're in the API payload for some reason
110115
]
111116

112117
HOME_TROOP_ORDER = ELIXIR_TROOP_ORDER + SUPER_TROOP_ORDER + DARK_ELIXIR_TROOP_ORDER + SIEGE_MACHINE_ORDER
@@ -171,17 +176,19 @@ def in_game_name(self):
171176
"Treasurer",
172177
"Anti-Artillery",
173178
"Sharing is caring",
179+
"Games Champion",
180+
"Get those other Goblins!",
181+
"Dragon Slayer",
182+
"War League Legend",
174183
"Keep your village safe",
184+
"Well Seasoned",
185+
"Shattered and Scattered",
175186
"Master Engineering",
176187
"Next Generation Model",
177188
"Un-Build It",
178189
"Champion Builder",
179190
"High Gear",
180191
"Hidden Treasures",
181-
"Games Champion",
182-
"Dragon Slayer",
183-
"War League Legend",
184-
"Keep your village safe",
185192
]
186193

187194
UNRANKED_LEAGUE_DATA = {

coc/players.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def get_ordered_troops(self, valid_troops):
447447
"""
448448
troops_dict = {t.name: t for t in self.troops if t.name in set(valid_troops)}
449449
key_order = {k: v for v, k in enumerate(valid_troops)}
450-
return OrderedDict(sorted(troops_dict.items(), key=lambda i: key_order.get(i[0])))
450+
return OrderedDict(sorted(troops_dict.items(), key=lambda i: key_order.get(i[0], 0)))
451451

452452
@property
453453
def ordered_home_troops(self):
@@ -456,7 +456,7 @@ def ordered_home_troops(self):
456456
This will return troops in the order found in both barracks and labatory in-game.
457457
"""
458458
key_order = {k: v for v, k in enumerate(HOME_TROOP_ORDER)}
459-
return OrderedDict(sorted(self.home_troops_dict.items(), key=lambda i: key_order.get(i[0])))
459+
return OrderedDict(sorted(self.home_troops_dict.items(), key=lambda i: key_order.get(i[0], 0)))
460460

461461
@property
462462
def ordered_super_troops(self):
@@ -465,7 +465,7 @@ def ordered_super_troops(self):
465465
This will return super troops in the order found in game.
466466
"""
467467
key_order = {k: v for v, k in enumerate(SUPER_TROOP_ORDER)}
468-
return OrderedDict(sorted(self.super_troops_dict.items(), key=lambda i: key_order.get(i[0])))
468+
return OrderedDict(sorted(self.super_troops_dict.items(), key=lambda i: key_order.get(i[0], 0)))
469469

470470
@property
471471
def ordered_builder_troops(self):
@@ -474,7 +474,7 @@ def ordered_builder_troops(self):
474474
This will return troops in the order found in both barracks and labatory in-game.
475475
"""
476476
key_order = {k: v for v, k in enumerate(BUILDER_TROOPS_ORDER)}
477-
return OrderedDict(sorted(self.builder_troops_dict.items(), key=lambda i: key_order.get(i[0])))
477+
return OrderedDict(sorted(self.builder_troops_dict.items(), key=lambda i: key_order.get(i[0], 0)))
478478

479479
@property
480480
def ordered_siege_machines(self):
@@ -483,7 +483,7 @@ def ordered_siege_machines(self):
483483
This will return siege machines in the order found in both barracks and labatory in-game.
484484
"""
485485
key_order = {k: v for v, k in enumerate(SIEGE_MACHINE_ORDER)}
486-
return OrderedDict(sorted(self.siege_machines_dict.items(), key=lambda i: key_order.get(i[0])))
486+
return OrderedDict(sorted(self.siege_machines_dict.items(), key=lambda i: key_order.get(i[0], 0)))
487487

488488
@property
489489
def ordered_spells(self):
@@ -492,7 +492,7 @@ def ordered_spells(self):
492492
This will return spells in the order found in both spell factory and labatory in-game.
493493
"""
494494
key_order = {k: v for v, k in enumerate(SPELL_ORDER)}
495-
return OrderedDict(sorted(self.spells_dict.items(), key=lambda i: key_order.get(i[0])))
495+
return OrderedDict(sorted(self.spells_dict.items(), key=lambda i: key_order.get(i[0], 0)))
496496

497497
@property
498498
def ordered_heroes(self):
@@ -501,7 +501,7 @@ def ordered_heroes(self):
501501
This will return heroes in the order found in the labatory in-game.
502502
"""
503503
key_order = {k: v for v, k in enumerate(HERO_ORDER)}
504-
return OrderedDict(sorted(self.heroes_dict.items(), key=lambda i: key_order.get(i[0])))
504+
return OrderedDict(sorted(self.heroes_dict.items(), key=lambda i: key_order.get(i[0], 0)))
505505

506506

507507
class LeaguePlayer(EqualityComparable):

0 commit comments

Comments
 (0)