Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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)
Ejemplo n.º 3
0
def choose_10_floor_of_yuhun_private_team():
    # 为了效率,默认跳过
    # # 副本类型选择魂十
    # mouse_move(Coordinate.create_team_choose_type_of_battle_x_left, Coordinate.create_team_choose_type_of_battle_y_top)
    # time.sleep(0.5)
    # mouseevent_wheel.scroll_down_to_the_bottom()
    # time.sleep(0.5)
    # 选择十层
    if not identifyImg.look_for_template_for_a_moment_return_boolean("check_floor_10.png", 2, 0.85):
        print("未选择十层,开始选择十层")
        mouse_move(Coordinate.create_team_choose_floor_of_battle_x_left, Coordinate.create_team_choose_floor_of_battle_y_top)
        mouseevent_wheel.scroll_down_to_the_bottom()
        # 滚轮滚到底之后,开始向上滚动寻找魂十
        while not identifyImg.look_for_template_for_a_moment_return_boolean("check_floor_10.png", 2, 0.85):
            time.sleep(0.3)
            win32api.mouse_event(win32con.MOUSEEVENTF_WHEEL, 0, 0, 32)
        time.sleep(0.5)
    # 限制60级进入
    if not identifyImg.look_for_template_for_a_moment_return_boolean("check_allowed_maxlevel.png", 2, 0.85):
        print("最大等级不是60级,开始调整等级限制")
        mouse_move(Coordinate.create_team_minimum_lv_x_left, Coordinate.create_team_minimum_lv_y_top)
        mouseevent_wheel.scroll_down_to_the_bottom()
        time.sleep(0.5)
        mouse_move(Coordinate.create_team_max_lv_x_left, Coordinate.create_team_max_lv_y_top)
        mouseevent_wheel.scroll_down_to_the_bottom()
        time.sleep(0.5)
    # 点击创建
    create_button_filename = "create_button.png"
    identifyImg.identify_template_click(create_button_filename, template_cv2_entity[create_button_filename], 0.75)
    time.sleep(1)
Ejemplo n.º 4
0
def start_choose_floor_of_yuhun_to_attack(omyuji_hwnd_info=None):
    # 选择组队
    common_button_creatteam_file = "common_button_creatteam.png"
    identifyImg.identify_template_click(common_button_creatteam_file, template_cv2_entity[common_button_creatteam_file], 0.8)
    time.sleep(1.5)
    # # 开始选择层数
    # team_choose_yuhun_floor_filename = "team_choose_yuhun_floor.png"
    # choose_floor_button_coordinate = identifyImage.identify_find_template_or_not(team_choose_yuhun_floor_filename,template_cv2_entity[team_choose_yuhun_floor_filename], 0.95)
    # if choose_floor_button_coordinate.__len__() > 0:
    #     mouse_move(choose_floor_button_coordinate['x'], choose_floor_button_coordinate['x'])
    #     mouseevent_wheel.scroll_down_to_the_bottom()
    # # 点击十层
    # floor_10_filename = "floor_10.png"
    # identifyImage.identify_template_click(floor_10_filename, template_cv2_entity[floor_10_filename], 0.95)
    # time.sleep(1)
    # 点击创建队伍
    create_team_filename = "create_team.png"
    identifyImg.identify_template_click(create_team_filename, template_cv2_entity[create_team_filename], 0.8)
    time.sleep(1)
    # 开始配置魂十-不公开队伍
    choose_10_floor_of_yuhun_private_team()
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
                "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))
            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
        else:
            try_find_tuizhi_button_count += 1
            mouse_click(random.randint(367, 400), random.randint(562, 570))
            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

    if whether_tiaozhan_buttion.__len__() > 0:
        physical_power = int(read_number_of_physical_power_remaining())
        if 0 <= physical_power <= 90:
            identifyImg.identify_template_click(
                "D:\\omyuji_ico\\tuizhi_superGhost_King.png", 0.8)
            fight()
        else:
            time.sleep(300)
    else:
        identifyImg.identify_template_click(
            "D:\\omyuji_ico\\back_button_blue.png", 0.7)
    time.sleep(5)
Ejemplo n.º 7
0
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'])
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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