Skip to content

Commit

Permalink
Fix Pickup not being used in Level Grind mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hanzi committed Oct 3, 2024
1 parent 3cd8310 commit 594465f
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modules/battle_strategies/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def decide_turn_in_double_battle(self, battle_state: BattleState, battler_index:
def decide_turn_in_safari_zone(self, battle_state: BattleState) -> tuple["SafariTurnAction", any]:
return SafariTurnAction.switch_to_manual()

def _pokemon_has_enough_hp(self, pokemon: Pokemon):
def _pokemon_has_enough_hp(self, pokemon: Pokemon | BattlePokemon):
return pokemon.current_hp_percentage > context.config.battle.hp_threshold

def _get_usable_party_indices(self, battle_state: BattleState | None = None) -> list[int]:
Expand Down
2 changes: 1 addition & 1 deletion modules/battle_strategies/level_balancing.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def decide_turn(self, battle_state: BattleState) -> tuple["TurnAction", any]:
# in the most powerful Pokémon in the party to defeat the opponent, so that the
# lead Pokémon at least gets partial XP.
# This helps if the lead has a much lower level than the encounters.
if battler.party_index == 0 and battler.current_hp_percentage < context.config.battle.hp_threshold:
if battler.party_index == 0 and not self._pokemon_has_enough_hp(battler):
strongest_pokemon: tuple[int, int] = (0, 0)
party = get_party()
for index in range(len(party)):
Expand Down
1 change: 1 addition & 0 deletions modules/modes/_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def on_pickup_threshold_reached(self) -> bool:
:return: True to allow Pickup checking, False to prevent it.
"""
return True

def on_spotted_by_trainer(self) -> None:
"""
Expand Down
3 changes: 1 addition & 2 deletions modules/modes/level_grind.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Generator

from modules.battle_strategies import TurnAction
from modules.context import context
from modules.map import get_map_data_for_current_position, get_map_data
from modules.map_data import MapFRLG, MapRSE, PokemonCenter, get_map_enum
Expand All @@ -10,7 +9,7 @@
from modules.pokemon import get_party, get_opponent, StatusCondition
from ._interface import BotMode, BotModeError
from .util import navigate_to, heal_in_pokemon_center, change_lead_party_pokemon, spin
from ..battle_state import BattleOutcome, BattleState
from ..battle_state import BattleOutcome
from ..battle_strategies import BattleStrategy, DefaultBattleStrategy
from ..battle_strategies.level_balancing import LevelBalancingBattleStrategy
from ..encounter import handle_encounter
Expand Down

0 comments on commit 594465f

Please sign in to comment.