From 282ab6da72c3eabfac5fc6ea1de418eef1a804d9 Mon Sep 17 00:00:00 2001 From: LmeSzinc <37934724+LmeSzinc@users.noreply.github.com> Date: Mon, 12 Feb 2024 23:29:21 +0800 Subject: [PATCH] Chore: _dungeon_nav_goto now receive nav input --- module/ocr/keyword.py | 2 +- tasks/dungeon/dungeon.py | 6 +++--- tasks/dungeon/ui.py | 22 +++++++++++----------- tasks/dungeon/weekly.py | 4 ++-- tasks/forgotten_hall/ui.py | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/module/ocr/keyword.py b/module/ocr/keyword.py index e285674f2..3593b1d46 100644 --- a/module/ocr/keyword.py +++ b/module/ocr/keyword.py @@ -7,7 +7,7 @@ import module.config.server as server from module.exception import ScriptError # ord('.') = 65294 -REGEX_PUNCTUATION = re.compile(r'[ ,..\'"“”,。…::;;!!??·・•●〇*※\-—-/\\\n\t()\[\]()「」『』【】《》[]]') +REGEX_PUNCTUATION = re.compile(r'[ ,..\'"“”,。…::;;!!??·・•●〇°*※\-—-/\\\n\t()\[\]()「」『』【】《》[]]') def parse_name(n): diff --git a/tasks/dungeon/dungeon.py b/tasks/dungeon/dungeon.py index 20d0c5081..6c7e5a60a 100644 --- a/tasks/dungeon/dungeon.py +++ b/tasks/dungeon/dungeon.py @@ -4,7 +4,7 @@ from tasks.battle_pass.keywords import KEYWORDS_BATTLE_PASS_QUEST from tasks.combat.combat import Combat from tasks.daily.keywords import KEYWORDS_DAILY_QUEST from tasks.dungeon.event import DungeonEvent -from tasks.dungeon.keywords import DungeonList, KEYWORDS_DUNGEON_LIST, KEYWORDS_DUNGEON_TAB +from tasks.dungeon.keywords import DungeonList, KEYWORDS_DUNGEON_LIST, KEYWORDS_DUNGEON_NAV, KEYWORDS_DUNGEON_TAB from tasks.dungeon.stamina import DungeonStamina @@ -211,10 +211,10 @@ class Dungeon(DungeonStamina, DungeonEvent, Combat): if self.has_double_rogue_event(): rogue = self.get_double_event_remain() if self.has_double_calyx_event(): - self._dungeon_nav_goto(KEYWORDS_DUNGEON_LIST.Calyx_Golden_Treasures_Jarilo_VI) + self._dungeon_nav_goto(KEYWORDS_DUNGEON_NAV.Calyx_Golden) calyx = self.get_double_event_remain() if self.has_double_relic_event(): - self._dungeon_nav_goto(KEYWORDS_DUNGEON_LIST.Cavern_of_Corrosion_Path_of_Gelid_Wind) + self._dungeon_nav_goto(KEYWORDS_DUNGEON_NAV.Cavern_of_Corrosion) relic = self.get_double_event_remain() with self.config.multi_set(): self.config.stored.DungeonDouble.calyx = calyx diff --git a/tasks/dungeon/ui.py b/tasks/dungeon/ui.py index 22b3aeb4f..ba0a14e11 100644 --- a/tasks/dungeon/ui.py +++ b/tasks/dungeon/ui.py @@ -351,17 +351,17 @@ class DungeonUI(DungeonState): logger.info('No Echo_of_War in list skip waiting') return False - def _dungeon_nav_goto(self, dungeon: DungeonList, skip_first_screenshot=True): + def _dungeon_nav_goto(self, nav: DungeonNav, skip_first_screenshot=True): """ Equivalent to `DUNGEON_NAV_LIST.select_row(dungeon.dungeon_nav, main=self)` but with tricks to be faster Args: - dungeon: + nav: skip_first_screenshot: """ logger.hr('Dungeon nav goto', level=2) - logger.info(f'Dungeon nav goto {dungeon.dungeon_nav}') + logger.info(f'Dungeon nav goto {nav}') # Wait rows while 1: @@ -402,11 +402,11 @@ class DungeonUI(DungeonState): else: # To start from any list states. logger.info('DUNGEON_NAV_LIST not at top') - DUNGEON_NAV_LIST.select_row(dungeon.dungeon_nav, main=self) + DUNGEON_NAV_LIST.select_row(nav, main=self) return True # Check the first page - if dungeon.dungeon_nav in [ + if nav in [ KEYWORDS_DUNGEON_NAV.Simulated_Universe, KEYWORDS_DUNGEON_NAV.Calyx_Golden, KEYWORDS_DUNGEON_NAV.Calyx_Crimson, @@ -415,9 +415,9 @@ class DungeonUI(DungeonState): KEYWORDS_DUNGEON_NAV.Forgotten_Hall, KEYWORDS_DUNGEON_NAV.Pure_Fiction, ]: - button = DUNGEON_NAV_LIST.keyword2button(dungeon.dungeon_nav) + button = DUNGEON_NAV_LIST.keyword2button(nav) if button: - DUNGEON_NAV_LIST.select_row(dungeon.dungeon_nav, main=self, insight=False) + DUNGEON_NAV_LIST.select_row(nav, main=self, insight=False) return True # Check the second page @@ -425,7 +425,7 @@ class DungeonUI(DungeonState): DUNGEON_NAV_LIST.drag_page('down', main=self) # No skip_first_screenshot since drag_page is just called if self._dungeon_wait_until_echo_or_war_stabled(skip_first_screenshot=False): - DUNGEON_NAV_LIST.select_row(dungeon.dungeon_nav, main=self, insight=False) + DUNGEON_NAV_LIST.select_row(nav, main=self, insight=False) return True def _dungeon_world_set(self, dungeon: DungeonList, skip_first_screenshot=True): @@ -636,7 +636,7 @@ class DungeonUI(DungeonState): if self.appear(SURVIVAL_INDEX_LOADED): logger.info('Already at nav Simulated_Universe') else: - self._dungeon_nav_goto(KEYWORDS_DUNGEON_LIST.Simulated_Universe_World_1) + self._dungeon_nav_goto(KEYWORDS_DUNGEON_NAV.Simulated_Universe) def dungeon_goto(self, dungeon: DungeonList): """ @@ -662,13 +662,13 @@ class DungeonUI(DungeonState): or dungeon.is_Stagnant_Shadow \ or dungeon.is_Cavern_of_Corrosion \ or dungeon.is_Echo_of_War: - self._dungeon_nav_goto(dungeon) + self._dungeon_nav_goto(dungeon.dungeon_nav) self._dungeon_wait_until_dungeon_list_loaded() self._dungeon_insight(dungeon) self._dungeon_enter(dungeon) return True if dungeon.is_Calyx_Golden: - self._dungeon_nav_goto(dungeon) + self._dungeon_nav_goto(dungeon.dungeon_nav) self._dungeon_wait_until_dungeon_list_loaded() self._dungeon_world_set_wrapper(dungeon) self._dungeon_wait_until_dungeon_list_loaded() diff --git a/tasks/dungeon/weekly.py b/tasks/dungeon/weekly.py index d0f1962bf..a5d549065 100644 --- a/tasks/dungeon/weekly.py +++ b/tasks/dungeon/weekly.py @@ -3,7 +3,7 @@ from module.ocr.ocr import DigitCounter from tasks.daily.keywords import KEYWORDS_DAILY_QUEST from tasks.dungeon.assets.assets_dungeon_ui import OCR_DUNGEON_LIST, OCR_WEEKLY_LIMIT from tasks.dungeon.dungeon import Dungeon -from tasks.dungeon.keywords import DungeonList, KEYWORDS_DUNGEON_TAB +from tasks.dungeon.keywords import DungeonList, KEYWORDS_DUNGEON_NAV, KEYWORDS_DUNGEON_TAB from tasks.dungeon.ui import DUNGEON_LIST @@ -53,7 +53,7 @@ class WeeklyDungeon(Dungeon): self.dungeon_tab_goto(KEYWORDS_DUNGEON_TAB.Survival_Index) # Equivalent to self.dungeon_goto(dungeon), but check limit remains DUNGEON_LIST.search_button = OCR_DUNGEON_LIST - self._dungeon_nav_goto(dungeon) + self._dungeon_nav_goto(KEYWORDS_DUNGEON_NAV.Echo_of_War) # Check limit remain = self.get_weekly_remain() diff --git a/tasks/forgotten_hall/ui.py b/tasks/forgotten_hall/ui.py index 595e4ea6d..a07c08753 100644 --- a/tasks/forgotten_hall/ui.py +++ b/tasks/forgotten_hall/ui.py @@ -10,7 +10,7 @@ from module.ocr.keyword import Keyword from module.ocr.ocr import Ocr, OcrResultButton from module.ui.draggable_list import DraggableList from tasks.base.assets.assets_base_page import FORGOTTEN_HALL_CHECK, MAP_EXIT -from tasks.dungeon.keywords import DungeonList, KEYWORDS_DUNGEON_LIST, KEYWORDS_DUNGEON_TAB +from tasks.dungeon.keywords import DungeonList, KEYWORDS_DUNGEON_LIST, KEYWORDS_DUNGEON_NAV, KEYWORDS_DUNGEON_TAB from tasks.dungeon.ui import DungeonUI from tasks.forgotten_hall.assets.assets_forgotten_hall_nav import * from tasks.forgotten_hall.assets.assets_forgotten_hall_ui import * @@ -187,7 +187,7 @@ class ForgottenHallUI(DungeonUI, ForgottenHallTeam): logger.info('Already in forgotten hall') else: self.dungeon_tab_goto(KEYWORDS_DUNGEON_TAB.Treasures_Lightward) - self._dungeon_nav_goto(dungeon) + self._dungeon_nav_goto(KEYWORDS_DUNGEON_NAV.Forgotten_Hall) self.stage_choose(dungeon) logger.info(f'Stage list select: {stage_keyword}')