From 30236d7423370cad395bc34fafb813495f64973e Mon Sep 17 00:00:00 2001 From: Shawnsdaddy Date: Mon, 22 Jul 2024 22:55:15 -0700 Subject: [PATCH] Free checking --- arknights_mower/solvers/base_schedule.py | 60 ++++++++++++------------ 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/arknights_mower/solvers/base_schedule.py b/arknights_mower/solvers/base_schedule.py index 7a2bead9..83c8fc26 100644 --- a/arknights_mower/solvers/base_schedule.py +++ b/arknights_mower/solvers/base_schedule.py @@ -683,36 +683,38 @@ def infra_main(self): if TaskTypes.RELEASE_DORM == self.task.type: # 如果该房间提前已经被移出,则跳过安排避免影响正常排班 free_room = list(self.task.plan.keys())[0] - free_index = self.task.plan[free_room].index("Free") - if self.task.meta_data in self.op_data.operators.keys(): - free_agent = self.op_data.operators[self.task.meta_data] - if ( - free_agent.current_room == free_room - and free_agent.current_index == free_index - ): - get_time = True - # 如果是高优先,还需要把宿舍reference移除 - if free_agent.is_high(): - idx, dorm = self.op_data.get_dorm_by_name( - free_agent.name - ) - if idx is not None: - update_task = find_next_task( - self.tasks, - task_type=TaskTypes.SHIFT_ON, - meta_data="dorm" + str(idx), + if "Free" in self.task.plan[free_room]: + free_index = self.task.plan[free_room].index("Free") + if self.task.meta_data in self.op_data.operators.keys(): + free_agent = self.op_data.operators[self.task.meta_data] + if ( + free_agent.current_room == free_room + and free_agent.current_index == free_index + ): + get_time = True + # 如果是高优先,还需要把宿舍reference移除 + if free_agent.is_high(): + idx, dorm = self.op_data.get_dorm_by_name( + free_agent.name ) - if update_task: - logger.debug("开始更新宿舍信息") - dorm_list = update_task.meta_data.split(",") - dorm_list.remove("dorm" + str(idx)) - update_task.meta_data = ",".join(dorm_list) - free_agent.mood = free_agent.upper_limit - free_agent.time_stamp = dorm.time - else: - self.task.plan = {} - else: - self.task.plan = {} + if idx is not None: + update_task = find_next_task( + self.tasks, + task_type=TaskTypes.SHIFT_ON, + meta_data="dorm" + str(idx), + ) + if update_task: + logger.debug("开始更新宿舍信息") + dorm_list = update_task.meta_data.split( + "," + ) + dorm_list.remove("dorm" + str(idx)) + update_task.meta_data = ",".join( + dorm_list + ) + free_agent.mood = free_agent.upper_limit + free_agent.time_stamp = dorm.time + self.task.plan = {} if ( config.grandet_back_to_index and TaskTypes.RUN_ORDER == self.task.type