def run(self, target_stage_code, repeat_times=1000):
     target_stage_code = target_stage_code.upper()
     target_stage, stage_linear = get_stage(target_stage_code)
     all_items_map = arkplanner.get_all_items_map()
     rewards = target_stage['stageDropInfo']['displayDetailRewards']
     # print(rewards)
     stage_drops = [all_items_map[reward["id"]]["name"] for reward in rewards
                    if reward["type"] == "MATERIAL" and reward["dropType"] == 2]
     print(f"{target_stage['code']}: {target_stage['name']}, 重复次数: {repeat_times}, 关卡掉落: {stage_drops}")
     record_name = f'goto_{target_stage["stageType"]}_{target_stage["zoneId"]}'
     while True:
         try:
             print(f'执行操作记录 {record_name}')
             self.helper.replay_custom_record(record_name)
             break
         except RuntimeError as e:
             if '未找到相应的记录' in str(e):
                 wait_seconds_after_touch = 5
                 c = input(f'{str(e)}, 是否录制相应操作记录(需要使用 MuMu 模拟器)[y/N]:').strip().lower()
                 if c != 'y':
                     return
                 print('录制到进入活动关卡选择界面即可, 无需点击具体的某个关卡.')
                 print(f'如果需要重新录制, 删除 custom_record 下的 {record_name} 文件夹即可.')
                 print(f'请在点击后等待 {wait_seconds_after_touch} s , 待控制台出现 "继续..." 字样, 再进行下一次点击.')
                 print(f'请在点击后等待 {wait_seconds_after_touch} s , 待控制台出现 "继续..." 字样, 再进行下一次点击.')
                 print(f'请在点击后等待 {wait_seconds_after_touch} s , 待控制台出现 "继续..." 字样, 再进行下一次点击.')
                 print(f'准备开始录制 {record_name}...')
                 self.helper.create_custom_record(record_name, roi_size=32,
                                                  description=get_zone_description(target_stage["zoneId"]),
                                                  wait_seconds_after_touch=wait_seconds_after_touch)
             else:
                 raise e
     self.helper.find_and_tap_stage_by_ocr(None, target_stage_code, stage_linear)
     self.helper.module_battle_slim(None, repeat_times)
Ejemplo n.º 2
0
 def run(self, target_stage_code, query_only=False):
     target_stage_code = target_stage_code.upper()
     try:
         target_stage, stage_linear = get_stage(target_stage_code)
     except Exception:
         if query_only:
             return False
         raise
     all_items_map = arkplanner.get_all_items_map()
     rewards = target_stage['stageDropInfo']['displayDetailRewards']
     # print(rewards)
     stage_drops = [
         all_items_map[reward["id"]]["name"] for reward in rewards
         if reward["type"] == "MATERIAL" and reward["dropType"] == 2
     ]
     record_name = f'goto_{target_stage["stageType"]}_{target_stage["zoneId"]}'
     if query_only:
         return self.addon(RecordAddon).get_record_path(record_name)
     self.logger.info(
         f"{target_stage['code']}: {target_stage['name']}, 关卡掉落: {stage_drops}"
     )
     self.logger.info(f'执行操作记录 {record_name}')
     self.addon(RecordAddon).replay_custom_record(record_name)
     self.addon(StageNavigator).find_and_tap_stage_by_ocr(
         None, target_stage_code, stage_linear)