Skip to content

Commit

Permalink
Fix move chosing when Pokémon has no damage moves
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultLassiaz committed Nov 11, 2024
1 parent 88b218f commit b5df19d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion modules/battle_strategies/_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from modules.items import ItemHoldEffect, get_item_bag, get_item_by_name
from modules.memory import get_event_flag, read_symbol
from modules.pokemon import StatusCondition, get_type_by_name, get_ability_by_name
from modules.modes._interface import BotModeError

if TYPE_CHECKING:
from modules.battle_state import BattlePokemon, BattleState
Expand Down Expand Up @@ -235,15 +236,19 @@ def get_strongest_move_against(self, pokemon: "BattlePokemon", opponent: "Battle
move_strengths = []
for learned_move in pokemon.moves:
if learned_move.move.name in context.config.battle.banned_moves:
move_strengths.append(-1)
continue
move = learned_move.move
if learned_move.pp == 0 or pokemon.disabled_move is move:
move_strengths.append(-1)
else:
move_strengths.append(self.calculate_move_damage_range(move, pokemon, opponent).max)

strongest_move = move_strengths.index(max(move_strengths))
max_strength = max(move_strengths)
if max_strength <= 0:
raise BotModeError("No valid moves available! Check move setup or disable restrictions.")

strongest_move = move_strengths.index(max_strength)
return strongest_move

def _calculate_base_move_damage(
Expand Down

0 comments on commit b5df19d

Please sign in to comment.