Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions src/poke_env/battle/abstract_battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,7 @@ def get_pokemon(

# if the pokemon has a nickname, this ensures we recognize it
name_det = details.split(", ")[0]
matches = [
i
for i, p in enumerate(team.values())
if p.base_species == to_id_str(name_det)
or p.base_species in [to_id_str(det) for det in name_det.split("-")]
]
matches = [i for i, p in enumerate(team.values()) if p.identifies_as(name_det)]
assert len(matches) < 2
if identifier not in team and matches:
i = matches[0]
Expand Down
5 changes: 5 additions & 0 deletions src/poke_env/battle/pokemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,11 @@ def heal(self, hp_status: str):
if self.fainted:
self._status = None

def identifies_as(self, ident: str) -> bool:
return self.base_species in to_id_str(ident) or self.base_species in [
to_id_str(substr) for substr in ident.split("-")
]

def invert_boosts(self):
self._boosts = {k: -v for k, v in self._boosts.items()}

Expand Down
3 changes: 2 additions & 1 deletion src/poke_env/player/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ async def _handle_battle_message(self, split_messages: List[List[str]]):
teambuilder_mon = [
m
for m in teambuilder_team
if preview_mon.base_species in to_id_str(m.nickname)
if m.nickname is not None
and preview_mon.identifies_as(m.nickname)
][0]
mon = battle.get_pokemon(
f"{role}: {teambuilder_mon.nickname}",
Expand Down
Loading