From f4e24b39fc3ecde8388381bc2958bb213cbc0c17 Mon Sep 17 00:00:00 2001 From: Tino Date: Thu, 10 Oct 2024 04:03:38 +0700 Subject: [PATCH] Don't rotate lead in Level Grind mode if only lead is selected to be levelled (#427) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the user chooses the 'level lead only' option, we use the default battle strategy -- but depending on configuration, this might rotate the lead after a battle if the previous lead was too weak. This would mess up that mode because now a different Pokémon is being levelled. I've added a modified battle strategy for that. --- modules/modes/level_grind.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/modes/level_grind.py b/modules/modes/level_grind.py index 04becc58..0c02ffbc 100644 --- a/modules/modes/level_grind.py +++ b/modules/modes/level_grind.py @@ -47,6 +47,11 @@ } +class NoRotateLeadDefaultBattleStrategy(DefaultBattleStrategy): + def choose_new_lead_after_battle(self) -> int | None: + return None + + class LevelGrindMode(BotMode): @staticmethod def name() -> str: @@ -76,7 +81,7 @@ def on_battle_started(self, encounter: EncounterInfo | None) -> BattleAction | B if self._level_balance: return LevelBalancingBattleStrategy() else: - return DefaultBattleStrategy() + return NoRotateLeadDefaultBattleStrategy() else: return action