|
22 | 22 |
|
23 | 23 | logger = Logger.get_logger(__name__) |
24 | 24 |
|
| 25 | +class MacroFailedException(Exception): |
| 26 | + """外部脚本失败异常。""" |
| 27 | + pass |
25 | 28 |
|
26 | 29 | class ImportTask(DNAOneTimeTask, CommissionsTask, BaseCombatTask): |
27 | 30 |
|
@@ -74,6 +77,7 @@ def run(self): |
74 | 77 | self.img = self.load_png_files(f'{path}\mod\{self.config.get('外部文件夹')}\map') |
75 | 78 | DNAOneTimeTask.run(self) |
76 | 79 | self.move_mouse_to_safe_position() |
| 80 | + self.set_check_monthly_card() |
77 | 81 | _to_do_task = self |
78 | 82 | try: |
79 | 83 | if self.config.get('副本类型') == '扼守无尽': |
@@ -131,7 +135,8 @@ def do_run(self): |
131 | 135 | self.log_info('任务完成') |
132 | 136 | self.wait_until(self.in_team, time_out=30) |
133 | 137 | self.sleep(2) |
134 | | - self.walk_to_aim() |
| 138 | + if not self.walk_to_aim(): |
| 139 | + self.open_in_mission_menu() |
135 | 140 | _wave_start = time.time() |
136 | 141 | _delay_task_start = _wave_start + 1 |
137 | 142 | self.current_wave = -1 |
@@ -198,7 +203,13 @@ def walk_to_aim(self, former_index = None): |
198 | 203 | return True |
199 | 204 | if map_index is not None: |
200 | 205 | self.log_info(f'执行{map_index}') |
201 | | - self.play_macro_actions(map_index) |
| 206 | + try: |
| 207 | + self.play_macro_actions(map_index) |
| 208 | + except MacroFailedException: |
| 209 | + return False |
| 210 | + except Exception as e: |
| 211 | + logger.error("ImportTask error", e) |
| 212 | + raise |
202 | 213 | former_index = map_index |
203 | 214 | else: |
204 | 215 | return True |
@@ -249,6 +260,8 @@ def play_macro_actions(self, map_index): |
249 | 260 | start = time.time() |
250 | 261 | for i, action in enumerate(actions): |
251 | 262 | while time.time()-start < action['time']: |
| 263 | + if self.check_for_monthly_card()[0]: |
| 264 | + raise MacroFailedException |
252 | 265 | self.next_frame() |
253 | 266 | if action['type'] == "delay": |
254 | 267 | self.delay_index = map_index |
|
0 commit comments