diff --git a/src/poke_env/environment/abstract_battle.py b/src/poke_env/environment/abstract_battle.py index c5c4b9a43..908cfd60a 100644 --- a/src/poke_env/environment/abstract_battle.py +++ b/src/poke_env/environment/abstract_battle.py @@ -365,7 +365,7 @@ def _finish_battle(self) -> None: self._finished = True - def _parse_message(self, split_message: List[str]) -> None: # pyre-ignore + def _parse_message(self, split_message: List[str]) -> None: if self._save_replays: self._replay_data.append(split_message) @@ -584,8 +584,8 @@ def _parse_message(self, split_message: List[str]) -> None: # pyre-ignore pokemon, item = split_message[2:4] self.get_pokemon(pokemon).item = to_id_str(item) elif split_message[1] == "-mega": - if not split_message[2].startswith(self._player_role): - self._opponent_can_mega_evolve = False + if not split_message[2].startswith(self._player_role): # pyre-ignore + self._opponent_can_mega_evolve = False # pyre-ignore pokemon, megastone = split_message[2:4] self.get_pokemon(pokemon)._mega_evolve(megastone) elif split_message[1] == "-mustrecharge": @@ -629,8 +629,8 @@ def _parse_message(self, split_message: List[str]) -> None: # pyre-ignore pokemon, into = split_message[2:4] self.get_pokemon(pokemon)._transform(self.get_pokemon(into)) elif split_message[1] == "-zpower": - if not split_message[2].startswith(self._player_role): - self._opponent_can_mega_z_move = False + if not split_message[2].startswith(self._player_role): # pyre-ignore + self._opponent_can_mega_z_move = False # pyre-ignore pokemon = split_message[2] self.get_pokemon(pokemon)._used_z_move() diff --git a/src/poke_env/environment/battle.py b/src/poke_env/environment/battle.py index e0a915c34..4087f6df1 100644 --- a/src/poke_env/environment/battle.py +++ b/src/poke_env/environment/battle.py @@ -288,7 +288,7 @@ def opponent_can_z_move(self) -> bool: @opponent_can_z_move.setter def opponent_can_z_move(self, value: bool) -> None: - self._opponentcan_z_move = value + self._opponent_can_z_move = value @property def trapped(self) -> bool: diff --git a/src/poke_env/teambuilder/teambuilder.py b/src/poke_env/teambuilder/teambuilder.py index d69628876..acd630544 100644 --- a/src/poke_env/teambuilder/teambuilder.py +++ b/src/poke_env/teambuilder/teambuilder.py @@ -26,7 +26,7 @@ def yield_team(self) -> str: # pragma: no cover """Returns a packed-format team.""" @staticmethod - def parse_showdown_team(team: str) -> List[TeambuilderPokemon]: # pyre-ignore + def parse_showdown_team(team: str) -> List[TeambuilderPokemon]: """Converts a showdown-formatted team string into a list of TeambuilderPokemon objects. @@ -37,14 +37,15 @@ def parse_showdown_team(team: str) -> List[TeambuilderPokemon]: # pyre-ignore :return: The formatted team. :rtype: list of TeambuilderPokemon """ - current_mon = None + current_mon = TeambuilderPokemon() + current_mon_has_been_added = True mons = [] for line in team.split("\n"): if line == "": - if current_mon is not None: + if not current_mon_has_been_added: mons.append(current_mon) - current_mon = None + current_mon_has_been_added = True elif line.startswith("Ability"): ability = line.replace("Ability: ", "") current_mon.ability = ability.strip() @@ -87,6 +88,7 @@ def parse_showdown_team(team: str) -> List[TeambuilderPokemon]: # pyre-ignore current_mon.hiddenpowertype = hp_type else: current_mon = TeambuilderPokemon() + current_mon_has_been_added = False if "@" in line: mon_info, item = line.split(" @ ") current_mon.item = item.strip() @@ -108,7 +110,7 @@ def parse_showdown_team(team: str) -> List[TeambuilderPokemon]: # pyre-ignore break current_mon.nickname = " ".join(split_mon_info) current_mon.nickname = " ".join(split_mon_info) - if current_mon is not None: + if not current_mon_has_been_added: mons.append(current_mon) return mons