From 0339b1c8526866be303f40154febe9f6de480cd5 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Tue, 2 Jul 2024 05:29:16 +0800 Subject: [PATCH] Fix: Ornament scheduling --- tasks/dungeon/dungeon.py | 4 ++-- tasks/ornament/combat.py | 21 ++++++++++++++++++--- tasks/ornament/ornament.py | 14 +++++++++++--- tasks/rogue/entry/entry.py | 5 +++++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/tasks/dungeon/dungeon.py b/tasks/dungeon/dungeon.py index a38c0a1fb..6969a4fe4 100644 --- a/tasks/dungeon/dungeon.py +++ b/tasks/dungeon/dungeon.py @@ -203,7 +203,7 @@ class Dungeon(DungeonStamina, DungeonEvent, Combat): elif require and not self.support_once: # Run with support all the way - return self._dungeon_run(dungeon=dungeon, team=team, wave_limit=1, + return self._dungeon_run(dungeon=dungeon, team=team, wave_limit=0, support_character=self.config.DungeonSupport_Character) else: @@ -281,7 +281,7 @@ class Dungeon(DungeonStamina, DungeonEvent, Combat): # Dungeon to clear all trailblaze power do_rogue = False - if self.config.is_task_enabled('Rogue'): + if self.config.is_task_enabled('Rogue') and not self.config.is_task_enabled('Ornament'): if self.config.cross_get('Rogue.RogueWorld.UseStamina'): logger.info('Going to use stamina in rogue') do_rogue = True diff --git a/tasks/ornament/combat.py b/tasks/ornament/combat.py index 37c434003..3903efb33 100644 --- a/tasks/ornament/combat.py +++ b/tasks/ornament/combat.py @@ -19,6 +19,10 @@ class OrnamentCombat(Dungeon, RouteLoader, DungeonState): # Enter from survival index instead pass + def _combat_should_reenter(self): + # Never re-enter, can only enter from Survival_Index + return False + def get_double_event_remain_at_combat(self, button=OCR_DOUBLE_EVENT_REMAIN_AT_OE): # Different position to OCR return super().get_double_event_remain_at_combat(button) @@ -100,10 +104,16 @@ class OrnamentCombat(Dungeon, RouteLoader, DungeonState): else: self._search_support(support_character_name) # Search support selected_support = True - self.device.click(OCR_DOUBLE_EVENT_REMAIN_AT_OE) + self.device.click(SUPPORT_ADD) self.interval_reset(COMBAT_SUPPORT_LIST) continue + def get_equivalent_stamina(self): + value = self.config.stored.Immersifier.value * 40 + if self.config.Ornament_UseStamina: + value += self.config.stored.TrailblazePower.value + return value + def combat_get_trailblaze_power(self, expect_reduce=False, skip_first_screenshot=True) -> int: """ Args: @@ -116,12 +126,12 @@ class OrnamentCombat(Dungeon, RouteLoader, DungeonState): Pages: in: COMBAT_PREPARE or COMBAT_REPEAT """ - before = self.config.stored.TrailblazePower.value + self.config.stored.Immersifier.value * 40 + before = self.get_equivalent_stamina() after = before for _ in range(3): self.dungeon_update_stamina() - after = self.config.stored.TrailblazePower.value + self.config.stored.Immersifier.value * 40 + after = self.get_equivalent_stamina() if expect_reduce: if before > after: break @@ -130,6 +140,11 @@ class OrnamentCombat(Dungeon, RouteLoader, DungeonState): return after + def is_trailblaze_power_exhausted(self): + flag = self.get_equivalent_stamina() < self.combat_wave_cost + logger.attr('TrailblazePowerExhausted', flag) + return flag + def is_team_prepared(self) -> bool: """ Pages: diff --git a/tasks/ornament/ornament.py b/tasks/ornament/ornament.py index 6b998dd1d..1d94fb35f 100644 --- a/tasks/ornament/ornament.py +++ b/tasks/ornament/ornament.py @@ -56,6 +56,14 @@ class Ornament(OrnamentCombat): return result + def delay_dungeon_task(self, dungeon: DungeonList): + with self.config.multi_set(): + super().delay_dungeon_task(dungeon) + if not self.config.Ornament_UseStamina and self.config.stored.DungeonDouble.rogue <= 0: + if self.config.stored.Immersifier.value <= 0: + logger.info('Immersifier exhausted') + self.config.task_delay(server_update=True) + def run(self): self.config.update_battle_pass_quests() self.config.update_daily_quests() @@ -79,6 +87,7 @@ class Ornament(OrnamentCombat): # Run dungeon = DungeonList.find(self.config.Ornament_Dungeon) + self.support_once = False self.combat_wave_cost = 40 self.dungeon = dungeon if self.config.Ornament_UseStamina: @@ -91,9 +100,8 @@ class Ornament(OrnamentCombat): self.running_double = True self.dungeon_run(dungeon, wave_limit=self.config.stored.DungeonDouble.rogue) self.running_double = False - - self.config.task_delay(server_update=True) + self.dungeon_stamina_delay(dungeon) else: # Use immersifier only, wave limited in _dungeon_wait_until_dungeon_list_loaded self.dungeon_run(dungeon, wave_limit=0) - self.config.task_delay(server_update=True) + self.dungeon_stamina_delay(dungeon) diff --git a/tasks/rogue/entry/entry.py b/tasks/rogue/entry/entry.py index 93a9e14f4..2f89e6b64 100644 --- a/tasks/rogue/entry/entry.py +++ b/tasks/rogue/entry/entry.py @@ -353,6 +353,8 @@ class RogueEntry(RouteBase, RogueRewardHandler, RoguePathHandler, DungeonRogueUI f'RogueWorld_DoubleEvent={self.config.RogueWorld_DoubleEvent}, ' f'RogueWorld_WeeklyFarming={self.config.RogueWorld_WeeklyFarming}, ' f'RogueDebug_DebugMode={self.config.RogueDebug_DebugMode}') + ornament = self.config.is_task_enabled('Ornament') + logger.info(f'Ornament: {ornament}') # This shouldn't happen if self.config.RogueWorld_UseStamina and not self.config.RogueWorld_UseImmersifier: logger.error('Invalid rogue reward settings') @@ -376,6 +378,9 @@ class RogueEntry(RouteBase, RogueRewardHandler, RoguePathHandler, DungeonRogueUI if self.config.RogueWorld_UseImmersifier and self.config.stored.Immersifier.value > 0: logger.info( 'Reached weekly point limit but still have immersifiers left, continue to use them') + if ornament: + logger.info('Ornament enabled, skip farming rogue') + raise RogueReachedWeeklyPointLimit elif self.config.RogueWorld_WeeklyFarming and not self.config.stored.SimulatedUniverseFarm.is_full(): logger.info( 'Reached weekly point limit but still continue to farm materials')