Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added correct handling for pledge moves #637

Merged
merged 2 commits into from
Nov 18, 2024
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
2 changes: 2 additions & 0 deletions src/poke_env/environment/abstract_battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ def parse_message(self, split_message: List[str]):
reveal_other_move = True
elif override_move in {"Copycat", "Metronome", "Nature Power"}:
pass
elif override_move in {"Grass Pledge", "Water Pledge", "Fire Pledge"}:
override_move = None
elif self.logger is not None:
self.logger.warning(
"Unmanaged [from]move message received - move %s in cleaned up "
Expand Down
32 changes: 32 additions & 0 deletions unit_tests/environment/test_double_battle.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,35 @@ def test_gen_and_format(example_doubles_logs):
assert battle.gen == 6
assert battle.battle_tag == "tag"
assert battle.format == "gen6doublesou"


def test_pledge_moves():
battle = DoubleBattle("tag", "username", MagicMock(), gen=8)
battle.player_role = "p2"

events = [
["", "switch", "p1a: Indeedee", "Indeedee-F, L50, F", "100/100"],
["", "switch", "p1b: Hatterene", "Hatterene, L50, F", "100/100"],
["", "switch", "p2a: Primarina", "Primarina, L50, F, shiny", "169/169"],
["", "switch", "p2b: Decidueye", "Decidueye-Hisui, L50, F, shiny", "171/171"],
["", ""],
["", "move", "p2b: Decidueye", "Grass Pledge", "p1a: Indeedee"],
["", "-waiting", "p2b: Decidueye", "p2a: Primarina"],
[
"",
"move",
"p2a: Primarina",
"Water Pledge",
"p1b: Hatterene",
"[from]move: Grass Pledge",
],
["", "-combine"],
["", "-damage", "p1b: Hatterene", "0 fnt"],
["", "-sidestart", "p1: cloverspsyspamsep", "Grass Pledge"],
]

for event in events:
battle.parse_message(event)

assert "grasspledge" not in battle.team["p2: Primarina"].moves
assert "waterpledge" in battle.team["p2: Primarina"].moves
Loading