Skip to content

Commit a4ff5c0

Browse files
committed
fix: spell lookup needs village flag
1 parent d675ed6 commit a4ff5c0

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

coc/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2413,7 +2413,7 @@ def get_spell(self, name: str, level: int = None, townhall: int = None) -> Optio
24132413
if not self._spell_holder.loaded:
24142414
raise RuntimeError("Spell metadata must be loaded to use this feature.")
24152415

2416-
spell = self._spell_holder.get(name)
2416+
spell = self._spell_holder.get((name, True))
24172417
if spell is None:
24182418
return None
24192419
elif level is not None:

coc/spell.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,14 @@ def _load_json(self, english_aliases, lab_to_townhall):
158158
self.item_lookup[(new_spell.name, new_spell._is_home_village)] = new_spell
159159

160160
self.loaded = True
161+
162+
def load(self, data, townhall: int, default: "Spell" = Spell, load_game_data: bool = None) -> Spell:
163+
if load_game_data is True:
164+
try:
165+
spell = self.item_lookup[(data["name"], True)]
166+
except KeyError:
167+
spell = default
168+
else:
169+
spell = default
170+
171+
return spell(data=data, townhall=townhall)

0 commit comments

Comments
 (0)