def main_process(times=3): h = env.get("game_leader_handle") l = GameInstance(h, "bai_gui_ye_xing_multi") h = env.get("game_member_handle") m = GameInstance(h, "bai_gui_ye_xing_multi") th1 = threading.Thread(target=b.main_process, args=( times, l.get_handle(), )) th1.setDaemon(True) th1.start() th2 = threading.Thread(target=b.main_process, args=( times, m.get_handle(), )) th2.setDaemon(True) th2.start()
def main_process(threshold=0.7, type=0, times=5, time_used=35): h = env.get("game_leader_handle") l = GameInstance(h, "mod_test") h = env.get("game_member_handle") m = GameInstance(h, "mod_test") th1 = threading.Thread(target=leader.main_process, args=( times, time_used, l.get_handle(), )) th1.setDaemon(True) th1.start() th2 = threading.Thread(target=member.main_process, args=( times, time_used, m.get_handle(), )) th2.setDaemon(True) th2.start()
def main_process(times=30, time_used=7): h = env.get("game_default_handle") g = GameInstance(h, "general") for i in range(times): logging.info("Start for times: " + str(i + 1) + ".") logging.info("Search for tiao_zhan.png.") p = g.wait_until(g.img_path("tiao_zhan"), timeout=time_used) g.random_sleep(1) g.random_click(p, 10) p = g.wait_until(g.img_path("sheng_li"), timeout=time_used * 5) p = u.offset_position(p, (300, 300)) u.random_sleep(1, 0.3) u.random_click(p, 20) p = g.wait_until(g.img_path("jie_suan"), timeout=time_used) u.random_sleep(2, 0.3) u.random_click(p, 20) u.toast("执行" + str(times) + "次完成.")
def main_process(threshold=0.7): if env.get("game_multi"): leader_handle = env.get("game_leader_handle") member_handle = env.get("game_member_handle") l = GameInstance(leader_handle, "match_test") m = GameInstance(member_handle, "match_test") template = cv2.imread(l.img_path("template")) l.match(l.get_screenshot(), template, show_result=True) m.match(m.get_screenshot(), template, show_result=True) else: h = env.get("game_default_handle") g = GameInstance(h, "match_test") template = cv2.imread(g.img_path("template")) g.match(g.get_screenshot(), template, threshold=threshold, show_result=True)
def main_process(times=1, time_used=35, handle=None): time_used_min = 7 DEFAULT_INVITED = False handle = utils.check_handle(handle) u = GameInstance(handle, "yu_hun_leader") logging.info("执行御魂(队长)" + str(times) + "次") for i in range(times): logging.info("第" + str(i + 1) + "次") # 锁定阵容 u.lock_lineup() # 点击挑战 logging.info("Search for tiao_zhan.png.") p = u.wait_until(img_path("tiao_zhan")) u.random_click(p, 20) # sleep以减少消耗 time.sleep(time_used_min) # 等待战斗结束 logging.info("等待胜利") p = u.wait_until(img_path("sheng_li"), timeout=time_used * 3) # 胜利下方点击 p = u.offset_position(p, (300, 300)) u.random_sleep(1, 0.3) u.random_click(p, 20) # 点赞 u.click_if_exists(u.img_path("dian_zan")) # 胜利下方点击 p = u.offset_position(p, (300, 300)) # 等待跳蛋 u.random_click(p, 20) logging.info("等待跳蛋") p = u.wait_until(img_path("jie_suan")) u.random_sleep(2, 0.3) u.random_click(p, 20) # 默认邀请好友 if not DEFAULT_INVITED: try: p = u.wait_until(img_path("mo_ren_yao_qing_hao_you"), timeout=1, interval=0.1, notify=False) if p is not None: u.random_click(p, 10) u.random_sleep(0.5) p = u.exists(img_path("que_ren")) u.random_click(p, 10) u.random_sleep(0.5) DEFAULT_INVITED = True except TimeoutError: pass # sleep以等待,等待稍久保证队员进入 u.random_sleep(1) try: p = u.wait_until(u.img_path("jia_ru_dui_wu"), timeout=20, interval=0.1, notify=False) if p is not None: logging.info("队员接受邀请") u.random_sleep(1) except TimeoutError: raise TimeoutError("未接受邀请")
def main_process(times=1, time_used=35, handle=None): handle = utils.check_handle(handle) u = GameInstance(handle, "yu_hun_member") # 最短时间,控制sleep以降低消耗 time_used_min = 7 logging.info("执行御魂(队员)" + str(times) + "次") INVITE_LOCKED = False # logging.info("开启加成") # bonus.main_process("yu_hun") for i in range(times): logging.info("第" + str(i + 1) + "次") # if not INVITE_LOCKED: # if u.current_scene() != "xie_zhan_dui_wu": # logging.info("等待接受邀请") # start = datetime.now() # while (True): # logging.info("111") # if u.click_if_exists(u.img_path("suo_ding_jie_shou_yao_qing"), interval=1): # logging.info("锁定接受邀请") # INVITE_LOCKED = True # time.sleep(0.2) # break # if u.click_if_exists(u.img_path("jie_shou_yao_qing"), # interval=1): # logging.info("接受邀请") # INVITE_LOCKED = False # time.sleep(0.2) # break # end = datetime.now() # if (end - start).seconds > 300: # logging.error("等待接受邀请超时,请重新启动") # return time.sleep(1) u.lock_lineup() time.sleep(time_used_min) logging.info("等待胜利") p = u.wait_until(u.img_path("sheng_li"), timeout=time_used * 3) u.random_sleep(1, 0.3) # 点赞 u.click_if_exists(u.img_path("dian_zan")) # 胜利下方点击 p = u.offset_position(p, (300, 300)) u.random_click(p, 20) # 等待跳蛋 logging.info("等待跳蛋") p = u.wait_until(u.img_path("jie_suan")) u.random_sleep(2, 0.3) p = u.offset_position(p, (300, 0)) u.random_click(p, 20) u.random_sleep(3, 0.3) if not INVITE_LOCKED: logging.info("接受邀请") start = datetime.now() while (True): if u.click_if_exists(u.img_path("suo_ding_jie_shou_yao_qing"), interval=1): logging.info("锁定接受邀请") INVITE_LOCKED = True time.sleep(0.2) break if u.click_if_exists(u.img_path("jie_shou_yao_qing"), interval=1): logging.info("接受邀请") INVITE_LOCKED = False time.sleep(0.2) break end = datetime.now() if (end - start).seconds > 5: logging.error("等待接受邀请超时,请重新启动") return # logging.info("关闭加成") # bonus.main_process("yu_hun") logging.info(str(times) + "次御魂(队员)完成")
def main_process(times=1, handle=None): handle = utils.check_handle(handle) u = GameInstance(handle, "bai_gui_ye_xing") img_dir = os.path.join(__file__, "..", "img") logging.info("将运行:"+str(times)+"次") INVITED_MAX = False INVITED = False if u.current_scene() is not None: u.goto_scene("bai_gui_ye_xing") for i in range(times): if not INVITED: if not INVITED_MAX: INVITED_MAX = False logging.info("第" + str(i + 1) + "次") # 邀请好友 logging.info("匹配 yao_qing_hao_you.png.") p = u.wait_until(img_path("yao_qing_hao_you")) u.random_sleep(1, 0.5) u.random_click(p, 10) u.random_sleep(1, 0.5) # 选择好友 logging.info("匹配 xuan_ze_hao_you.png.") p = u.wait_until(os.path.join( img_dir, "xuan_ze_hao_you.png"), threshold=0.5) u.random_sleep(1, 0.5) u.random_click(p, 5) try: # 邀请次数上限 logging.info("Search for yao_qing_ci_shu_shang_xian.png.") p = u.wait_until(img_path("yao_qing_ci_shu_shang_xian"), timeout=2, interval=0.1, notify=False) if p is not None: p = u.exists(img_path("guan_bi_xuan_ze_hao_you")) p = u.offset_position(p, (0, 200)) u.random_sleep(1, 0.5) u.random_click(p, 5) u.random_sleep(1, 0.5) INVITED_MAX = True i = i - 1 continue except TimeoutError: pass # 进入 logging.info("Search for jin_ru.png.") p = u.wait_until(img_path("jin_ru")) u.random_sleep(1, 0.5) u.random_click(p, 20) try: # 邀请次数上限 logging.info("Search for yao_qing_ci_shu_shang_xian.png.") p = u.wait_until(img_path("yao_qing_ci_shu_shang_xian"), timeout=2, interval=0.1, notify=False) if p is not None: p = u.exists(img_path("guan_bi_xuan_ze_hao_you")) p = u.offset_position(p, (0, 200)) u.random_sleep(1, 0.5) u.random_click(p, 5) u.random_sleep(1, 0.5) INVITED_MAX = True INVITED = True i = i - 1 continue except TimeoutError: pass u.random_sleep(1, 0.5) # 选择鬼王,选择中间的 logging.info("Search for xuan_ze_gui_wang.png.") try: p = u.wait_until(img_path("xuan_ze_gui_wang"), timeout=10) except TimeoutError: i = i - 1 INVITED = True continue # 点击中间的鬼王 u.random_sleep(1, 0.5) p = u.offset_position(p, (0, 300)) u.random_click(p, 20) u.random_sleep(2, 0.5) else: # 邀请 logging.info("Search for qu_xiao_xuan_ze_hao_you.png.") p = u.wait_until(img_path("qu_xiao_xuan_ze_hao_you")) u.random_sleep(1, 0.5) u.random_click(p, 20) u.random_sleep(1, 0.5) i = i - 1 INVITED = False continue # 开始 logging.info("Search for kai_shi.png.") p = u.wait_until(img_path("kai_shi")) u.random_sleep(1, 0.5) u.random_click(p, 20) u.random_sleep(3, 0.5) # 砸豆子 logging.info("开始砸豆子。") begin_time = datetime.now() while (True): # 判断是否完成,前面一直点一定概率直接跳过分享界面了 p = u.exists(img_path("feng_xiang")) if p != None: u.random_sleep(1, 0.2) p = u.position_relative(0.95, 0.55) u.random_click(p, 20) u.random_sleep(0.5, 0.2) logging.info("砸完了") break # 存在豆子获取 p = u.exists(img_path("dou_zi_huo_qu")) if p is not None: p = u.offset_position(p, (-30, -20)) u.random_click(p, 5) u.random_sleep(0.5, 0.2) # 概率up p = u.exists(img_path("gai_lv_up")) if p is not None: p = u.offset_position(p, (-30, -20)) u.random_click(p, 5) u.random_sleep(0.5, 0.2) # 好友概率up p = u.exists(img_path("hao_you_gai_lv_up")) if p is not None: p = u.offset_position(p, (-30, -20)) u.random_click(p, 5) u.random_sleep(0.5, 0.2) # 优先砸带灯笼的 p = u.exists(img_path("deng_long")) if p is not None: # 大概由于识别速度慢,要增加一定偏移才能砸到正下方 p = u.offset_position(p, (-100, 100)) u.random_click(p, 20) u.random_sleep(0.5, 0.2) else: p = u.position_relative(0.8, 0.55) u.random_click(p, 20) u.random_sleep(0.5, 0.2) # 分享界面出现以后一定概率直接跳过,检测到进入即视为当次完成 if u.exists(img_path("jin_ru")): logging.info("砸完了") break # 超时退出 if (datetime.now() - begin_time).seconds >= 100: logging.info("超时退出") break u.random_sleep(3, 0.3) logging.info("Finished.")
def main_process(accept=True, times=1, time_used=7): global STOP STOP.clear() STOP.set() img_dir = os.path.join(__file__, "..", "img") accept_path = os.path.join(img_dir, "accept.png") reject_path = os.path.join(img_dir, "reject.png") while (True): if not env.get("game_multi"): if accept: u.click_if_exists(accept_path, threshold=0.9) else: u.click_if_exists(reject_path, threshold=0.9) u.random_sleep(1, 0.2) else: l = GameInstance(env.get("game_leader_handle"), "xie_zuo") m = GameInstance(env.get("game_member_handle"), "xie_zuo") if accept: l.click_if_exists(accept_path, threshold=0.9) m.click_if_exists(accept_path, threshold=0.9) else: l.click_if_exists(reject_path, threshold=0.9) m.click_if_exists(reject_path, threshold=0.9) u.random_sleep(1, 0.2) if STOP.is_set(): break