def guochang(self, screen_shot, template_paths, suiji=1): # suji标号置1, 表示未找到时将点击左上角, 置0则不点击 # 输入截图, 模板list, 得到下一次操作 self.dWidth, self.dHeight = self.d.window_size() screen_shot = screen_shot template_paths = template_paths active_path = UIMatcher.imgs_where(screen_shot, template_paths) if active_path: # print(active_path) if 'img/caidan_tiaoguo.jpg' in active_path: x, y = active_path['img/caidan_tiaoguo.jpg'] self.d.click(x, y) else: for name, (x, y) in active_path.items(): # print(name) self.d.click(x, y) time.sleep(0.5) else: if suiji: # print('未找到所需的按钮,将点击左上角') self.d.click(0.1 * self.dWidth, 0.1 * self.dHeight) else: # print('未找到所需的按钮,无动作') pass
def guochang(self, screen_shot, template_paths, suiji=1): # suji标号置1, 表示未找到时将点击左上角, 置0则不点击 # 输入截图, 模板list, 得到下一次操作 # 2020-08-08 建议弃用该函数。 screen_shot = screen_shot template_paths = template_paths active_path = UIMatcher.imgs_where(screen_shot, template_paths) if active_path: # print(active_path) if 'img/juqing/tiaoguo_1.bmp' in active_path: x, y = active_path['img/juqing/tiaoguo_1.bmp'] self.click(x, y) else: for name, (x, y) in active_path.items(): # print(name) self.click(x, y) time.sleep(0.5) else: if suiji: # print('未找到所需的按钮,将点击左上角') self.click(0.1 * self.dWidth, 0.1 * self.dHeight) else: # print('未找到所需的按钮,无动作') pass
def shoushuazuobiao(self, x, y, jiaocheng=0, lockpic='img/normal.jpg', screencut=None): """ 不使用挑战券挑战,xy为该图坐标 jiaocheng=0 只处理简单的下一步和解锁内容 jiaocheng=1 要处理复杂的教程 lockpic: 返回时锁定的图 screencut: 返回时锁定的图的搜索范围 :return: """ while True: screen_shot_ = self.d.screenshot(format="opencv") if UIMatcher.img_where(screen_shot_, lockpic, at=screencut): break self.d.click(1, 138) time.sleep(1) self.lockimg('img/tiaozhan.jpg', elseclick=[(x, y)], elsedelay=2) self.d.click(840, 454) time.sleep(0.7) while True: screen_shot_ = self.d.screenshot(format="opencv") if UIMatcher.imgs_where(screen_shot_, ['img/kuaijin.jpg', 'img/kuaijin_1.jpg']) != {}: break self.d.click(840, 454) # 点到进入战斗画面 time.sleep(0.7) while True: screen_shot_ = self.d.screenshot(format="opencv") if self.click_img(screen_shot_, 'img/kuaijin.jpg', at=(891, 478, 936, 517)): time.sleep(1) if self.click_img(screen_shot_, 'img/auto.jpg', at=(891, 410, 936, 438)): time.sleep(1) if UIMatcher.img_where(screen_shot_, 'img/wanjiadengji.jpg', at=(233, 168, 340, 194)): break self.d.click(1, 138) time.sleep(0.5) if jiaocheng == 1: # 有复杂的教程,交给教程函数处理 self.chulijiaocheng() else: # 无复杂的教程,自己处理掉“下一步” for _ in range(7): self.d.click(832, 506) time.sleep(0.2) while True: time.sleep(2) screen_shot_ = self.d.screenshot(format="opencv") if UIMatcher.img_where(screen_shot_, lockpic, at=screencut): break elif UIMatcher.img_where(screen_shot_, 'img/xiayibu.jpg'): self.d.click(832, 506) else: self.d.click(1, 100) while True: # 两次确认回到挑战界面 self.d.click(1, 100) time.sleep(0.5) screen_shot_ = self.d.screenshot(format="opencv") if UIMatcher.img_where(screen_shot_, lockpic, at=screencut): break
def qianghua(self): # 此处逻辑极为复杂,代码不好理解 time.sleep(3) self.d.click(215, 513) # 角色 time.sleep(3) self.d.click(177, 145) # First time.sleep(3) for i in range(5): print("Now: ", i) while True: screen_shot_ = self.d.screenshot(format='opencv') if UIMatcher.img_where(screen_shot_, 'img/keyihuode.jpg'): # 存在可以获得,则一直获得到没有可以获得,或者没有三星 self.d.click(374, 435) time.sleep(1) screen_shot_ = self.d.screenshot(format='opencv') if UIMatcher.img_where(screen_shot_, 'img/tuijianguanqia.jpg', at=(258, 87, 354, 107)): # 已经强化到最大等级,开始获取装备 if not UIMatcher.img_where(screen_shot_, 'img/sanxingtongguan.jpg'): # 装备不可刷,换人 self.d.click(501, 468) # important time.sleep(1) break while UIMatcher.img_where(screen_shot_, 'img/sanxingtongguan.jpg'): # 一直刷到没有有推荐关卡但没有三星或者返回到角色列表 self.guochang(screen_shot_, ['img/sanxingtongguan.jpg'], suiji=0) time.sleep(1) # 使用扫荡券的数量: for _ in range(4 - 1): self.d.click(877, 333) time.sleep(0.3) self.d.click(752, 333) time.sleep(0.7) self.d.click(589, 371) while True: screen_shot_ = self.d.screenshot(format='opencv') active_paths = UIMatcher.imgs_where(screen_shot_, ['img/tuijianguanqia.jpg', 'img/zidongqianghua.jpg', 'img/tiaoguo.jpg']) if 'img/tiaoguo.jpg' in active_paths: x, y = active_paths['img/tiaoguo.jpg'] self.d.click(x, y) if 'img/tuijianguanqia.jpg' in active_paths: flag = 'img/tuijianguanqia.jpg' break elif 'img/zidongqianghua.jpg' in active_paths: flag = 'img/zidongqianghua.jpg' break else: self.d.click(1, 100) time.sleep(1.3) if flag == 'img/zidongqianghua.jpg': # 装备获取完成,跳出小循环,重进大循环 self.d.click(371, 437) time.sleep(0.7) break else: # 装备未获取完毕,继续尝试获取 continue self.d.click(501, 468) # important time.sleep(2) continue else: # 未强化到最大等级,强化到最大登记 self.d.click(501, 468) # important time.sleep(3) continue else: # 没有可以获得 if UIMatcher.img_where(screen_shot_, 'img/ranktisheng.jpg', at=(206, 325, 292, 346)): self.d.click(250, 338) time.sleep(2) screen_shot_ = self.d.screenshot(format='opencv') active_list = UIMatcher.imgs_where(screen_shot_, ['img/queren.jpg', 'img/ok.bmp']) if 'img/queren.jpg' in active_list: x, y = active_list['img/queren.jpg'] self.d.click(x, y) if 'img/ok.bmp' in active_list: x, y = active_list['img/ok.bmp'] self.d.click(x, y) time.sleep(8) self.d.click(481, 369) time.sleep(1) continue else: self.d.click(371, 437) time.sleep(0.7) self.d.click(501, 468) # important time.sleep(2) break self.d.click(933, 267) # 下一位 time.sleep(2) self.lockimg('img/liwu.bmp', elseclick=[(131, 533)], elsedelay=1, at=(891, 413, 930, 452)) # 回首页 self.lockimg('img/zhuxianguanqia.jpg', elseclick=[(480, 513)], elsedelay=3) self.d.click(562, 253) time.sleep(3) self.lockimg('img/normal.jpg', elseclick=[(704, 84)], elsedelay=0.5, alldelay=1, at=(660, 72, 743, 94)) self.d.click(923, 272) time.sleep(3)