From 58f2793b408104cbf64a770eaeb2470ff1c093ce Mon Sep 17 00:00:00 2001 From: hsahovic <25432355+hsahovic@users.noreply.github.com> Date: Tue, 11 Apr 2023 01:08:50 +0200 Subject: [PATCH] Fix active pokemon issue when not all mons are selected in team-preview --- src/poke_env/environment/abstract_battle.py | 2 ++ src/poke_env/environment/pokemon.py | 3 +++ unit_tests/test_data.py | 1 - 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/poke_env/environment/abstract_battle.py b/src/poke_env/environment/abstract_battle.py index 4a85bc484..d45fca2c9 100644 --- a/src/poke_env/environment/abstract_battle.py +++ b/src/poke_env/environment/abstract_battle.py @@ -656,6 +656,8 @@ def _parse_message(self, split_message: List[str]) -> None: self.get_pokemon(pokemon)._used_z_move() elif split_message[1] == "clearpoke": self._in_team_preview = True + for mon in self.team.values(): + mon._clear_active() elif split_message[1] == "gen": self._format = split_message[2] elif split_message[1] == "inactive": diff --git a/src/poke_env/environment/pokemon.py b/src/poke_env/environment/pokemon.py index acb166374..8380fcc49 100644 --- a/src/poke_env/environment/pokemon.py +++ b/src/poke_env/environment/pokemon.py @@ -154,6 +154,9 @@ def _cant_move(self): if self._status == Status.SLP: self._status_counter += 1 + def _clear_active(self): + self._active = False + def _clear_boosts(self): for stat in self._boosts: self._boosts[stat] = 0 diff --git a/unit_tests/test_data.py b/unit_tests/test_data.py index f1e11c673..76a019a4a 100644 --- a/unit_tests/test_data.py +++ b/unit_tests/test_data.py @@ -1,4 +1,3 @@ - import pytest from poke_env.data import GenData from poke_env.environment import PokemonType