diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index 13213598..fa4be4ea 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -444,8 +444,6 @@ def plan_metadata(self): _name = dorm.name if _name == "": continue - if self.op_data.operators[dorm.name].operator_type != "high": - continue # 如果是rest in full,则新增单独任务.. if ( _name in self.op_data.operators.keys() @@ -592,14 +590,14 @@ def plan_metadata(self): def should_keep(task): if task.type != TaskTypes.RELEASE_DORM: return True + elif len(task.plan) == 0: + return False name = task.meta_data - for key, value in task.plan.items(): - dorm_name = key - dorm_op = value - break + free_room = list(task.plan.keys())[0] + free_op = task.plan[free_room] if ( - self.op_data.operators[name].current_room != dorm_name - or dorm_op[self.op_data.operators[name].current_index] != "Free" + self.op_data.operators[name].current_room != free_room + or free_op[self.op_data.operators[name].current_index] != "Free" ): logger.info(f"检测到{task.meta_data}不在对应位置,移除相关任务") return False diff --git a/arknights_mower/utils/graph.py b/arknights_mower/utils/graph.py index 7a243113..47b53d1f 100644 --- a/arknights_mower/utils/graph.py +++ b/arknights_mower/utils/graph.py @@ -431,7 +431,9 @@ class SceneGraphSolver(BaseSolver): def scene_graph_navigation(self, scene: int): if scene not in DG.nodes: logger.error(f"{SceneComment[scene]}不在场景图中") - return False + return + + error_count = 0 while (current := self.scene()) != scene: if current in self.waiting_scene: @@ -453,7 +455,7 @@ def scene_graph_navigation(self, scene: int): self.device.start_droidcast() if config.conf.touch_method == "scrcpy": self.device.control.scrcpy = Scrcpy(self.device.client) - return False + return logger.debug(sp) @@ -462,11 +464,12 @@ def scene_graph_navigation(self, scene: int): try: transition(self) + error_count = 0 except MowerExit: raise except Exception as e: logger.exception(f"场景转移异常:{e}") - restart_simulator() + """restart_simulator() self.device.client.check_server_alive() Session().connect(config.conf.adb) if config.conf.droidcast.enable: @@ -475,7 +478,22 @@ def scene_graph_navigation(self, scene: int): self.device.control.scrcpy = Scrcpy(self.device.client) self.check_current_focus() return False - return True + return True""" + if error_count <= 5: + self.sleep() + error_count += 1 + continue + if restart_simulator(): + self.device.client.check_server_alive() + Session().connect(config.conf.adb) + if config.conf.droidcast.enable: + self.device.start_droidcast() + if config.conf.touch_method == "scrcpy": + self.device.control.scrcpy = Scrcpy(self.device.client) + self.check_current_focus() + else: + self.restart_game() + error_count = 0 def back_to_index(self): logger.info("场景图导航:back_to_index") diff --git a/arknights_mower/utils/scheduler_task.py b/arknights_mower/utils/scheduler_task.py index 912ee0a1..a3b18c07 100644 --- a/arknights_mower/utils/scheduler_task.py +++ b/arknights_mower/utils/scheduler_task.py @@ -289,7 +289,7 @@ def merge_release_dorm(tasks, merge_interval): if last_not_release is not None: continue elif task.time + timedelta(minutes=merge_interval) > tasks[-idx + 1].time: - task.time = tasks[-idx + 1].time + timedelta(seconds=1) + tasks[-idx].time = tasks[-idx + 1].time + timedelta(seconds=1) tasks[-idx], tasks[-idx + 1] = ( tasks[-idx + 1], tasks[-idx], diff --git a/arknights_mower/utils/simulator.py b/arknights_mower/utils/simulator.py index c51be19b..f38010f4 100644 --- a/arknights_mower/utils/simulator.py +++ b/arknights_mower/utils/simulator.py @@ -31,7 +31,7 @@ def restart_simulator(stop=True, start=True): if simulator_type not in [types.value for types in Simulator_Type]: logger.warning(f"尚未支持{simulator_type}重启/自动启动") csleep(10) - return + return False if simulator_type == Simulator_Type.Nox.value: cmd = "Nox.exe" @@ -95,6 +95,7 @@ def restart_simulator(stop=True, start=True): pyautogui.FAILSAFE = False pyautogui.hotkey(*hotkey) + return True def exec_cmd(cmd, folder_path, wait_time, blocking): diff --git a/arknights_mower/utils/solver.py b/arknights_mower/utils/solver.py index c607dede..00514f0c 100644 --- a/arknights_mower/utils/solver.py +++ b/arknights_mower/utils/solver.py @@ -190,6 +190,11 @@ def ctap(self, pos: tp.Location, max_seconds: int = 10): def check_current_focus(self): self.recog.check_current_focus() + def restart_game(self): + self.device.exit() + self.device.launch() + self.recog.update() + def tap_element( self, element_name: tp.Res,