Example #1
0
def pick_stage():
    # 判断港口是否满员
    check_port_full()

    auto_adb = AutoAdb()
    # 判断是否已经在关卡中
    res = auto_adb.wait('temp_images/stage/in-stage.png',
                        max_wait_time=2).is_valuable()
    if res:
        return

    # 确定进入
    target_stage_list = TempUtils.get_temp_rel_path_list(
        'temp_images/target-stage')
    start_time = datetime.now()
    while True:
        duration = (datetime.now() - start_time).seconds
        print('\r扫描目标关卡中 ... %ds' % duration, end='')
        loc = auto_adb.get_location(*target_stage_list)
        if loc is not None:
            break

    print('%s √' % loc.temp_rel_path)
    loc.click()
    # 这里不是重复, 是确实要点两下. 一次确认关卡, 一次确认队伍
    auto_adb.wait('temp_images/stage/into-confirm.png').click()
    auto_adb.wait('temp_images/stage/into-confirm.png',
                  episode=check_port_full).click()
    # 特殊关卡会提示更多
    auto_adb.wait('temp_images/fight/fight-confirm.png',
                  max_wait_time=3).click()

    # 确保已经进入关卡
    auto_adb.wait('temp_images/stage/in-stage.png')
Example #2
0
def fight_stage(stage_temp_list):
    if stage_temp_list is None or len(stage_temp_list) == 0:
        print('目标关卡未指定')
        exit(1)

    auto_adb = AutoAdb()
    # 判断是否已经在关卡中
    in_enemy = PageUtils.in_enemy_page()
    if in_enemy:
        fight_all_enemy()
        return

    # 确定进入
    timer = Timer()
    while True:
        print('\r扫描目标关卡中 ... %ds ' % timer.get_duration(), end='')
        loc = auto_adb.get_location(*stage_temp_list)
        if loc is not None:
            break

    print('%s √' % loc.temp_rel_path)
    loc.click()  # 点击关卡图标
    confirmed = confirm_stage_team()  # 确认队伍
    if not confirmed:  # 如果队伍确认失败,则重新做一次
        fight_stage(stage_temp_list)
Example #3
0
def run():
    PageUtils.to_main_page()

    adb = AutoAdb()
    adb.click('temp_images/daily-task/left-notice.png')
    complete = adb.get_location(
        'temp_images/daily-task/delegation/complete.png').click()
    if not complete:
        print('没有委托任务')
        return

    while True:
        success_temp = [
            'temp_images/daily-task/delegation/success.png',  # 委托成功
            'temp_images/daily-task/delegation/success-1.png'  # 点击继续
        ]
        success = adb.get_location(*success_temp).click()
        if not success:
            break
Example #4
0
def to_main_page():
    adb = AutoAdb()
    temp_list = [
        'temp_images/page/main-page-button.png',  # 主页按钮
        'temp_images/page/close.png',  # 关闭按钮
        'temp_images/page/close-1.png',  # 关闭按钮
        'temp_images/page/back.png',  # 返回按钮
        'temp_images/page/back-2.png'  # 返回按钮
    ]
    while True:
        # 如果已经在主页则直接返回
        if in_main_page():
            return True
        # 尝试点击返回按钮
        loc = adb.get_location(*temp_list)
        if loc is None:  # 如果没找到合理的返回按钮,则点击左上角尝试
            Location(adb, None, 10, 10).click()
        else:
            loc.click()
Example #5
0
def provoke_enemy():
    # 这里要多等待几秒, 因为经常会有个动画影响寻敌
    time.sleep(3)

    auto_adb = AutoAdb()
    check = auto_adb.check('temp_images/stage/in-unit.png')
    if check:
        print('关卡已经结束')
        return False

    # 弹药为空时切换到第二舰队
    if auto_adb.check('temp_images/stage/bullet-empty.png'):
        auto_adb.wait('temp_images/stage/switch-over.png').click(2)

    image_rel_path_list = TempUtils.get_temp_rel_path_list('temp_images/enemy')

    slider = Slider()
    while True:
        print('寻找敌人 ... ')
        enemy_loc = auto_adb.get_location(*image_rel_path_list)
        if enemy_loc is None:
            slider.slider()
            continue

        # 如果找到的是boss, 且当前是第一队, 则切换到第二队开始寻找敌人
        is_boss = 'boss' in enemy_loc.temp_rel_path
        is_first_team = auto_adb.check('temp_images/stage/team-1.png')
        if is_boss and is_first_team:
            auto_adb.wait('temp_images/stage/switch-over.png').click(2)
            continue

        enemy_loc.click()
        # 等待进击按钮出现, 期间会不断处理意外情况, 如果指定时间内出现按钮, 则执行结束, 否则再次循环
        res = auto_adb.wait('temp_images/fight/fight.png',
                            max_wait_time=8,
                            episode=deal_accident_when_provoke_enemy).click()
        if res:
            # 是否出现满员提示
            check_port_full()
            return True
        else:
            # 如果点击后未进入确认界面, 说明那里不可到达, 此时去除image_rel_path_list中的值
            image_rel_path_list.remove(enemy_loc.temp_rel_path)
Example #6
0
def confirm_stage_team():
    adb = AutoAdb()
    timer = Timer()
    while True:
        print('\r确认关卡队伍中。。。 %ds ' % timer.get_duration(), end='')
        # 如果已经进入敌人列表界面,则跳出循环
        if PageUtils.in_enemy_page():
            print(' √')
            fight_all_enemy()  # 战斗
            return True

        button_list = [
            'temp_images/stage/immediate-start.png',  # 立刻前往
            'temp_images/stage/weigh-anchor.png',  # 出击按钮
            'temp_images/fight/fight-confirm.png'  # 特殊关卡会提示更多
        ]
        button_loc = adb.get_location(*button_list)
        if button_loc is not None:
            button_loc.click()
        port_full = PortUtils.check_port_full()
        if port_full:
            return False
def run():
    print('日常巡检开始。。。')

    adb = AutoAdb()
    notice_loc = adb.get_location('temp_images/daily-task/notice.png')
    if not notice_loc:
        print('没有待处理的任务,巡检结束')
        return

    # 菜单位置
    menu_pos = [
        Location(adb, None, 628, 674, 'life-area'),  # 生活区
        Location(adb, None, 946, 674, 'missions'),  # 任务
    ]
    nearest_loc = notice_loc.get_nearest(menu_pos)
    nearest_loc.click()
    nearest_remark = nearest_loc.remark
    if nearest_remark == 'life-area':
        check_life_area(adb)
    elif nearest_remark == 'missions':
        deal_missions(adb)
    else:
        print('不能分辨出处理任务')
Example #8
0
def fight_stage(stage_temp_list):
    if stage_temp_list is None or len(stage_temp_list) == 0:
        print('目标关卡未指定')
        exit(1)

    auto_adb = AutoAdb()
    # 判断是否已经在关卡中
    wind_up_stage_fight()

    # 确定进入
    timer = Timer()
    while True:
        print('\r扫描目标关卡中 ... %ds ' % timer.get_duration(), end='')
        loc = auto_adb.get_location(*stage_temp_list)
        if loc is not None:
            break

    print('%s √' % loc.temp_rel_path)
    loc.click()  # 点击关卡图标
    confirm_result = confirm_stage_team()  # 确认队伍, 战斗
    if confirm_result is None:  # 如果关卡进入失败, 则重新尝试
        print('关卡进入失败, 重新尝试...')
        fight_stage(stage_temp_list)
    return confirm_result