def check_link(auto_adb): adb_host_port = ConfigUtils.get('adb_host_port') print('检测设备连接状态 >>> %s ...' % adb_host_port) auto_adb.run('connect %s' % adb_host_port) device_list = get_devices(auto_adb) if len(device_list) == 0: print('未检测到设备,请检查ADB地址配置,或参考 https://github.com/FirstJavaMaster/AzurLaneScripts/blob/master/README.md') exit(1) target_device = None print('\n设备列表:') for device in device_list: print(device) if adb_host_port in device: target_device = device print() # 设备没找到 if target_device is None: print('设备列表中没找到目标连接(%s),请检查配置是否正确' % adb_host_port) exit(1) # 如果找到了设备,但是离线状态 if 'offline' in target_device: print('检测到设备离线!!!') print('由于不同模拟器ADB实现细节不同,请尝试以下办法(没有先后顺序):') print('· 重启模拟器') print('· 如果模拟器已经自带了ADB,则可以尝试将脚本中adb文件夹的文件拷贝至模拟器自带ADB目录。注意备份原文件') print('· 在adb目录下打开cmd,执行 adb kill-server 后再执行 adb start-server,然后执行 adb devices 查看是否解决') print('· 重启电脑') print('· 换个模拟器') exit(1) # 设备正常 print('设备已连接', end='\n\n')
def check_link(auto_adb): print('检测设备 ...') device_number = check_link_number(auto_adb) if device_number < 1: adb_host_port = ConfigUtils.get('adb_host_port') if adb_host_port is not None: auto_adb.run('connect %s' % adb_host_port) device_number = check_link_number(auto_adb) if device_number < 1: print('未检测到设备, 请参考 https://github.com/FirstJavaMaster/AzurLaneScripts/blob/master/README.md') exit(1) if device_number > 2: print('设备数量过多, 请参考 https://github.com/FirstJavaMaster/AzurLaneScripts/blob/master/README.md') exit(1) print('设备已连接', end='\n\n')
def run(): # 计数 num = 0 # 最大通关次数 max_stage_fight_times = int(ConfigUtils.get('max_stage_fight_times')) # 循环战斗 while True: # 选择关卡 开始战斗 target_stage_list = PathUtils.get_temp_rel_path_list('temp_images/target-stage') StageFight.fight_stage(target_stage_list) # 计数 num += 1 print('通关次数累计:%d' % num, end='\n\n') if max_stage_fight_times is not None and num >= max_stage_fight_times: print('已达最大通关次数 %d,结束运行' % max_stage_fight_times) exit()
def run(): # 计数 fight_recorder = FightRecorder() # 最大通关次数 max_stage_fight_times = int(ConfigUtils.get('max_stage_fight_times')) # 循环战斗 while True: # 选择关卡 开始战斗 target_stage_list = PathUtils.get_temp_rel_path_list('temp_images/target-stage') fight_result = StageFight.fight_stage(target_stage_list) # 计数 fight_recorder.append(fight_result) fight_recorder.print_recorder() # 连续失败两次就停止战斗 if fight_recorder.get_last_fail_count() >= 2: print('连续 2 次关卡战斗失败, 为了避免更多损失脚本自动退出') exit() if max_stage_fight_times is not None and fight_recorder.get_total_count() >= max_stage_fight_times: print('已达最大通关次数 %d,结束运行' % max_stage_fight_times) exit()
def check_port_full(): adb = AutoAdb() port_full = adb.check('temp_images/port/port-full.png') if not port_full: return False print('船坞已经满员了... ', end='') auto_retire = ConfigUtils.get('auto_retire', fallback=False) if auto_retire: print('开始自动退役... ') adb.wait('temp_images/port/port-full-retire.png').click() # 整理 adb.wait('temp_images/port/retire.png').click() # 一键退役 adb.wait('temp_images/port/retire-confirm.png').click() # 确定舰娘 adb.wait('temp_images/port/retire-confirm.png', max_wait_time=2).click() # 确定(可能出现的)精英舰娘 adb.wait('temp_images/port/retire-confirm-1.png').click() # (获得物资)点击继续 adb.wait('temp_images/port/retire-confirm.png').click() # 确定装备 adb.wait('temp_images/port/retire-confirm.png').click() # 确定物资 adb.wait('temp_images/port/retire-confirm-1.png').click() # (获得物资)点击继续 adb.wait('temp_images/port/cancel.png').click() # (获得物资)点击继续 print('退役完成, 程序继续执行') return True print('未启用自动退役配置, 程序退出') exit()
def run(self, raw_command): adb_host_port = ConfigUtils.get('adb_host_port') command = '%s -s %s %s' % (self.adb_path, adb_host_port, raw_command) res = os.popen(command) return res.buffer.read().decode('utf-8').strip()