def choose_the_latest_chapter(chapter): # 鼠标选择指定章节,鼠标滚轮一直滚到看到指定章节的模板为止,并点击 print("开始找最新章节,当前试图寻找 %d" % chapter + " 章") chapter_coordinate = identifyImg.identify_find_template_or_not("explore_choose_chapter.png", 0.85) if chapter_coordinate: mouse_move(chapter_coordinate['x'], chapter_coordinate['y']) time.sleep(1) while True: # 先找章节模板,找不到就滚动滚轮寻找 aim_of_chapter_coordinate = identifyImg.identify_find_template_or_not("explore_chapter_%d.png" % chapter, 0.9) if aim_of_chapter_coordinate: # 点击指定章节 mouse_click(aim_of_chapter_coordinate['x'], aim_of_chapter_coordinate['y']) # 等待屏幕移动出现选择难度及组队信息 wait_for_explore_button = identifyImg.look_for_template_for_a_moment_return_boolean("common_button_explore.png", 3.5, 0.85) # 看到屏幕出现等待信息后,判断是否点击了困难标志,否则无法组队 if wait_for_explore_button: hard_status_coordinate = identifyImg.identify_find_template_or_not("experience_hard.png", 0.85) # 如果看到了困难标志没有点上,点击 if hard_status_coordinate: mouse_click(hard_status_coordinate['x'],hard_status_coordinate['y']) # 点击组队,结束本方法 identifyImg.identify_template_click("common_button_creatteam.png", template_cv2_entity["common_button_creatteam.png"], 0.85) break # win32con.MOUSEEVENTF_WHEEL代表鼠标中轮,第四个参数正数代表往上轮滚,负数代表往下 win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, -128) time.sleep(0.3) print("choose_the_latest_chapter()结束") return
def choose_reward_by_time(): # 先找悬赏封印的【封印】二字,返回坐标 reward_invite_filename = "reward_invite.png" reward_invite_coordinate = identifyImg.identify_find_template_or_not( reward_invite_filename, 0.7) if reward_invite_coordinate.__len__() > 0: reward_refuse_filename = "reward_refuse.png" reward_refuse_coordinate = identifyImg.identify_find_template_or_not( reward_refuse_filename, 0.85) if reward_refuse_coordinate.__len__() > 0: # 如果过了18点,或者当天是周末,就接受悬赏,由于接受按钮在拒绝按钮上面,为了优化性能,将拒绝按钮y轴坐标减去86代表接受按钮坐标 if time.localtime().tm_hour > 17 or datetime.datetime.now( ).weekday() > 4: mouse_click(reward_refuse_coordinate['x'], reward_refuse_coordinate['y'] - 86) print("晚上6点以后开始接客啦!") else: # 拒绝是点击关闭按钮,而非点X拒绝,这样邀请人无感知,不然秒拒绝会被当作是外挂 mouse_click(reward_refuse_coordinate['x'] - 58, reward_refuse_coordinate['y'] - 327) print("有人邀请,立即点关闭并无视邀请,没有犹豫") if identifyImg.identify_find_template_or_not("multi_login.png", 0.8): print("重复登陆,终止程序") sys.exit() elif identifyImg.identify_find_template_or_not("shutdown_menu.png", 0.8): print("要休眠了,停止程序") sys.exit()
def change_the_level_max_hellspawn(level_max_flag_of_main_1, level_max_flag_of_main_2, level_max_flag_of_main_3): # 通过【预设阵容】按钮来点击更换阵容位置 change_battle_array_coordinate = identifyImg.identify_find_template_or_not("preinstall.png", 0.8) mouse_click(change_battle_array_coordinate['x'], change_battle_array_coordinate['y'] - 100) # 通过聊天频道按钮来定位更换狗粮位置 chat_button_coordinate = identifyImg.identify_find_template_or_not("common_button_chat.png", 0.8) print("通过聊天按钮来定位123号狗粮拖动位置,当前聊天按钮坐标:"+str(chat_button_coordinate)) No1_coordinate = {'x': chat_button_coordinate['x'] + 35, 'y': chat_button_coordinate['y'] + 335} No2_coordinate = {'x': chat_button_coordinate['x'] + 415, 'y': chat_button_coordinate['y'] + 335} No3_coordinate = {'x': chat_button_coordinate['x'] + 806, 'y': chat_button_coordinate['y'] + 335} # 打开换狗粮界面,只找1级狗粮,此方法不更换狗粮 shikigamiTools.prepare_to_find_N_card() # 循环更换满级的狗粮 while level_max_flag_of_main_1 or level_max_flag_of_main_2 or level_max_flag_of_main_3: changed_N_card_coordinate = shikigamiTools.find_N_card() if level_max_flag_of_main_1: operation.mouse_drag_to_target(changed_N_card_coordinate['x'], changed_N_card_coordinate['y'], No1_coordinate['x'], No1_coordinate['y']) level_max_flag_of_main_1 = False print("1号更换完毕"+str(No1_coordinate)) if level_max_flag_of_main_2: operation.mouse_drag_to_target(changed_N_card_coordinate['x'], changed_N_card_coordinate['y'], No2_coordinate['x'], No2_coordinate['y']) level_max_flag_of_main_2 = False print("2号更换完毕"+str(No2_coordinate)) if level_max_flag_of_main_3: operation.mouse_drag_to_target(changed_N_card_coordinate['x'], changed_N_card_coordinate['y'], No3_coordinate['x'], No3_coordinate['y']) level_max_flag_of_main_3 = False print("3号更换完毕"+str(No3_coordinate))
def foster_execute(): # 点击进入结界 identifyImg.look_for_template_to_click("boundary_entry_other_boundary.png", 0.8) # 寻找【友】字的坑位 if identifyImg.look_for_template_for_a_moment_return_boolean( "boundary_foster_available_flag.png", 8, 0.8): # 寻找目标式神,并返回等级的坐标位置 shikigami_level_coordinate = shikigamiTools.select_shikigami() # 如果没找到滑块,直接return if shikigami_level_coordinate.__len__() == 0: return # N卡被吃光,直接切回全部,随便选第一个寄养 elif shikigami_level_coordinate.__len__( ) > 0 and shikigami_level_coordinate['x'] == 0: identifyImg.wait_for_a_moment_and_click_template( "common_rare_N.png", 3, 0.8) identifyImg.wait_for_a_moment_and_click_template( "common_rare_button.png", 3, 0.8) temp_coordinate = identifyImg.identify_find_template_or_not( "common_rare_button.png", 0.8) mouse_click(temp_coordinate['x'], temp_coordinate['y']) identifyImg.wait_for_a_moment_and_click_template( "common_confirm_button.png", 3, 0.8) return else: # 如果正常返回坐标,开始寄养 mouse_click(shikigami_level_coordinate['x'], shikigami_level_coordinate['y']) identifyImg.wait_for_a_moment_and_click_template( "common_confirm_button.png", 3, 0.8) return datetime.datetime.now()
def single_player(omyuji_hwnd_info, mission): coordinate = Coordinate() # 点击探索 mouse_click( random.randint(coordinate.explore_x_left, coordinate.explore_x_left), random.randint(coordinate.explore_y_top, coordinate.explore_y_bottom)) time.sleep(3)
def choose_floor_and_start_battle(): # 点击战斗 mouse_click( random.randint(Coordinate.explore_start_battle_x_left, Coordinate.explore_start_battle_x_right), random.randint(Coordinate.explore_start_battle_y_top, Coordinate.explore_start_battle_y_top)) time.sleep(1) return
def wait_for_a_moment_and_click_template(template_file_name, waitting_time, threshold): return_result = False time_sum = 0 while time_sum < waitting_time: coordinate = identify_find_template_or_not(template_file_name, threshold) if coordinate: print("观察到模板" + template_file_name + "了,开始点击") mouse_click(coordinate['x'], coordinate['y']) return_result = True break else: time.sleep(0.5) time_sum += 0.5 return return_result
def look_for_template_to_click(template_file_name, threshold, x=None, y=None): find_template_flag = False identify_template_coordinate = identify_find_template_or_not( template_file_name, threshold) if x is None: x = 0 if y is None: y = 0 if identify_template_coordinate.__len__() > 0: print("找到模板" + template_file_name + "了,x:" + str(identify_template_coordinate['x']) + ",y:" + str(identify_template_coordinate['y'])) mouse_click(identify_template_coordinate['x'] + x, identify_template_coordinate['y'] + y) find_template_flag = True time.sleep(0.3) return find_template_flag
def single_work(omyuji_hwnd_info, mission): # 选择任务模式,mission字典中的key代表任务名称,会在每一个任务方法中取出,分析本次任务执行方式 for key in mission: # if key == "yuhun": # print("准备开始打御魂,预计打"+str(mission[key])+"次") # yuhun_singleplayer(omyuji_hwnd_array, mission[key]) if key == "yuling": print("准备开始打御灵,预计打"+str(mission[key])+"次") yuling.single_player(omyuji_hwnd_info, mission[key]) elif key == "infinite_breakthrough": # 点击探索 mouse_click(random.randint(Coordinate.explore_x_left, Coordinate.explore_x_left), random.randint(Coordinate.explore_y_top, Coordinate.explore_y_bottom)) time.sleep(3) breakthrough.infinite_breakthrough_loop(mission[key]) # 回到主界面 backToIndex()
def start_yuhun_to_attack_for_multi_player(omyuji_hwnd_info, config): time.sleep(1) # 获取窗口焦点 win32gui.SetForegroundWindow(list(omyuji_hwnd_info.keys())[1]) # 点击御魂 mouse_click(random.randint(Coordinate.yuhun_x_left, Coordinate.yuhun_x_right), random.randint(Coordinate.yuhun_y_top, Coordinate.yuhun_y_bottom)) time.sleep(2) # 点击大蛇打开御魂组队界面 mouse_click(random.randint(Coordinate.choose_yuhun_not_yeyuanhuo_x_left, Coordinate.choose_yuhun_not_yeyuanhuo_x_right), random.randint(Coordinate.choose_yuhun_not_yeyuanhuo_y_top, Coordinate.choose_yuhun_not_yeyuanhuo_y_bottom)) time.sleep(1) start_choose_floor_of_yuhun_to_attack(omyuji_hwnd_info)
def identify_template_click(template_file_name, template_imread, threshold): identify_result = False false_count = 0 while not identify_result: identify_coordinates = identify_find_template_or_not( template_file_name, threshold) if identify_coordinates.__len__() > 0: identify_result = True # print("点击坐标:x :" + str(identify_coordinates['x']) +" y :" + # str(identify_coordinates['y'])) mouse_click(identify_coordinates['x'], identify_coordinates['y']) else: false_count += 1 time.sleep(1) if false_count > 7: print("点击识别出现6次失败,放弃点击") print("想要点的模板名称为 :" + template_file_name) return return
def check_time_and_foster(task_type): # 进入方法时间,目前方法不够精确,所以是否寄养成功,都返回寄养时间,防止寄养失败后,每一次循环都启用一次寄养。 foster_time = datetime.datetime.now() # 首先检查人物所处位置,如果在探索菜单就先返回主界面 # 先找下有没有后退的蓝色按钮,不断地按直到没有找到 if identifyImg.look_for_template_for_a_moment_return_boolean( "back_button_blue.png", 2, 0.8): while identifyImg.look_for_template_for_a_moment_return_boolean( "back_button_blue.png", 5, 0.8): identifyImg.look_for_template_to_click("back_button_blue.png", 0.8) if identifyImg.look_for_template_for_a_moment_return_boolean( "main_menu_yinyangliao.png", 0.5, 0.8): print("检测到退回主界面了,开始点击阴阳寮") break # 点击主界面阴阳寮按钮 identifyImg.look_for_template_to_click("main_menu_yinyangliao.png", 0.8) # 点击结界,进入结界界面 identifyImg.wait_for_a_moment_and_click_template("boundary_button.png", 5, 0.8) # 点击式神育成 identifyImg.wait_for_a_moment_and_click_template("boundary_index.png", 8, 0.7) time.sleep(1) # 观察一下寄养按钮是否可用 foster_coordinate = identifyImg.identify_find_template_or_not( "boundary_foster_button.png", 0.8) # 如果寄养还没结束,则终止寄养流程,开始准备返回上一级调用 if not foster_coordinate: # 返回正在进行的任务,比如御魂 back_to_mission(task_type) return foster_time mouse_click(foster_coordinate['x'], foster_coordinate['y']) # 最多等待5秒寄养主界面弹出,方法是检测模板中的【结界卡】字样 identifyImg.look_for_template_for_a_moment_return_boolean( "boundary_foster_main_menu_flag.png", 5, 0.8) # 开始挑卡寄养,尽量选择收益高的 foster_time = check_friend_to_foster() # 挂完卡之后,开始返回进行中任务 back_to_mission(task_type) return foster_time
def check_friend_to_foster(): while True: # 检查当前画面是否有好友挂了卡并开放寄养,目前是鉴定鸟居图标是否出现 friend_boundary_available_coordinate = identifyImg.multi_template_coordinate( "boundary_available_flag.png", 0.9) # 如果没有人挂卡,终止循环 if friend_boundary_available_coordinate.__len__() == 0: print("无卡可挂,推测是没有收益的坑可蹲,记录当前时间,返回当前执行的任务。比如御魂") foster_time = datetime.datetime.now() break # 开始逐个点击可挂卡的好友 for coordinate in friend_boundary_available_coordinate: # 点击鸟居flag,代表该好友挂了卡 mouse_click(coordinate[0], coordinate[1]) identifyImg.wait_loading() time.sleep(1) if identifyImg.identify_find_template_or_not( "taiko_level_6.png", 0.8): print("六星太鼓赶紧寄养,赚飞了") foster_time = foster_execute() break elif identifyImg.identify_find_template_or_not( "taiko_level_6.png", 0.8): print("六星斗鱼太赚了,体力就是一切") foster_time = foster_execute() break elif identifyImg.identify_find_template_or_not( "taiko_level_4_and_5.png", 0.8): print("四五星太鼓,直接寄养") foster_time = foster_execute() break elif identifyImg.identify_find_template_or_not( "fish_level_4_and_5.png", 0.8): print("四星斗鱼,也行") foster_time = foster_execute() break # 这一轮没找到的话,就往下滚轮 for i in range(4): win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, -128) time.sleep(0.3) return foster_time
def selectFloor(n): getScreenshot('screen.bmp', 612, 335, 275, 255) img = opencv.imread('screen.bmp', 0) template = opencv.imread('tasks/tools/images/floor%d.jpg' % n, 0) res = opencv.matchTemplate(img, template, opencv.TM_CCOEFF_NORMED) threshold = 0.98 gps = None loc = np.where(res >= threshold) for pt in zip(*loc[::-1]): gps = pt if gps: loc_x = gps[0] + 612 + int(random.uniform(2, 20)) loc_y = gps[1] + 335 + int(random.uniform(3, 20)) mouse_click(loc_x, loc_y) else: # todo 滚动选择 pass time.sleep(0.5)
def check_battle_result(): battle_win_continue_filename = "battle_win_continue.png" battle_failed_filename = "battle_failed.png" # 计数,防止程序点出了战斗界面,但是循环还在一直判断战斗是成功了还是失败了。 # 如果超过10秒还在判断,证明程序已经误点出去,默认战斗成功 count = 0 while True: fail_result = identifyImg.identify_find_template_or_not( battle_failed_filename, 0.85) if fail_result.__len__() > 0: print("战斗失败") mouse_click(random_x, random_y) return False win_result = identifyImg.identify_find_template_or_not( battle_win_continue_filename, 0.85) if win_result.__len__() > 0: print("战斗胜利") mouse_click(random_x, random_y) return True if count < 10: count += 1 mouse_click(random_x, random_y) time.sleep(0.3) else: print("点了10次发现还是没有发现判断战斗结果的图标,证明程序误点出去了,默认战斗胜利") return True
def accept_invite_from_captain(omyuji_hwnd_info): # 切换大号接受 windowTools.switch_window(list(omyuji_hwnd_info.keys())[0]) # 添加意外处理,防止大号被6000御魂、掉线以及其他异常情况卡在战斗收益画面没有出来 if identifyImg.identify_find_template_or_not("money_ico.png",0.85): mouse_click(Coordinate.explore_getoutofbattle_x_left, Coordinate.explore_getoutofbattle_y_top) # 开始接受队长邀请 accept_xiaohao_invite = "accept_xiaohao_invite.png" for i in range(10): # 检测小号邀请信息,点击对号 xiaohao_invite_coordinate = identifyImg. \ identify_find_template_or_not(accept_xiaohao_invite, 0.8) if xiaohao_invite_coordinate: # 如果找到默认邀请了,仅点击对号接受邀请 if identifyImg.look_for_template_for_a_moment_return_boolean("continuous_invited_flag.png", 3, 0.8): mouse_click(xiaohao_invite_coordinate['x'] - 170, xiaohao_invite_coordinate['y'] + 10) print("invitationTask.py:检测到小号发来的默认邀请,仅点击对号接受本次邀请") time.sleep(0.2) break # 如果没找到默认邀请的标志,那么就是普通邀请 mouse_click(xiaohao_invite_coordinate['x'] - 95, xiaohao_invite_coordinate['y'] + 10) time.sleep(0.2) print("检测到小号发来的普通邀请,点击对号接受本次邀请") break # 切换队长号继续流程 windowTools.switch_window(list(omyuji_hwnd_info.keys())[1])
def invite_main_account(): print("Start with invite_main_account()") # 如果邀请失败了,临时重新打开御魂邀请界面邀请 checkk_explore_filename = "check_explore.png" checkk_explore = identifyImg.identify_find_template_or_not(checkk_explore_filename, 0.85) if checkk_explore.__len__() > 0: # 点击御魂 mouse_click(random.randint(Coordinate.yuhun_x_left, Coordinate.yuhun_x_right), random.randint(Coordinate.yuhun_y_top, Coordinate.yuhun_y_bottom)) time.sleep(2) # 点击大蛇 mouse_click(random.randint(Coordinate.choose_yuhun_not_yeyuanhuo_x_left, Coordinate.choose_yuhun_not_yeyuanhuo_x_right), random.randint(Coordinate.choose_yuhun_not_yeyuanhuo_y_top, Coordinate.choose_yuhun_not_yeyuanhuo_y_bottom)) yuhun.start_choose_floor_of_yuhun_to_attack() # 点击队友空位栏处的邀请图标邀请他人 identifyImg.wait_for_a_moment_and_click_template("start_to_invite.png", 3, 0.85) identifyImg.wait_for_a_moment_and_click_template("invite_ico.png", 3, 0.85) time.sleep(1) # 开始寻找大号头像并点击邀请 headportrait_of_main_account_filename = "headportrait_of_main_account.png" main_account_coordinate = identifyImg.identify_find_template_or_not( headportrait_of_main_account_filename, 0.8) if main_account_coordinate.__len__() > 0: # 找到头像后往右移动60像素点击,防止点击头像出现玩家信息操作界面 mouse_click(main_account_coordinate['x'] + 60, main_account_coordinate['y']) time.sleep(0.3) # 点击邀请 invite_button_filename = "invite_button.png" identifyImg.identify_template_click(invite_button_filename, template_cv2_entity[invite_button_filename], 0.8)
def m_c_eye(x, y, template_name=None): for i in range(2): screen_before = np.array(ImageGrab.grab(window_info_tuple)) mouse_click(x, y) time.sleep(1) screen_after = np.array(ImageGrab.grab(window_info_tuple)) # 先是RGB转换为BGR,然后再转为灰度图 gray_img_before = opencv.cvtColor( opencv.cvtColor(screen_before, opencv.COLOR_RGB2BGR), opencv.COLOR_BGR2GRAY) gray_img_after = opencv.cvtColor( opencv.cvtColor(screen_after, opencv.COLOR_RGB2BGR), opencv.COLOR_BGR2GRAY) match_res = opencv.matchTemplate(gray_img_before, gray_img_after, opencv.TM_CCOEFF_NORMED) loc = np.where(match_res >= 1) for pt in zip(*loc[::-1]): if pt: print("点击" + str(template_name) + "没反应,重点") continue return
def switch_on_buffer(type): while True: print("switch_on_buffer()尝试寻找加成灯笼图标") # 如果看到有寮突的关闭按键,点击关闭后再找灯笼 identifyImg.look_for_template_to_click("common_close_button.png", 0.8, 0, 0) # 点击加成按钮 buffer_button_explore_filename = "buffer_button_explore.png" buffer_button_coordinate = identifyImg.identify_find_template_or_not( buffer_button_explore_filename, 0.8) if buffer_button_coordinate.__len__() > 0: # 如果找到加成灯笼的坐标,点击之后检查觉醒图标是否出现 mouse_click(buffer_button_coordinate['x'], buffer_button_coordinate['y']) whether_page_of_buffer_is_available = check_whether_page_of_buffer_is_available( ) if whether_page_of_buffer_is_available: break time.sleep(0.5) # 选择要点击的buffer if type == "yuhun": yuhun_buffer_filename = "yuhun_buffer.png" yuhun_buffer_button_coordinate = identifyImg.identify_find_template_or_not( yuhun_buffer_filename, 0.85) time.sleep(0.8) if yuhun_buffer_button_coordinate.__len__() > 0: # 在坐标后面加上数字修正是为了点击buffer按钮,模板返回的坐标为模板左上角那一点 mouse_click(yuhun_buffer_button_coordinate['x'] + 105, yuhun_buffer_button_coordinate['y'] + 3) time.sleep(1) elif type == "experience": experience_buffer_filename = "experience_buffer.png" experience_buffer_button_coordinate = identifyImg.identify_find_template_or_not( experience_buffer_filename, 0.85) time.sleep(0.8) if experience_buffer_button_coordinate.__len__() > 0: # +100和+5是为了点击buffer按钮,模板返回的坐标为模板左上角那一点 mouse_click(experience_buffer_button_coordinate['x'] + 105, experience_buffer_button_coordinate['y'] + 3) time.sleep(1) # 点击加成按钮关闭buffer页面 mouse_click(buffer_button_coordinate['x'], buffer_button_coordinate['y']) time.sleep(0.8)
def switch_off_all_of_buffer(): print("进入switch_off_all_of_buffer()方法") while True: print("尝试寻找加成灯笼图标") # 点击加成按钮 buffer_button_explore_filename = "buffer_button_explore.png" buffer_button_coordinate = identifyImg.identify_find_template_or_not( buffer_button_explore_filename, 0.85) if buffer_button_coordinate.__len__() > 0: # 如果找到加成灯笼的坐标,点击之后检查觉醒图标是否出现 mouse_click(buffer_button_coordinate['x'], buffer_button_coordinate['y']) whether_page_of_buffer_is_available = check_whether_page_of_buffer_is_available( ) if whether_page_of_buffer_is_available: break time.sleep(0.5) buffer_on_filename = "buffer_on_little.png" # 截图判别模板次数 try_to_identify_count = 0 # 关掉的buffer数量计数 count = 0 # 执行try_to_identify_count数量的高频循环检查 while try_to_identify_count < 50: # 检测回数+1 try_to_identify_count += 1 buffer_on_coordinate = identifyImg.identify_find_template_or_not( buffer_on_filename, 0.95) time.sleep(0.2) if buffer_on_coordinate.__len__() > 0: # 在坐标后面加上数字修正是为了点击buffer按钮,模板返回的坐标为模板左上角那一点 mouse_click(buffer_on_coordinate['x'], buffer_on_coordinate['y']) # 关掉1个buffer之后,重置检测回数,可以将误开启的buffer再次关闭 try_to_identify_count = 0 count += 1 print("关完 " + str(count) + " 个") print("已关完全部buffer,退出switch_off_buffer()") # 点击加成按钮关闭buffer页面 mouse_click(buffer_button_coordinate['x'], buffer_button_coordinate['y']) time.sleep(0.8)
def battle_statistics_and_command(omyuji_hwnd_info, mission): residue_number = mission battle_count = 0 win_count = 0 # 寮突破是否可以继续打的Flag,True:可以打,False:不可以继续打了 whether_breakthrough_is_available = True # 切换大号开始判断首先要处理的事情,比如寄养、突破 windowTools.switch_window(list(omyuji_hwnd_info.keys())[0]) # 首先去寄养,然后再记下寄养的时间 the_last_foster_time = fosterCare.check_time_and_foster("yuhun") # 然后判断收益号是否开始执行个人突破,突破票28张以上就开打 breakthrough.AOP_for_breakthrough(omyuji_hwnd_info) # 切回队长小号开始流程 windowTools.switch_window(list(omyuji_hwnd_info.keys())[1]) # 开始进入刷御魂主流程 start_yuhun_to_attack_for_multi_player(omyuji_hwnd_info, mission) # 邀请大号,返回开始战斗图标坐标 start_battle_button_is_availeable_coordinate = invitationTask.invite_main_account_for_yuhun( omyuji_hwnd_info) # 点击开始战斗 mouse_click(start_battle_button_is_availeable_coordinate['x'], start_battle_button_is_availeable_coordinate['y']) # 获取当前时间点,用时间差计算何时进入寮突: the_last_breakthrough_union_time = datetime.now() while win_count < residue_number: # 进入大小号无限刷的循环 print("当前已打:" + str(battle_count) + "次,胜利:" + str(win_count) + "次,还需再打" + str(residue_number - win_count) + "次") # 进入战斗,注意当前是小号视角,退出战斗可以找开始战斗按钮是否出现 battle_result = fight.fight("common_team_start_battle_button.png") battle_count += 1 if battle_result: win_count += 1 # 设置默认邀请队友界面是否会弹出的Flag default_invite = False # 第一次组队,一定会弹出默认邀请 first_default_invite = True # 检测弹出【是否默认邀请队友界面】 if not default_invite and first_default_invite: # 开始执行点击默认邀请流程,首先要把首次进入战斗Flag设为False first_default_invite = False checkbox_need_to_click_filename = "checkbox_need_to_click.png" checkbox_need_to_click_coordinate = identifyImg.\ identify_find_template_or_not( checkbox_need_to_click_filename,0.85) if checkbox_need_to_click_coordinate.__len__() > 0: print("点击默认邀请队友") mouse_click(checkbox_need_to_click_coordinate['x'], checkbox_need_to_click_coordinate['y']) # 点击确定 common_confirm_button_filename = "common_confirm_button.png" identifyImg.identify_template_click( common_confirm_button_filename, template_cv2_entity[common_confirm_button_filename], 0.8) # 点了默认邀请之后,默认邀请Flag设置为True default_invite = False windowTools.switch_window(list(omyuji_hwnd_info.keys())[0]) check_explore_filename = "check_explore.png" # 切出去等待大号点出战斗,判断方式为左下角出现御魂图标 while True: time.sleep(0.6) print("点击屏幕退出战斗画面") # 为了防止弹出御魂6000超量警告,这里加一个判断点击 # 判断御魂数量大于6000 yuhun_number_exceeded_filename = "yuhun_number_exceeded.png" yuhun_number_exceeded_coordinate = identifyImg.identify_find_template_or_not( yuhun_number_exceeded_filename, 0.85) if yuhun_number_exceeded_coordinate.__len__() > 0: mouse_click(yuhun_number_exceeded_coordinate['x'], yuhun_number_exceeded_coordinate['y']) print("大号御魂超数了,赶紧去清了") # 如果没见到超量,就正常点击小号邀请 check_explore = identifyImg.identify_find_template_or_not( check_explore_filename, 0.75) if check_explore.__len__() > 0: break # 如果意外地弹出去直接进了队,那么离开点击 leave_the_team_button_filename = "leave_the_team_button.png" leave_the_team_button_coordinate = identifyImg.identify_find_template_or_not( leave_the_team_button_filename, 0.85) if leave_the_team_button_coordinate.__len__() > 0: break mouse_click(Coordinate.explore_getoutofbattle_x_left, Coordinate.explore_getoutofbattle_y_top) # 在接受前,上次寄养是否超过了6小时,如是,则先去寄养 if (datetime.now() - the_last_foster_time).seconds > 21600: # Sensitive operation!!! # 关buffer bufferTools.switch_off_all_of_buffer() # 寄养 the_last_foster_time = fosterCare.check_time_and_foster("yuhun") # Sensitive operation!!! # 开buffer bufferTools.switch_on_buffer("yuhun") # 在接受前,判断大号突破票是否大于28张,如是,则先进行突破 personal_breakthrough_ticket = observerTools.remaining_of_personal_breakthrough_ticket( ) print("当前突破票剩余:" + personal_breakthrough_ticket) if int(personal_breakthrough_ticket) > 28: # Sensitive operation!!! # 关buffer bufferTools.switch_off_all_of_buffer() # 开始突破 breakthrough.breakthrough_personal("yuhun") # Sensitive operation!!! # 开buffer bufferTools.switch_on_buffer("yuhun") # 接下来判断经过时间,用于进入寮突破 breakthrough_loop_time = datetime.now() time_lapse = (breakthrough_loop_time - the_last_breakthrough_union_time).seconds print("与上次突破时间相比,当前经过了:" + str(time_lapse) + "秒") if time_lapse > 300 or time_lapse < 5: # 加入定时寮突破 print("又该打寮突了,当前时间 :" + str(datetime.now())) if whether_breakthrough_is_available: # Sensitive operation!!! # 关buffer bufferTools.switch_off_all_of_buffer() # 开始寮突破 whether_breakthrough_is_available = breakthrough.start_to_breakthrough( "union", "yuhun") # Sensitive operation!!! # 开buffer bufferTools.switch_on_buffer("yuhun") # 记录打完突破的时间点,用于下一次计算时长 the_last_breakthrough_union_time = datetime.now() else: print("记得上一次看到100%被攻破了,那今天先不打寮突了") # 判断完个突(如果票够)和寮突(如果时间点对)后,点击对号接受组队 # mouse_click(Coordinate.accept_invite_x_left, Coordinate.accept_invite_y_top) accept_xiaohao_invite = "accept_xiaohao_invite.png" for i in range(10): # 检测小号邀请信息,点击对号 xiaohao_invite_coordinate = identifyImg. \ identify_find_template_or_not(accept_xiaohao_invite, 0.85) if xiaohao_invite_coordinate: # 如果找到默认邀请了,仅点击对号接受邀请 if identifyImg.look_for_template_for_a_moment_return_boolean( "continuous_invited_flag.png", 3, 0.85): mouse_click(xiaohao_invite_coordinate['x'] - 170, xiaohao_invite_coordinate['y'] + 10) print("yuhun.py :检测到小号发来的默认邀请,仅点击对号接受本次邀请") time.sleep(0.2) break # 如果没找到默认邀请的标志,那么就是普通邀请 mouse_click(xiaohao_invite_coordinate['x'] - 95, xiaohao_invite_coordinate['y'] + 10) print("检测到小号发来的普通邀请,点击对号接受本次邀请") time.sleep(0.2) break time.sleep(0.1) # 打完突破(如果打了)之后,切换小号观察大号是否进来,如是,开始战斗。如不是,重新邀请 windowTools.switch_window(list(omyuji_hwnd_info.keys())[1]) time.sleep(0.3) headportrait_of_main_account_filename = "headportrait_of_main_account_team_interface.png" headportrait_of_main_account_coordinate = \ identifyImg.identify_find_template_or_not(headportrait_of_main_account_filename, 0.85) if headportrait_of_main_account_coordinate.__len__() > 0: # 看开始战斗按钮是否可用,如有,则进行下一轮循环,直到打满输入次数 common_team_start_battle_button_filename = "common_team_start_battle_button.png" start_battle_button_is_availeable_coordinate = \ identifyImg.identify_find_template_or_not(common_team_start_battle_button_filename, 0.85) if start_battle_button_is_availeable_coordinate.__len__() > 0: print("邀请成功,退出invite_main_account_for_yuhun()") # 点击开始战斗 mouse_click(start_battle_button_is_availeable_coordinate['x'], start_battle_button_is_availeable_coordinate['y']) else: # 邀请大号,返回开始战斗图标坐标 start_battle_button_is_availeable_coordinate = invitationTask.invite_main_account_for_yuhun( omyuji_hwnd_info) # 点击开始战斗 mouse_click(start_battle_button_is_availeable_coordinate['x'], start_battle_button_is_availeable_coordinate['y'])
def read_number_of_physical_power_remaining(): screenshot.getScreenshot('D:\\win32Screenshot\\physical_power.bmp', Coordinate.physical_power_value_x_left, Coordinate.physical_power_value_y_top, 86, 21) read_screen_text = pytesseract.image_to_string( Image.open('D:\\win32Screenshot\\physical_power.bmp')) if read_screen_text is None: print("没读出来,什么破玩意") number_of_physical_power = str(read_screen_text).strip(" ").split("/")[0] return number_of_physical_power while True: time.sleep(1) windowTools.move_window_to_0_0() mouse_click(random.randint(570, 578), random.randint(311, 318)) time.sleep(1) try_find_tuizhi_button_count = 0 whether_tiaozhan_buttion = {} while try_find_tuizhi_button_count < 3: if try_find_tuizhi_button_count == 0: try_find_tuizhi_button_count += 1 mouse_click(random.randint(367, 400), random.randint(296, 331)) whether_tiaozhan_buttion = identifyImg.identify_find_template_or_not( "D:\\omyuji_ico\\tuizhi_superGhost_King.png", 0.5) if whether_tiaozhan_buttion.__len__() > 0: break elif try_find_tuizhi_button_count == 1: try_find_tuizhi_button_count += 1 mouse_click(random.randint(367, 400), random.randint(400, 420))
def city_of_sun(): # 点日轮之城活动主界面 identifyImg.look_for_template_to_click("sun_index.png", 0.85) # 10秒内等轮回秘境 identifyImg.wait_for_a_moment_and_click_template("lun_hui_mi_jing.png", 10, 0.85) # 等待出现轮回重置按钮出现,代表页面读取完毕 if identifyImg.look_for_template_for_a_moment_return_boolean( "reset_lunhui.png", 10, 0.85): # 开始打秘境大循环 while True: print("开始外层大循环,缓冲几秒") sleep(1) print("开始读取每一格坐标") # 如果有资源选取意愿,先点击御魂资源 identifyImg.look_for_template_to_click( "lunhuimijing_yuhun_ziyuan.png", 0.85) # 开始读取每个板块坐标 battle_list = identifyImg.multi_template_coordinate( "cityofsun.png", 0.9) # 逻辑:优先看资源格子、下一层,如果什么都没发现就开始正常翻格子遍历 # 下面的遍历是以每个板块坐标为单位 for i in battle_list: sleep(0.5) # 如果有资源选取意愿,先点击御魂资源 resources_button = identifyImg.identify_find_template_or_not( "lunhuimijing_yuhun_ziyuan.png", 0.85) if resources_button: mouse_click(resources_button['x'], resources_button['y']) identifyImg.wait_for_a_moment_and_click_template( "common_confirm.png", 3, 0.85) # 先看有没有宝箱 box = identifyImg.multi_template_coordinate( "lunhuimijing_box.png", 0.85) if box: count = box.__len__() print("有宝箱,拾取%d个宝箱" % count) for j in box: mouse_click(j[0], j[1]) # 等待箱子开完,点击屏幕取消掉奖励 identifyImg.wait_for_a_moment_and_click_template( "battle_win_continue.png", 5, 0.85) # 判断是否取消掉屏幕,如果没有,直接点到看不到达摩弹出的金币奖励图标为止 while identifyImg.identify_find_template_or_not( "money_ico.png", 0.9): print("持续点击到没有金币为止") identifyImg.look_for_template_to_click( "battle_win_continue.png", 0.85) # 再看有没有时曲碎片 shiqusuipian = identifyImg.multi_template_coordinate( "lunhuimijing_shiqusuipian.png", 0.9) if shiqusuipian: count = shiqusuipian.__len__() print("有碎片,拾取%d个碎片" % count) for k in shiqusuipian: mouse_click(k[0], k[1]) sleep(1) # 再看有没有下一层 sleep(0.5) next_floor = identifyImg.identify_find_template_or_not( "lunhuimijing_next_floor.png", 0.85) if next_floor: print("发现下一层了,直接进入下一层") mouse_click(next_floor['x'], next_floor['y']) # 点击下一层的时候有2种情况 # 第一种是第一次点击,出现BOSS战斗界面 sleep(1) boss_battle_button = identifyImg.identify_find_template_or_not( "lunhuimijing_start_battle.png", 0.85) if boss_battle_button: mouse_click(boss_battle_button['x'], boss_battle_button['y']) fight.fight("reset_lunhui.png") print("打完下一层BOSS了,等待2秒缓冲去下一层") sleep(2) # 第二种是打完boss了,弹出是否进入下一层,会现common的确定按钮,直接点击进入下一层 common_confirm_button = identifyImg.identify_find_template_or_not( "common_confirm_button.png", 0.85) if common_confirm_button: mouse_click(common_confirm_button['x'], common_confirm_button['y']) continue # 如果特殊资源格子都没发现,那么就开始正常点击每个板块翻 mouse_click(i[0], i[1]) sleep(0.3) # 找单人挑战的按钮 start_battle_button_cd = identifyImg.identify_find_template_or_not( "lunhuimijing_start_battle.png", 0.85) if start_battle_button_cd: mouse_click(start_battle_button_cd['x'], start_battle_button_cd['y']) fight.fight("reset_lunhui.png") else: continue
def breakthrough_personal(mode): time.sleep(0.5) print("开始进行个人突破") mouse_click( random.randint(Coordinate.breakthrough_x_left, Coordinate.breakthrough_x_right), random.randint(Coordinate.breakthrough_y_top, Coordinate.breakthrough_y_bottom)) time.sleep(1) # 标记当前玩家是否被攻破 battle_status = False # 开始个突大循环,一直到票为0之后才break while True: print("个突开始,首先读取剩余票数") breakthrough_personal_ticket = readContentOfScreen.read_number_of_screen( 'screenshot_temp\\breakthrough_ticket.png', Coordinate.breakthrough_personal_ticket_x_left, Coordinate.breakthrough_personal_ticket_y_top, 72, 26) print("突破票还有:" + breakthrough_personal_ticket + "张") # 突破票大于0再打突破 if int(breakthrough_personal_ticket) > 0: # 从1号玩家打到9号玩家 for i in range(1, 10): # 重置判断玩家是否被攻破计数 whether_battle_count = 0 print("开始打第" + str(i) + "号玩家") while True: # 判断如果被攻破,则去打下一个人,并将下一个人Flag标为False,防止一下全部跳过去 if battle_status: battle_status = False # print("将当前第" + str(i) + "号玩家被击破Flag设置为False") break if whether_battle_count < 2: try: print("开始读取剩余突破票数量,当前目标是第" + str(i) + "号玩家") breakthrough_personal_ticket = readContentOfScreen.read_number_of_screen( 'screenshot_temp\\breakthrough_ticket.png', Coordinate.breakthrough_personal_ticket_x_left, Coordinate.breakthrough_personal_ticket_y_top, 72, 26) print("突破票还有:" + breakthrough_personal_ticket + "张") except Exception as e: print("error! errormessage is : " + str(e)) breakthrough_personal_ticket = "0" time.sleep(1) if abs(int(breakthrough_personal_ticket)) > 0: # 点完任务之后是否有战斗按钮弹出,如果有则正常打,如果超过2次没有弹出,则证明该人物已经被突破 battle_false_count = 0 while True: if whether_battle_count > 2: print("点了2次没反应,应该是打完了,那么打下一个人") break if battle_false_count < 2: breakthrough_personal_info = Coordinate.breakthrough_personal_info[ i] mouse_click( breakthrough_personal_info['x'], breakthrough_personal_info['y']) time.sleep(1) attack_button_filename = "attack.png" whether_battle = identifyImg.identify_find_template_or_not( attack_button_filename, 0.85) if whether_battle.__len__() > 0: try: identifyImg.identify_template_click( attack_button_filename, template_cv2_entity[ attack_button_filename], 0.85) except Exception: break battle_result = fight.fight( "personal_breakthrough_flag.png") if battle_result and i % 3 == 0: time.sleep(0.5) for j in range(6): mouse_click( random.randint( Coordinate. breakthrough_personal_reward_x_left, Coordinate. breakthrough_personal_reward_x_right ), random.randint( Coordinate. breakthrough_personal_reward_y_top, Coordinate. breakthrough_personal_reward_y_bottom )) time.sleep( random.uniform(0.3, 0.8)) battle_status = True break elif battle_result: time.sleep(2) battle_status = True break else: battle_false_count += 1 print( "个突失败了!失败统计次数 + 1 ,当前失败次数 : " + str(battle_false_count)) battle_status = False else: whether_battle_count += 1 print("靠?打完了?我现在点了 " + str(whether_battle_count) + "次,再点 " + str(3 - whether_battle_count) + "次 ,再不行,就不打了") else: print("打了2次都没打过,放弃殴打,准备2秒后刷新下一批倒霉孩子") time.sleep(2) mouse_click( random.randint( Coordinate. breakthrough_personal_refresh_x_left, Coordinate. breakthrough_personal_refresh_x_right ), random.randint( Coordinate. breakthrough_personal_refresh_y_top, Coordinate. breakthrough_personal_refresh_y_bottom )) time.sleep(1) mouse_click( random.randint( Coordinate. breakthrough_personal_refresh_confirm_x_left, Coordinate. breakthrough_personal_refresh_confirm_x_right ), random.randint( Coordinate. breakthrough_personal_refresh_confirm_y_top, Coordinate. breakthrough_personal_refresh_confirm_y_bottom )) time.sleep(0.5) break else: return else: break else: #如果突破票小于0,退出个突最外层大循环 break if mode == "yuhun": # 首先点击个人选项卡,重置当前页面,防止卡在某一个弹出界面上 for i in range(3): mouse_click( random.randint(Coordinate.breakthrough_personal_x_left, Coordinate.breakthrough_personal_x_right), random.randint(Coordinate.breakthrough_personal_y_top, Coordinate.breakthrough_personal_y_bottom)) time.sleep(1.5) # 退出突破X键 identifyImg.look_for_template_to_click("common_close_button.png", 0.5, 0, 0) return elif mode == "yuling": yuling.start_choose_yuling_to_attack() elif mode == "infinite_union": # 点击个人突破选项卡,为了在外层使用BackToIndex()方法退出任务 for i in range(3): mouse_click( random.randint(Coordinate.breakthrough_personal_x_left, Coordinate.breakthrough_personal_x_right), random.randint(Coordinate.breakthrough_personal_y_top, Coordinate.breakthrough_personal_y_bottom)) # 退出突破X键 identifyImg.look_for_template_to_click("common_close_button.png", 0.5, 0, 0) time.sleep(1) else: print("personal_breakthrough()方法的mode参数未定义,继续进行退出流程") time.sleep(0.5) print("本次breakthrough_personal()循环结束") return
def breakWards(): # 点击探索 mouse_click(1000, 360) time.sleep(5)
def fight(template_filename=None): # 本次战斗结果返回值,True为胜利,否则失败 result = False print("fight()已启动,首先判断上一次操作是否真的进入了战斗,目前的方法是检测左下角自动图标有没有出现") # 判断战斗是否真正进入的循环次数,暂时先判断25次,每次1秒 whether_start_battle_try_count = 0 while True: if whether_start_battle_try_count < 25: if identifyImg.identify_find_template_or_not("word_auto.png", 0.80): # 看到自动图标出现,代表进入了战斗,跳出当前循环开始执行战斗流程 break else: whether_start_battle_try_count += 1 time.sleep(1) else: print("可能上一次操作没有真正进入流程,暂时先走战斗失败流程") return result # ready_button_filename = "ready_button.png" # whether_ready_button = identifyImage.identify_find_template_or_not( # ready_button_filename, template_cv2_entity[ready_button_filename], 0.85) # if whether_ready_button.__len__() > 0: # print("检测到战斗按钮,点击准备开始战斗") # identifyImage.identify_template_click( # ready_button_filename, template_cv2_entity[ready_button_filename], 0.8) # else: # print("没检测到准备按钮,推测阵容锁定,直接进入战斗") print("开始进入战斗") while True: if identifyImg.identify_find_template_or_not("word_auto.png", 0.85): # 检测为持续战斗就继续等待结束 time.sleep(2) else: print("没有检测到战斗状态,开始判断战斗结果") result = check_battle_result() break # 点击屏幕退出战斗画面 if template_filename is not None: # 尝试点击退出次数,如果超数一定数额,判定是不是要求默认邀请,或者御魂超数量6000了 try_count = 0 while True: out_of_fight_flag_coordinate = identifyImg.identify_find_template_or_not( template_filename, 0.75) print("等待模板" + template_filename + "的出现") if out_of_fight_flag_coordinate.__len__() > 0: print("已识别出进入战斗前模板:" + template_filename + " fight()方法结束") break # 超过一定尝试次数,开始特殊状态判断 if try_count >= 5: # 判断是否有默认组队 checkbox_need_to_click_filename = "checkbox_need_to_click.png" checkbox_need_to_click_coordinate = identifyImg. \ identify_find_template_or_not( checkbox_need_to_click_filename, 0.85) if checkbox_need_to_click_coordinate.__len__() > 0: print("点击默认邀请队友") mouse_click(checkbox_need_to_click_coordinate['x'], checkbox_need_to_click_coordinate['y']) # 点击确定 common_confirm_button_filename = "common_confirm_button.png" identifyImg.identify_template_click(common_confirm_button_filename, template_cv2_entity[common_confirm_button_filename], 0.85) break # 判断御魂数量大于6000 yuhun_number_exceeded_filename = "yuhun_number_exceeded.png" yuhun_number_exceeded_coordinate = identifyImg.identify_find_template_or_not( yuhun_number_exceeded_filename, 0.85) if yuhun_number_exceeded_coordinate.__len__() > 0: mouse_click(yuhun_number_exceeded_coordinate['x'], yuhun_number_exceeded_coordinate['y']) # 点击完超6000提醒后还要点击一下无影响位置,用于退出战斗 time.sleep(0.3) mouse_click(random_x, random_y) break # 判断掉线了 connecting_filename = "connecting.png" connecting_coordinate = identifyImg.identify_find_template_or_not( connecting_filename, 0.85) if connecting_coordinate.__len__() > 0: while True: print("掉线了!3秒后继续判断连接状态") time.sleep(3) still_connecting_coordinate = identifyImg.identify_find_template_or_not( connecting_filename, 0.85) if still_connecting_coordinate.__len__() > 0: print("还没连接上,等待中") continue else: print("重连回来了,继续流程,判断战斗是否退出") break if identifyImg.identify_find_template_or_not("multi_login.png", 0.8): print("重复登陆,终止程序") sys.exit() try_count += 1 print("没发现出去的迹象,继续点击,尝试次数:" + str(try_count)) mouse_click(random_x, random_y) time.sleep(0.5) return result
def breakthrough_union(mode): # 定义寮突破是否还可以继续打的Flag,这是一个返回值。True为可以(未攻破),False为不可以再打(已攻破) whether_breakthrough_is_available = True print("开始进行寮突破") time.sleep(1.5) mouse_click( random.randint(Coordinate.breakthrough_x_left, Coordinate.breakthrough_x_right), random.randint(Coordinate.breakthrough_y_top, Coordinate.breakthrough_y_bottom)) time.sleep(1.5) mouse_click( random.randint(Coordinate.breakthrough_union_x_left, Coordinate.breakthrough_union_x_right), random.randint(Coordinate.breakthrough_union_y_top, Coordinate.breakthrough_union_y_bottom)) time.sleep(1.5) whether_start = check_whether_start() # 点完勋章之后是否有战斗按钮弹出,如果有则正常打,如果超过2次没有弹出,则证明该人物已经被突破 whether_battle_count = 0 if whether_start: print("寮突开了,开始寮突循环") # 战斗失败次数统计 battle_false_count = 0 while True: if whether_battle_count > 2: print("点了2次发现没弹出战斗按钮,推测该人物已被攻破,开始判断是否整个寮突都打完了") # 判断寮突破是否被100%攻破了,如是,返回False(表示不可以再打了) check_breakthrough_availabe_filename = "check_breakthrough_availabe.png" check_breakthrough_availabe_corrdinate = identifyImg.identify_find_template_or_not( check_breakthrough_availabe_filename, 0.85) if check_breakthrough_availabe_corrdinate.__len__() > 0: whether_breakthrough_is_available = False break read_attack_remaining = readContentOfScreen.read_number_of_screen( 'screenshot_temp\\union.bmp', Coordinate.breakthrough_union_attack_remaining_x_left, Coordinate.breakthrough_union_attack_remaining_y_top, 56, 56) if read_attack_remaining.isdigit() is False: break print("剩余可攻击次数 :" + read_attack_remaining + " 当前失败次数统计 : " + str(battle_false_count)) attack_count = int(read_attack_remaining) if attack_count > 0: if battle_false_count < 2: # 开始点击勋章,或者空寻找槽位。优先打空勋章槽位,因为好打。 try: if identifyImg.identify_find_template_or_not( "medal-none.png", 0.8): identifyImg.identify_template_click( "medal-none.png", template_cv2_entity["medal-none.png"], 0.8) else: identifyImg.look_for_template_to_click( "medal.png", template_cv2_entity["medal.png"], 0.75) except Exception as e: print("error! errormessage is : " + str(e)) break time.sleep(1) # 点击勋章之后如果没有弹出进攻,说明已攻破。 # 计算失败次数,如果超过3次,那么猜测可能为突破完毕,终止本次突破 whether_battle = identifyImg.identify_find_template_or_not( "attack.png", 0.8) if whether_battle.__len__() > 0: try: identifyImg.identify_template_click( "attack.png", template_cv2_entity["attack.png"], 0.75) except Exception: break battle_result = fight.fight( "union_breakthrough_flag.png") if battle_result: battle_false_count = 0 else: battle_false_count += 1 print("寮突失败了!失败统计次数 + 1 ,当前失败次数 : " + str(battle_false_count)) else: whether_battle_count += 1 print("靠?打完了?我现在点了 " + str(whether_battle_count) + "次,再点 " + str(3 - whether_battle_count) + "次 ,再不行,就不打了") else: # 勋章ico,打人失败两次后,将鼠标移动到任意一个勋章位置,为了使接下来的滚轮操作生效。 # 不然如果鼠标处于界面外,滚轮动作将无法完成 medal_filename = "medal.png" medal_file_coordinateindex = identifyImg.identify_find_template_or_not( medal_filename, 0.75) if medal_file_coordinateindex.__len__() > 0: mouse_move(medal_file_coordinateindex['x'], medal_file_coordinateindex['y']) # 如果失败了2次还没打过,那么鼠标滚轮往下滚一点,打别人。 # win32con.MOUSEEVENTF_WHEEL代表鼠标中轮,第四个参数正数代表往上轮滚,负数代表往下 for i in range(4): win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, -128) time.sleep(0.3) battle_false_count = 0 else: break else: print("会长副会真懒,都 " + str(time.localtime().tm_hour) + " 点了还没开寮突") # 开始退出寮突破 # 首先点击个人选项卡,重置当前页面,防止卡在某一个弹出界面上 mouse_click(Coordinate.breakthrough_personal_x_left, Coordinate.breakthrough_personal_y_top) time.sleep(0.3) # 退出突破X键 mouse_click(Coordinate.breakthrough_logout_x_left, Coordinate.breakthrough_logout_y_top) # 开始执行返回进入寮突破流程之前的界面 if mode == "yuhun": # TODO return whether_breakthrough_is_available elif mode == "yuling": yuling.start_choose_yuling_to_attack() else: print("本次无限breakthrough_union()循环结束") time.sleep(0.5) return whether_breakthrough_is_available