def deal_sos_sign(): adb = AutoAdb() adb.wait('temp_images/sos/sos-signal.png').click() # 将已经开启的潜艇关卡解决掉 goto_stage_page = adb.click('temp_images/sos/goto-stage-page.png') if goto_stage_page: # 有些情况会直接进入关卡,因此不需要“点击关卡” print('发现已经开启的关卡,即将进入战斗。。。') if PageUtils.in_enemy_page(): StageFight.fight_all_enemy() else: StageFight.fight_stage(['temp_images/sos/stage-icon.png']) return True # 搜索新的信号 print('搜索新的信号。。。') adb.click('temp_images/sos/search-signal.png') while True: if adb.check('temp_images/sos/no-chance.png'): print('已经没有新的信号,SOS关卡执行完毕,脚本退出') PageUtils.to_stage_page() exit() # 如果有确认按钮,则点击确认,前往关卡 adb.click('temp_images/confirm-btn.png') # 如果已经发现了关卡按钮,则点击 click_stage = adb.click('temp_images/sos/stage-icon.png') if click_stage: print('进入SOS关卡战斗。。。') confirmed = StageFight.confirm_stage_team() if not confirmed: continue return True
def run(): print('处理求救信号关卡。。。') # 如果已经在关卡中,则先战斗 StageFight.wind_up_stage_fight() PageUtils.to_stage_page() while True: res = deal_sos_sign() if not res: print('所有求救信号已处理完毕') PageUtils.to_main_page() break
def run(): StageFight.wind_up_stage_fight() adb = AutoAdb(test_device=True) temp_list = PathUtils.get_temp_rel_path_list( 'temp_images/target-stage-hard') while True: # 如果发现次数为0,则终止 if adb.click('temp_images/stage/no-chance-for-hard.png'): print('困难关卡机会已用尽,程序终止') break StageFight.fight_stage(temp_list) print('困难关卡已经结束')
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(self): # 点击出击 Location(self.adb, None, self.x_pos, self.y_pos + self.y_step * self.flag).click() # 观察是否已经耗尽机会 while True: # 出现出击按钮,说明已经进入关卡了 if self.adb.check('temp_images/fight/fight.png'): break # 如果出现没有机会提示,则说明没机会了 if self.adb.check( 'temp_images/daily-task/daily-task/no-chance.png', 'temp_images/daily-task/daily-task/no-chance-2.png', threshold=0.95): print('机会耗尽,%s结束' % self.task_name) return # 切换到最右边的队伍 while True: have_right = self.adb.click( 'temp_images/daily-task/daily-task/right-team.png') if not have_right: break # 出击 print('出击第 %d 关' % (self.flag + 1)) result = StageFight.fight() if not result: print('挑战失败,目标下移。。。') self.step_add() # 调用自己,继续战斗 self.run()
def to_stage_page(): adb = AutoAdb() if in_stage_page(): return True to_main_page() adb.click('temp_images/page/main-fight.png') # 可能正处在战斗关卡,自动战斗 fight = StageFight.wind_up_stage_fight() if fight: return to_stage_page() return True
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()
from bin import StageFight from common.AutoAdb import AutoAdb if __name__ == '__main__': AutoAdb(test_device=True) print('[单发模式] 如果已经在某个关卡中,则自动战斗至关卡结束', end='\n\n') res = StageFight.wind_up_stage_fight() if res: print('关卡收尾结束') else: print('未在关卡中,结束运行')