diff --git a/module/os/fleet.py b/module/os/fleet.py index 26a41e4fb7..7fed196cff 100644 --- a/module/os/fleet.py +++ b/module/os/fleet.py @@ -528,6 +528,11 @@ def go_month_boss_room(self, is_normal=True): def question_goto(self, has_fleet_step=False): logger.hr('Question goto') while 1: + # A game bug that AUTO_SEARCH_REWARD from the last cleared zone popups + if self.appear_then_click(AUTO_SEARCH_REWARD, offset=(50, 50), interval=3): + self.device.screenshot() + continue + # Update local view # Not screenshots taking, reuse the old one self.update_os() diff --git a/module/os_handler/map_event.py b/module/os_handler/map_event.py index e347219102..3e909d5317 100644 --- a/module/os_handler/map_event.py +++ b/module/os_handler/map_event.py @@ -9,7 +9,16 @@ from module.statistics.azurstats import DropImage from module.ui.switch import Switch -fleet_lock = Switch('Fleet_Lock', offset=(10, 120)) + +class FleetLockSwitch(Switch): + def handle_additional(self, main): + # A game bug that AUTO_SEARCH_REWARD from the last cleared zone popups + if main.appear_then_click(AUTO_SEARCH_REWARD, offset=(50, 50), interval=3): + return True + return False + + +fleet_lock = FleetLockSwitch('Fleet_Lock', offset=(10, 120)) fleet_lock.add_status('on', check_button=OS_FLEET_LOCKED) fleet_lock.add_status('off', check_button=OS_FLEET_UNLOCKED) @@ -160,11 +169,14 @@ def handle_os_in_map(self): self._os_in_map_confirm_timer.reset() return False - def ensure_no_map_event(self): + def ensure_no_map_event(self, skip_first_screenshot=True): self._os_in_map_confirm_timer.reset() while 1: - self.device.screenshot() + if skip_first_screenshot: + skip_first_screenshot = False + else: + self.device.screenshot() if self.handle_map_event(): continue diff --git a/module/ui/switch.py b/module/ui/switch.py index 301bbc344a..a72b9f366a 100644 --- a/module/ui/switch.py +++ b/module/ui/switch.py @@ -96,6 +96,16 @@ def get_data(self, status): logger.warning(f'Switch {self.name} received an invalid status {status}') raise ScriptError(f'Switch {self.name} received an invalid status {status}') + def handle_additional(self, main): + """ + Args: + main (ModuleBase): + + Returns: + bool: If handled + """ + return False + def set(self, status, main, skip_first_screenshot=True): """ Args: @@ -122,6 +132,10 @@ def set(self, status, main, skip_first_screenshot=True): current = self.get(main=main) logger.attr(self.name, current) + # Handle additional popups + if self.handle_additional(main=main): + continue + # End if current == status: return changed diff --git a/submodule/AlasMaaBridge/maa.py b/submodule/AlasMaaBridge/maa.py index 79bb10f1ec..fdc8e7675b 100644 --- a/submodule/AlasMaaBridge/maa.py +++ b/submodule/AlasMaaBridge/maa.py @@ -49,6 +49,11 @@ def asst(self): self.config.task_stop() logger.info(f'MAA安装路径:{self.config.MaaEmulator_MaaPath}') + if not os.path.exists(self.config.MaaEmulator_MaaPath): + logger.critical( + f'未找到路径 {self.config.MaaEmulator_MaaPath},请确认MAA已安装在该路径。' + f'如果你是第一次使用MAA插件,需要自选安装MAA,并在 "MAA设置" - "MAA安装路径" 中填入MAA的安装路径') + raise RequestHumanTakeover try: incremental_path = [os.path.join(self.config.MaaEmulator_MaaPath, './cache')] if self.config.MaaEmulator_PackageName in ["YoStarEN", "YoStarJP", "YoStarKR", "txwy"]: @@ -63,7 +68,17 @@ def asst(self): AssistantHandler.load(self.config.MaaEmulator_MaaPath, incremental_path) except ModuleNotFoundError: logger.critical('找不到MAA,请检查安装路径是否正确') - exit(1) + raise RequestHumanTakeover + except OSError as e: + # OSError: [WinError 126] 找不到指定的模块。 + if '[WinError 126]' in str(e): + logger.exception(e) + logger.critical( + f'无法导入MAA,请确认MAA已正确安装在 {self.config.MaaEmulator_MaaPath}' + ) + raise RequestHumanTakeover + else: + raise @AssistantHandler.Asst.CallBackType def callback(msg, details, arg):