def complete0001(loopNum): log.info("开始事件Aband3t-0001") # w, h = location_screen("Aband3t-1.png") # log.info(w) # pyautogui.moveTo(w + 60, h) # click(w+60, h, _pause=1, duration=1) # time.sleep(2) for i in range(loopNum): evt = ExitEvent(20) while not MapCv.__in_screenshot__("Aband3t-3.png"): evt.start_event() log.info("evt leave ...-3") time.sleep(2) w, h = location_screen("Aband3t-3.png") click(w, h, _pause=1, duration=1) time.sleep(120) evt = ExitEvent(150) while not MapCv.__in_screenshot__("Aband3t-2.png"): # evt.start_event() log.info("end... -2") time.sleep(10) w, h = MapCv.location_screen("Aband3t-2.png") click(w, h, _pause=1, duration=1) time.sleep(2) log.info("结束事件Aband3t-0001")
def complete0001(loopNum): wp = WaitPredication() twp = wp.get_predication("Aj8fer-1") log.info("开始事件Aj8fer-0001") for i in range(loopNum): evt = ExitEvent(20) while not MapCv.__in_screenshot__("Aj8fer-1.png"): evt.start_event() log.info("evt leave ...-3") time.sleep(2) w, h = location_screen("Aj8fer-1.png") click(w, h, _pause=1, duration=1) wp = WaitPredication() twp = wp.get_predication("Aj8fer-1") log.info("Aj8fer-1 预测时间" + str(twp)) time.sleep(int(twp)) while not MapCv.__in_screenshot__("Aband3t-2.png"): # evt.start_event() log.info("程序正在执行中,未检测到结束状态") time.sleep(3) wp.record("Aj8fer-1") w, h = MapCv.location_screen("Aband3t-2.png") click(w, h, _pause=1, duration=1) time.sleep(1) log.info("结束事件Aj8fer-0001")
def start(self): lock_click(281, 649, lock_img="结界突破.png") while True: for now in range(9): now = now + 1 x_index = math.ceil(float(now) / 3) y_index = now % 3 click(x[x_index - 1], y[y_index - 1]) time.sleep(3) fight = MapCv.location_screen("突破进攻.png") if fight is None: continue log.info(fight) lock_click(fight, lock_img="准备2.png") lock_wait_lost(lock_img="准备2.png", loop_action=lambda x: click(1022, 541)) time.sleep(20) while True: sb = MapCv.__in_screenshot__("突破失败.png") end = MapCv.__in_screenshot__("妖气封印打完_2.png") if sb or end: click(x[0], y[0]) time.sleep(4) break time.sleep(2) lock_wait_lost(lock_img="突破刷新.png", loop_action=lambda x: {click(927, 541), click(667, 443)}) time.sleep(3)
def start(timer=10): pyautogui.click(start_yuhun, pause=2) pyautogui.click(simple_yuhun, pause=1) for i in range(0, timer): while not MapCv.__in_screenshot__("觉醒道场.png"): pyautogui.click(simple_yuhun) time.sleep(5) pyautogui.click(simple_yuhun2) pyautogui.click(pre_activate, pause=2) log.info("开始打怪") time.sleep(5) while MapCv.__in_screenshot__("准备2.png"): log.info("查找准备按钮") pyautogui.click(start_activate) time.sleep(2) time.sleep(120) while not MapCv.__in_screenshot__("妖气封印打完_2.png"): log.info("查找打完按钮") time.sleep(5) pyautogui.click(simple_yuhun)
def start(self): # lock_wait("wait_adventure.png") # find_map() lock_click(last_adventure, lock_img="start_adventure.png") log.info("已经进入探索副本,开始进行自动扫怪") for i in range(self.timer): lock_click(adventure_200, lock_img="wait_adventure.png") log.info("第{}次探索副本开始\n--------------------------------".format(i + 1)) next_page() while True: page_num = 0 lost_monster = 0 for retry in range(self.adventure_retry): monsters = Monster.lock_monster_exp( ) if self.exp else Monster.lock_monster() log.info("当前在地图第{}页,已定位怪物数量{}".format( page_num, len(monsters))) if len(monsters) > 0: lost_monster = 0 print(monsters) self.activate(monsters[0]) else: # 未定位到怪物进入下一页 lost_monster += 1 log.info("第{}次,未找到怪兽".format(lost_monster)) if lost_monster > 1: log.info("进入下一页寻找怪兽") page_num += 1 next_page() lost_monster = 0 if page_num > self.max_page_num: log.info("已经第4次拖图,结束本次探索") lock_wait("探索退出.png", after_action=click(49, 121)) time.sleep(2) click(686, 419) time.sleep(4) if MapCv.start_adventure(): break if MapCv.__in_screenshot__("首页.png"): #find_map() lock_click(last_adventure, lock_img="start_adventure.png") log.info("------------------------------\n") break break
def lock_wait_lost(lock_img=None, wait_time=2, max_timeout=30, after_action=None, loop_action=None): timeout = 0 while MapCv.__in_screenshot__(lock_img): time.sleep(wait_time) timeout += wait_time if loop_action is not None: loop_action(1) if timeout > max_timeout: log.error("程序已等待进入{} -{}秒,脚本停止运行".format(lock_img)) exit(300) if after_action is not None: after_action(1)
def lock_wait(lock_img=None, wait_time=2, max_timeout=30, after_action=None, loop_action=None): timeout = 0 lock = True while not MapCv.__in_screenshot__(lock_img): if loop_action is not None: loop_action(1) time.sleep(wait_time) timeout += wait_time if timeout > max_timeout: log.error("程序已等待进入{} -{}秒,脚本停止运行".format(lock_img, max_timeout)) lock = False break if after_action is not None: after_action(1) return lock
def activate(self, monster): # 得到怪物的坐标点 开始打怪 log.info("开始点击monster {}.{}".format(monster[0], monster[1])) lock_click(monster, pause=1, duration=0) log.info("点击monster") if MapCv.append_power(): log.info("体力已经耗尽,程序运行停止...") exit(300) time.sleep(2) if MapCv.wait_adventure(): click(move_right) return time.sleep(1) location_points = MapCv.location_multiscreen("满.png") change_dog = False if len(location_points) > 1: for location_point in location_points: if location_point[0] > 350: change_dog = True if change_dog: lock_doubleclick(413, 558) lock_wait( "狗粮.png", loop_action=lambda x: lock_doubleclick(413, 558, pause=1)) # 替换狗粮大队长 log.info("------------------------开始替换狗粮") points = MapCv.location_multiscreen("满.png") log.info("查找狗粮是否需要替换") block_1 = 377 block_2 = 760 for point in points: if point[1] < 400: if block_1 < point[0] < block_2: next_dog() time.sleep(2) pyautogui.moveTo(472, 572, pause=1) pyautogui.dragTo(point[0], point[1] + 100, 1) break elif point[0] < block_1: next_dog() time.sleep(2) pyautogui.moveTo(472, 572, pause=1) pyautogui.dragTo(point[0], point[1] + 100, 1) break pyautogui.click(1048, 558, pause=2) log.info("开始探索\n_________________________________") time.sleep(30) while not MapCv.end_adventure(): if MapCv.__in_screenshot__("start_adventure.png"): break if MapCv.__in_screenshot__("首页.png"): break log.info("打怪中....") time.sleep(5) log.info("打怪完成\n##################################") time.sleep(7) click(awake_200) lock = lock_wait("wait_adventure.png", loop_action=lambda x: click(awake_200)) if not lock: click(awake_200) log.info("退出单次打怪页面....") # 判断当前所在页面 time.sleep(4) if MapCv.start_adventure( ): # 如果在开始探索页面 如果有boss奖励就拿,然后退出,重新进入探索模式 没有就继续下一次找怪 # 判断是不是boss奖励不是继续探索 boss_awards = MapCv.location_screen("boos奖励.png") if boss_awards is None or len(boss_awards) == 0: log.info("啥都没有") else: for award in boss_awards: click(award) time.sleep(1) click(award) time.sleep(3) log.info("奖励领取完成....") time.sleep(3) log.info("重新进入探索页面") if MapCv.__in_screenshot__("首页.png"): # 如果在首页 判断是不是有石距,或者宝箱 # box = MapCv.__in_screenshot__("宝箱.png") # 回到首页宝箱 # bigMonster = MapCv.__in_screenshot__("愤怒的石距.png") # 回到首页石距 lock_click(last_adventure, lock_img="start_adventure.png") if MapCv.__in_screenshot__("首页.png"): # 如果在首页 判断是不是有石距,或者宝箱 # box = MapCv.__in_screenshot__("宝箱.png") # 回到首页宝箱 # bigMonster = MapCv.__in_screenshot__("愤怒的石距.png") # 回到首页石距 lock_click(last_adventure, lock_img="start_adventure.png")
def loop_start(): while not MapCv.__in_screenshot__("挑战.png"): pyautogui.click(awake_100, pause=2) time.sleep(2)
def loop_end(): while not MapCv.__in_screenshot__("妖气封印打完_2.png"): time.sleep(2) pyautogui.click(awake_100, pause=2)