def lock_home(self): """ 锁定首页 要求场景:存在“我的主页”按钮 逻辑:不断点击我的主页,直到右下角出现“礼物” """ self.clear_all_initFC() last = time.time() while True: sc = self.getscreen() if self.is_exists(MAIN_BTN["xiazai"], screen=sc): self.click(MAIN_BTN["xiazai"]) num_of_white, _, x, y = UIMatcher.find_gaoliang(sc) if num_of_white < 77000: self.chulijiaocheng(None) # 增加对教程的处理功能 last = time.time() if self.is_exists(MAIN_BTN["liwu"], screen=sc): return # if self.is_exists(MAIN_BTN["guanbi"], screen=sc): # self.click(MAIN_BTN["guanbi"]) try: r_list = self.img_where_all(img=MAIN_BTN["guanbi"], screen=sc) if self.lock_no_img(img=MAIN_BTN["guanbi"], elseclick=(int(r_list[0]), int(r_list[1])), side_check=self.juqing_kkr): time.sleep(5) continue except: pass self.click(MAIN_BTN["zhuye"]) # 防卡公告 self.click(1, 1) time.sleep(1.5) if time.time() - last > lockimg_timeout: raise Exception("lock_home时出错:超时!")
def init_home(self): # 2020-07-31 TheAutumnOfRice: 检查完毕 while True: screen_shot_ = self.getscreen() if self.is_exists(MAIN_BTN["liwu"], screen=screen_shot_): break if self.is_exists(MAIN_BTN["xiazai"], screen=screen_shot_): self.click(MAIN_BTN["xiazai"]) if self.is_exists(MAIN_BTN["tiaoguo"], screen=screen_shot_): self.click(893, 39, post_delay=0.5) # 跳过 continue if self.is_exists(MAIN_BTN["xzcw"], screen=screen_shot_): raise Exception("下载错误") if self.is_exists(MAIN_BTN["jingsaikaishi"], screen=screen_shot_): self.click(786, 308, post_delay=0.2) # 选角色 self.click(842, 491) # 开始 continue num_of_white, _, x, y = UIMatcher.find_gaoliang(screen_shot_) if num_of_white < 77000: break # 跳过特别庆典 self.click(1, 1, post_delay=0.5) self.click(330, 270, post_delay=1) # 跳过抽签(备用) self.d.touch.down(470, 30).sleep(0.1).move(470, 500).sleep(0.2).up(470, 500) self.lock_home() time.sleep(0.5) # 这里防一波第二天可可萝跳脸教程 screen_shot_ = self.getscreen() num_of_white, _, _, _ = UIMatcher.find_gaoliang(screen_shot_) if num_of_white < 50000: self.lock_img('img/renwu_1.bmp', elseclick=[(837, 433)], elsedelay=1) self.lock_home() return if UIMatcher.img_where(screen_shot_, 'img/kekeluo.bmp'): self.lock_img('img/renwu_1.bmp', elseclick=[(837, 433)], elsedelay=1) self.lock_home() time.sleep(1) self.lock_home() # 追加检测
def init_home(self): while True: screen_shot_ = self.d.screenshot(format="opencv") if UIMatcher.img_where(screen_shot_, 'img/liwu.bmp', at=(891, 413, 930, 452)): break if UIMatcher.img_where(screen_shot_, 'img/niudan_jiasu.jpg', at=(700, 0, 960, 100)): self.d.click(893, 39) # 跳过 time.sleep(0.5) continue if UIMatcher.img_where(screen_shot_, 'img/jingsaikaishi.bmp', at=(755, 471, 922, 512)): self.d.click(786, 308) # 选角色 time.sleep(0.2) self.d.click(842, 491) # 开始 time.sleep(0.5) continue self.d.click(1, 1) self.d.click(330, 270) # 跳过特别庆典 self.lockimg('img/liwu.bmp', elseclick=[(1, 1)], elsedelay=0.2, at=(891, 413, 930, 452)) # 首页锁定 time.sleep(0.5) # 这里防一波第二天可可萝跳脸教程 screen_shot_ = self.d.screenshot(format="opencv") num_of_white, _, _ = UIMatcher.find_gaoliang(screen_shot_) if num_of_white < 50000: self.lockimg('img/renwu_1.bmp', elseclick=[(837, 433)], elsedelay=1) self.lockimg('img/liwu.bmp', elseclick=[(90, 514)], elsedelay=0.2, at=(891, 413, 930, 452)) return if UIMatcher.img_where(screen_shot_, 'img/kekeluo.bmp'): self.lockimg('img/renwu_1.bmp', elseclick=[(837, 433)], elsedelay=1) self.lockimg('img/liwu.bmp', elseclick=[(90, 514)], elsedelay=0.2, at=(891, 413, 930, 452))
def lock_home(self): """ 锁定首页 要求场景:存在“我的主页”按钮 逻辑:不断点击我的主页,直到右下角出现“礼物” """ last = time.time() while True: sc = self.getscreen() num_of_white, _, x, y = UIMatcher.find_gaoliang(sc) if num_of_white < 77000: self.chulijiaocheng(None) # 增加对教程的处理功能 last = time.time() if self.is_exists(MAIN_BTN["liwu"], screen=sc): return self.click(MAIN_BTN["zhuye"]) # 防卡公告 self.click(1, 1) time.sleep(1.5) if time.time() - last > lockimg_timeout: raise Exception("lock_home时出错:超时!")
def chulijiaocheng(self): # 处理教程, 最终返回刷图页面 """ 有引导点引导 有下一步点下一步 有主页点主页 有圆menu就点跳过,跳过 有跳过点跳过 都没有就点边界点 # 有取消点取消 :return: """ count = 0 # 出现主页的次数 while True: screen_shot_ = self.d.screenshot(format="opencv") num_of_white, x, y = UIMatcher.find_gaoliang(screen_shot_) if num_of_white < 77000: try: self.d.click(x * self.dWidth, y * self.dHeight + 20) except: pass time.sleep(1) continue if UIMatcher.img_where(screen_shot_, 'img/liwu.bmp', at=(891, 413, 930, 452)): count += 1 if count > 2: break time.sleep(1) continue elif UIMatcher.img_where(screen_shot_, 'img/jiaruhanghui.jpg'): break elif self.click_img(screen_shot_, 'img/xiayibu.jpg'): time.sleep(2) elif self.click_img(screen_shot_, 'img/niudan_jiasu.jpg', at=(700, 0, 960, 100)): pass elif self.click_img(screen_shot_, 'img/wuyuyin.jpg', at=(450, 355, 512, 374)): time.sleep(3) elif self.click_img(screen_shot_, 'img/tiaoguo.jpg'): time.sleep(3) elif self.click_img(screen_shot_, 'img/zhuye.jpg', at=(46, 496, 123, 537)): pass elif self.click_img(screen_shot_, 'img/caidan_yuan.jpg', at=(898, 23, 939, 62)): time.sleep(0.7) self.d.click(804, 45) time.sleep(0.7) self.d.click(593, 372) time.sleep(2) elif UIMatcher.img_where(screen_shot_, 'img/qianwanghuodong.bmp'): for _ in range(3): self.d.click(390, 369) time.sleep(1) else: self.d.click(1, 100) count = 0 time.sleep(1) # 返回冒险 self.d.click(480, 505) time.sleep(2) self.lockimg('img/zhuxianguanqia.jpg', elseclick=[(480, 513), (390, 369)], elsedelay=0.5) while True: screen_shot_ = self.d.screenshot(format="opencv") if UIMatcher.img_where(screen_shot_, 'img/zhuxianguanqia.jpg', at=(511, 286, 614, 314)): self.d.click(562, 253) time.sleep(0.5) else: break time.sleep(3) while True: screen_shot_ = self.d.screenshot(format="opencv") if UIMatcher.img_where(screen_shot_, 'img/normal.jpg', at=(660, 72, 743, 94)): break self.d.click(704, 84) time.sleep(0.5)
def init_home(self): # 2020-07-31 TheAutumnOfRice: 检查完毕 while True: time.sleep(2) screen_shot_ = self.getscreen() if self.is_exists(MAIN_BTN["liwu"], screen=screen_shot_): break if self.is_exists(MAIN_BTN["xiazai"], screen=screen_shot_): self.click(MAIN_BTN["xiazai"]) if self.is_exists(MAIN_BTN["tiaoguo"], screen=screen_shot_): self.click(893, 39, post_delay=0.5) # 跳过 continue if self.is_exists(MAIN_BTN["xzcw"], screen=screen_shot_): raise Exception("下载错误") if self.is_exists(MAIN_BTN["jingsaikaishi"], screen=screen_shot_): self.click(786, 308, post_delay=0.2) # 选角色 self.click(842, 491) # 开始 continue try: r_list = self.img_where_all(img=MAIN_BTN["guanbi"], screen=screen_shot_) if self.lock_no_img(img=MAIN_BTN["guanbi"], elseclick=(int(r_list[0]), int(r_list[1])), side_check=self.juqing_kkr): time.sleep(3) continue except: pass # if self.is_exists(MAIN_BTN["guanbi"], screen=screen_shot_): # self.click(MAIN_BTN["guanbi"]) # continue # num_of_white, _, x, y = UIMatcher.find_gaoliang(screen_shot_) # print(num_of_white) # if num_of_white < 77000: # break # 跳过特别庆典 self.click(1, 1, post_delay=0.5) self.click(330, 270, post_delay=1) # 跳过抽签(备用) self.d.touch.down(370, 330).sleep(0.1).move(50, 50).sleep(0.2).up(370, 450) self.lock_home() time.sleep(0.5) # 这里防一波第二天可可萝跳脸教程 screen_shot_ = self.getscreen() num_of_white, _, _, _ = UIMatcher.find_gaoliang(screen_shot_) if num_of_white < 50000: self.lock_img('img/renwu_1.bmp', elseclick=[(837, 433)], elsedelay=1) self.lock_home() return if UIMatcher.img_where(screen_shot_, 'img/kekeluo.bmp'): self.lock_img('img/renwu_1.bmp', elseclick=[(837, 433)], elsedelay=1) self.lock_home() time.sleep(1) self.lock_home() # 追加检测
def runmain(address, account, password): a = Automator(address, account) a.start() print('>>>>>>>即将登陆的账号为:', account, '密码:', password, '<<<<<<<') t0 = time.time() need_auth = a.login(ac=account, pwd=password) if need_auth: auth_name, auth_id = random_name(), CreatIDnum() a.auth(auth_name=auth_name, auth_id=auth_id) # ========现在开始完成新手教程======== ''' 最高优先级 引导, 结束标志 高优先级 同意,跳过,登记,OK,扭蛋跳过 复合点击 长条菜单->跳过 (只使用两次) 圆Menu->跳过->跳过 低优先级 未激活的加速战斗 默认,点击(1,100) ''' count = 0 # 记录跳过战斗的数量 times = 0 # 记录主页出现的次数 while True: screen = a.d.screenshot(format="opencv") num_of_white, x, y = UIMatcher.find_gaoliang(screen) if num_of_white < 70000: try: a.d.click(x * a.dWidth, y * a.dHeight + 20) except: pass time.sleep(1) continue template_paths = { 'img/tongyi.jpg': (490, 459, 686, 496), 'img/tiaoguo.jpg': None, 'img/dengji.jpg': (382, 352, 578, 391), 'img/ok.bmp': None, 'img/niudan_jiasu.jpg': (700, 0, 960, 100) } for template in template_paths: if a.click_img(screen, template, at=template_paths[template]): break if count < 2 and (UIMatcher.img_where(screen, 'img/caidan.jpg', at=(861, 15, 940, 37))): # 有两场战斗是可以跳过的 count += 1 a.d.click(900, 25) time.sleep(0.8) a.d.click(591, 370) time.sleep(0.5) continue if UIMatcher.img_where(screen, 'img/caidan_yuan.jpg', at=(898, 23, 939, 62)): a.d.click(919, 45) time.sleep(0.8) a.d.click(806, 46) time.sleep(1) a.d.click(589, 370) time.sleep(0.5) continue if UIMatcher.img_where(screen, 'img/jingsaikaishi.bmp', at=(755, 471, 922, 512)): a.d.click(786, 308) # 选角色 time.sleep(0.2) a.d.click(842, 491) # 开始 time.sleep(0.5) continue if UIMatcher.img_where(screen, 'img/kuaijin.jpg', at=(891, 478, 936, 517)): a.d.click(911, 493) time.sleep(3) continue if UIMatcher.img_where(screen, 'img/liwu.bmp', at=(891, 413, 930, 452)): if times == 2: break times += 1 print('在主页的第', times, '次') # default a.d.click(1, 100) time.sleep(0.5) print('新手教程已完成') # ===========新手教程完成============ # ===========开始前期准备============ a.lockimg('img/liwu.jpg', elseclick=[(1, 100)], elsedelay=0.5, alldelay=2) a.shouqu() # 拿一点钻石用于买扫荡券,理论上至少能拿到300钻 a.goumaimana(1) # 买扫荡券 a.goumaitili(3) a.goumaijingyan() a.setting() # 设置无动画、低帧率 a.lockimg('img/zhuxianguanqia.jpg', elseclick=[(480, 513)], elsedelay=0.5, alldelay=1) a.lockimg('img/zhuxianguanqia.jpg', ifclick=[(562, 235)], ifdelay=3, alldelay=0) # ===========前期准备结束============ # =============开始刷图============== # 如果执行了新手教程,应该已经开成两倍速了,否则直接 a.shoushuazuobiao(313, 341) # 1-3 a.shoushuazuobiao(379, 240, 1) # 1-4 a.shoushuazuobiao(481, 286) # 1-5 a.shoushuazuobiao(545, 381, 1) # 1-6 a.shoushuazuobiao(607, 304) # 1-7 a.shoushuazuobiao(620, 209) # 1-8 a.shoushuazuobiao(747, 243) # 1-9 a.qianghua() a.shoushuazuobiao(824, 348, 1) # 1-10 虽然没有繁琐教程,但解锁东西过多,还是去用函数 a.shoushuazuobiao(129, 413, 1) # 2-1 a.shoushuazuobiao(255, 413, 1) # 2-2 a.qianghua() a.shoushuazuobiao(379, 379) # 2-3 a.shoushuazuobiao(332, 269) # 2-4 a.shoushuazuobiao(237, 206, 1) # 2-5 a.shoushuazuobiao(353, 161) # 2-6 a.shoushuazuobiao(453, 231) # 2-7 a.shoushuazuobiao(479, 316, 1) # 2-8 a.qianghua() a.d.drag(600, 270, 200, 270, 0.1) # 拖拽到最右,固定后面的点击位置 time.sleep(1) a.shoushuazuobiao(526, 372) # 2-9 装备危险 a.shoushuazuobiao(647, 375) # 2-10 a.shoushuazuobiao(756, 346) # 2-11 a.qianghua() a.d.drag(600, 270, 200, 270, 0.1) # 拖拽到最右,固定后面的点击位置 time.sleep(1) a.shoushuazuobiao(741, 228, 1) # 2-12 a.shoushuazuobiao(138, 188, 1) # 3-1 # 结束刷图 # 开始探索 a.lockimg('img/liwu.bmp', elseclick=[(131, 533)], elsedelay=1) # 回首页 # a.tansuo(mode=2) 还有问题,暂时关闭 a.shouqurenwu() # a.rename(account) # 重命名昵称为账号ID a.change_acc() # 退出当前账号,切换下一个 t = time.time() print('>>>>>>>账号:', account, '已刷完, 用时', t - t0, '秒<<<<<<<')
def chulijiaocheng(self, turnback="shuatu"): # 处理教程, 最终返回刷图页面 """ 这个处理教程函数是给chushihua.py用的 有引导点引导 有下一步点下一步 有主页点主页 有圆menu就点跳过,跳过 有跳过点跳过 都没有就点边界点 # 有取消点取消 :turnback: shuatu: 返回刷图页面 None: 不返回任何页面 :return: """ count = 0 # 出现主页的次数 while True: screen_shot_ = self.getscreen() num_of_white, _, x, y = UIMatcher.find_gaoliang(screen_shot_) if num_of_white < 77000: try: self.click(x * self.dWidth, y * self.dHeight + 20) except: pass time.sleep(1) continue if UIMatcher.img_where(screen_shot_, 'img/liwu.bmp', at=(891, 413, 930, 452)): count += 1 if count > 2: break time.sleep(1) continue elif UIMatcher.img_where(screen_shot_, 'img/jiaruhanghui.jpg'): break elif self.is_exists(MAIN_BTN["xiazai"], screen=screen_shot_): self.click(MAIN_BTN["xiazai"]) elif self.click_img(screen_shot_, 'img/xiayibu.jpg'): time.sleep(2) elif self.click_img(screen_shot_, 'img/niudan_jiasu.jpg', at=(700, 0, 960, 100)): pass elif self.click_img(screen_shot_, 'img/wuyuyin.jpg', at=(450, 355, 512, 374)): time.sleep(3) elif self.click_img(screen_shot_, 'img/juqing/tiaoguo_2.bmp'): time.sleep(3) elif self.click_img(screen_shot_, 'img/zhuye.jpg', at=(46, 496, 123, 537)): pass elif self.click_img(screen_shot_, 'img/juqing/caidanyuan.bmp', at=(898, 23, 939, 62)): time.sleep(0.7) self.click(804, 45) time.sleep(0.7) self.click(593, 372) time.sleep(2) elif UIMatcher.img_where(screen_shot_, 'img/qianwanghuodong.bmp'): for _ in range(3): self.click(390, 369) time.sleep(1) else: self.click(1, 100) count = 0 time.sleep(1) if turnback == "shuatu": # 返回冒险 self.click(480, 505) time.sleep(2) self.lock_img('img/zhuxianguanqia.jpg', elseclick=[(480, 513), (390, 369)], elsedelay=0.5) while True: screen_shot_ = self.getscreen() if UIMatcher.img_where(screen_shot_, 'img/zhuxianguanqia.jpg', at=(511, 286, 614, 314)): self.click(562, 253) time.sleep(0.5) else: break time.sleep(3) while True: screen_shot_ = self.getscreen() if UIMatcher.img_where(screen_shot_, 'img/normal.jpg', at=(660, 72, 743, 94)): break self.click(704, 84) time.sleep(0.5)