Skip to content

Commit

Permalink
Don't do battle_modifier checks if battle.request_json hasn't been se…
Browse files Browse the repository at this point in the history
…t yet.

Discovered when addressing #194.
  • Loading branch information
pmariglia committed Jul 5, 2024
1 parent b906991 commit 8db271a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions showdown/battle_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ def check_speed_ranges(battle, msg_lines):
- Grassy Glide is used when Grassy Terrain is up
"""
# If either side switched this turn - don't do this check
if any(ln.startswith("|switch|") for ln in msg_lines):
if any(ln.startswith("|switch|") for ln in msg_lines) or not battle.request_json:
return

moves = [get_move_information(m) for m in msg_lines if m.startswith('|move|')]
Expand Down Expand Up @@ -901,7 +901,7 @@ def check_speed_ranges(battle, msg_lines):

def check_choicescarf(battle, msg_lines):
# If either side switched this turn - don't do this check
if any(ln.startswith("|switch|") for ln in msg_lines):
if any(ln.startswith("|switch|") for ln in msg_lines) or not battle.request_json:
return

moves = [get_move_information(m) for m in msg_lines if m.startswith('|move|')]
Expand Down Expand Up @@ -982,7 +982,8 @@ def check_choice_band_or_specs(battle, damage_dealt):
damage_dealt.crit or
damage_dealt.move in constants.WEIGHT_BASED_MOVES or
damage_dealt.move in constants.SPEED_BASED_MOVES or
not battle.opponent.active.can_have_choice_item
not battle.opponent.active.can_have_choice_item or
not battle.request_json
):
return

Expand Down

0 comments on commit 8db271a

Please sign in to comment.