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 prepare_to_find_N_card(): # 点击【全部】按钮,挑选式神的稀有度 if identifyImg.wait_for_a_moment_and_click_template("common_rare_button.png", 3,0.75): print("找到全部按钮,开始点击选择目标稀有度") time.sleep(1.5) # 选择N卡狗粮 identifyImg.wait_for_a_moment_and_click_template("common_rare_N.png", 3, 0.8) print("选择N卡狗粮")
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 shutdown_computer(type): print("开始执行休眠/重启/关机") sleep(1) identifyImg.wait_for_a_moment_and_click_template("start_button.png", 3, 0.8) sleep(1) identifyImg.wait_for_a_moment_and_click_template("shutdown.png", 3, 0.8) sleep(1) if type == "reset": identifyImg.wait_for_a_moment_and_click_template("reset.png", 3, 0.8) elif type == "shutdown": identifyImg.wait_for_a_moment_and_click_template( "shutdown.png", 3, 0.8) else: identifyImg.wait_for_a_moment_and_click_template("sleep.png", 3, 0.8)
def explore_main(omyuji_hwnd_info): print("start explore_main()") while True: # 切换队长号 win32gui.SetForegroundWindow(list(omyuji_hwnd_info.keys())[1]) print("进入点怪界面,先观察有没有BOSS") boss_appear_flag = identifyImg.look_for_template_for_a_moment_return_boolean("boss_appear.png", 1, 0.85) boss_flag = identifyImg.look_for_template_for_a_moment_return_boolean("boss.png", 1, 0.85) if boss_appear_flag or boss_flag: print("出BOSS了,开始打BOSS") identifyImg.wait_for_a_moment_and_click_template("boss.png", 5, 0.85) fight.fight_for_experience(omyuji_hwnd_info) identifyImg.look_for_template_to_click("monster.png",0.85) fight.fight_for_experience(omyuji_hwnd_info)
def back_to_mission(task_type): # 挂完卡之后,开始退出界面,方法是不断地点击蓝色退后按钮,直至出现阴阳寮主界面 while True: identifyImg.wait_for_a_moment_and_click_template( "back_button_blue.png", 4, 0.8) if identifyImg.identify_find_template_or_not("boundary_button.png", 0.8): identifyImg.look_for_template_to_click("common_close_button.png", 0.8) # 添加新版返回按钮的点击 identifyImg.look_for_template_to_click( "common_back_button_new.png", 0.8) break if task_type == "yuhun": identifyImg.look_for_template_to_click("explore_main_button.png", 0.7) elif task_type == "infinite_breakthrough": identifyImg.look_for_template_to_click("explore_main_button.png", 0.7)
def check_level_of_hellspawn(omyuji_hwnd_info): time.sleep(0.5) # 定义各个式神满级状态 level_max_flag_of_main_1 = False level_max_flag_of_main_2 = False level_max_flag_of_main_3 = False # 首先更换收益号狗粮 win32gui.SetForegroundWindow(list(omyuji_hwnd_info.keys())[0]) # 开始逐个判断3个位置的式神满级情况 # 注意,次方法通过截取屏幕对应位置式神的图片来识别【满】字判断哪个位置有式神满级 custom_1_coordinate = ( Coordinate.experience_1_member_x_left, Coordinate.experience_1_member_y_top, Coordinate.experience_1_member_x_right, Coordinate.experience_1_member_y_bottom, ) level_max_flag = identifyImg.identify_find_template_or_not("full_level.png", 0.85, custom_1_coordinate) if level_max_flag: level_max_flag_of_main_1 = True custom_2_coordinate = ( Coordinate.experience_2_member_x_left, Coordinate.experience_2_member_y_top, Coordinate.experience_2_member_x_right, Coordinate.experience_2_member_y_bottom, ) level_max_flag = identifyImg.identify_find_template_or_not("full_level.png", 0.85, custom_2_coordinate) if level_max_flag: level_max_flag_of_main_2 = True custom_3_coordinate = ( Coordinate.experience_3_member_x_left, Coordinate.experience_3_member_y_top, Coordinate.experience_3_member_x_right, Coordinate.experience_3_member_y_bottom, ) level_max_flag = identifyImg.identify_find_template_or_not("full_level.png", 0.85, custom_3_coordinate) if level_max_flag: level_max_flag_of_main_3 = True # 如果有式神满级,点击至更换式神界面 if level_max_flag_of_main_1 or level_max_flag_of_main_2 or level_max_flag_of_main_3: # 开始把满级式神更换至1级式神 print("检测到有式神满级,开始切换成1级狗粮") change_the_level_max_hellspawn(level_max_flag_of_main_1, level_max_flag_of_main_2, level_max_flag_of_main_3) # 返回战斗界面 identifyImg.wait_for_a_moment_and_click_template("common_exit_battle.png", 3, 0.8)
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 invite_main_account_experience(omyuji_hwnd_info, chapter): # 首先等待看见大号名字 main_account_appeare_flag = identifyImg.wait_for_a_moment_and_click_template("headportrait_of_main_account.png", 3, 0.85) if not main_account_appeare_flag: # 如果出现异常,直接点击X退出到探索主界面,重新选择章节再邀请一次。 catch_invite_main_account_error(chapter) # invite_click_is_done_flag = identifyImg.wait_for_a_moment_and_click_template("invite_click_is_done.png", 2, 0.85) # if not invite_click_is_done_flag: # # 如果出现异常,直接点击X退出到探索主界面,重新选择章节再邀请一次。 # catch_invite_main_account_error(chapter) # 疯狂邀请至大号进来为止 while True: # 点击邀请 identifyImg.wait_for_a_moment_and_click_template("invite_button.png", 1, 0.85) # 接受队长邀请 accept_invite_from_captain(omyuji_hwnd_info) # 判断大号是否进入 success_flag = identifyImg.look_for_template_for_a_moment_return_boolean("experience_move_left.png", 9, 0.85) if success_flag: print("end invite_main_account_experience()") return
def start_to_battle_every_30_min(template_path): omyuji_hwnd_info = hwndInfo.getHwndInfo() omyuji_hwnd_array = list(omyuji_hwnd_info.keys()) windowTools.switch_window(omyuji_hwnd_array[0]) while True: sleep(1) # 读取体力 phycial_power = readContentOfScreen.read_number_of_screen( r"D:\PyCharm 2018.3.4\workspace\Omyuji\screenshot_temp\breakthrough_ticket.png", 1020, 46, 81, 22) if int(phycial_power) <= 100: # 关闭居酒屋 identifyImg.wait_for_a_moment_and_click_template( r"D:\PyCharm 2018.3.4\workspace\Omyuji\omyuji_ico\common_close_button.png", 5, 0.7) sleep(1) # 打开澡堂 identifyImg.wait_for_a_moment_and_click_template( r"D:\PyCharm 2018.3.4\workspace\Omyuji\omyuji_ico\festival_bashroom.png", 5, 0.8) sleep(1) # 泡澡 identifyImg.wait_for_a_moment_and_click_template( r"D:\PyCharm 2018.3.4\workspace\Omyuji\omyuji_ico\festival_bash.png", 5, 0.8) sleep(1) # 关闭澡堂 identifyImg.wait_for_a_moment_and_click_template( r"D:\PyCharm 2018.3.4\workspace\Omyuji\omyuji_ico\common_close_button.png", 5, 0.8) sleep(1) # 打开居酒屋 identifyImg.wait_for_a_moment_and_click_template( r"D:\PyCharm 2018.3.4\workspace\Omyuji\omyuji_ico\fastive_bar.png", 5, 0.8) sleep(1) # 继续打居酒屋 identifyImg.wait_for_a_moment_and_click_template( r"D:\PyCharm 2018.3.4\workspace\Omyuji\omyuji_ico\fastive_battle_button.png", 5, 0.8) fight.fight( r"D:\PyCharm 2018.3.4\workspace\Omyuji\omyuji_ico\fastive_battle_button.png" ) sleep(3)
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