Exemplo n.º 1
0
def fight():
    adb = AutoAdb()
    # 战斗前各种按钮的点击
    while True:
        if PageUtils.in_fight_page():
            break
        click = adb.click('temp_images/fight/fight.png')
        if click:
            continue
        retired = PortUtils.check_port_full()
        if retired:  # 如果发生了退役操作,则再次点击确认按钮
            AutoAdb().wait('temp_images/fight/fight.png').click()
            continue
        low_mood = adb.check('temp_images/fight/low-mood.png')
        if low_mood:
            print('低心情状态,脚本终止')
            exit()

    print('战斗开始 >>>')
    adb.wait('temp_images/fight/fight-finish.png', cycle_interval=5)

    # 战斗结束
    fight_result = None
    ending_loc = Location(adb, None, 1160, 690)
    while True:
        if fight_result is None:
            # 处理新船
            new_ship = adb.check('temp_images/fight/new-ship.png')
            if new_ship:
                print('发现新船!!')
                fight_result = True
                ending_loc.click()
                adb.click('temp_images/confirm-btn.png')
                continue
            # 处理失败
            fail_confirm = adb.click('temp_images/fight/fail-confirm.png')
            if fail_confirm:
                fight_result = False
                # 战队难以成型时点击确定
                adb.wait('temp_images/confirm-btn.png',
                         max_wait_time=3).click()
                break
        # 持续点击右下角
        ending_loc.click()
        # 回到 stage列表页面 或 敌人列表页面 也说明战斗已经结束
        if adb.check(
                'temp_images/page/in-stage.png',  # stage列表
                'temp_images/page/in-enemy.png',  # enemy列表
                'temp_images/page/main-page-button.png'):  # 日常任务结束后的界面
            fight_result = True
            break

    print('战斗胜利~(~ ̄▽ ̄)~' if fight_result else '战斗失败 >_<')
    # 战斗结束后可能出现紧急任务提示
    # 由于是透明遮罩, 所以无法根据其他元素是否显示而做出反应, 只能等一定的时间
    adb.wait('temp_images/confirm-btn.png', max_wait_time=2).click()
    return fight_result
Exemplo n.º 2
0
def back():
    temp_list = [
        'temp_images/page/back.png',  # 返回按钮
        'temp_images/page/back-2.png'  # 返回按钮
    ]
    loc = AutoAdb().get_location(*temp_list)
    if loc is not None:
        print('点击页面返回按钮')
        loc.click()
Exemplo n.º 3
0
def run():
    adb = AutoAdb()
    blank_loc = Location(adb, None, 600, 30)

    PageUtils.to_main_page()
    # 点击生活区
    Location(adb, None, 580, 680).click()
    # 点击指挥喵
    Location(adb, None, 980, 460).click()
    # 判断有无免费订购。
    have_free = adb.click("temp_images/daily-task/meow/free-meow.png", threshold=0.95)
    if have_free:
        # 第二次判断
        have_free = adb.check("temp_images/daily-task/meow/free-meow-1.png", threshold=0.95)
    if have_free:
        print('领取每日免费喵箱...')
        # 结算
        adb.wait('temp_images/daily-task/meow/buy.png').click()
        # 点击确定
        adb.wait('temp_images/daily-task/meow/confirm.png').click()
        # 二次确定
        adb.wait("temp_images/click-to-continue.png").click()
        # 关闭领取对话框
        blank_loc.click()

    # 点击训练
    Location(adb, None, 1200, 680).click()
    # 等待对话框打开
    adb.wait('temp_images/daily-task/meow/in-lesson-page.png')
    while adb.click('temp_images/daily-task/meow/lesson-finish.png', wait_time=2):
        print('领取训练完成的喵...')
        meow_full = adb.check('temp_images/daily-task/meow/meow-full.png')
        if meow_full:
            print('喵窝已满!!!请先处理!!!')
            return
        while True:
            if adb.click('temp_images/daily-task/meow/confirm.png'):
                continue
            if adb.click('temp_images/daily-task/meow/new-meow-btn.png'):
                continue
            if adb.check('temp_images/daily-task/meow/in-lesson-page.png'):
                break

    print('训练新的喵...')
    # 点击“开始训练”
    adb.wait('temp_images/daily-task/meow/start-lesson.png').click()
    # 点击“一键选择”
    adb.wait("temp_images/daily-task/meow/pick-all.png").click()
    # 点击“开始训练”
    adb.wait('temp_images/daily-task/meow/start-lesson.png').click()
    # 点击确认
    adb.wait("temp_images/daily-task/meow/confirm.png", max_wait_time=3).click()
    # 回到主页
    PageUtils.to_main_page()
    print('指挥喵处理完毕')
Exemplo n.º 4
0
def deal_accident_when_provoke_enemy():
    auto_adb = AutoAdb()
    # 自动战斗
    res = auto_adb.click('temp_images/fight/auto-fight-confirm-1.png')
    if res:
        print('确认自律战斗')
        auto_adb.wait('temp_images/fight/auto-fight-confirm-2.png').click()
    # 处理途中获得道具的提示
    auto_adb.click('temp_images/stage/get-tool.png')
    # 处理伏击
    auto_adb.click('temp_images/stage/escape.png')
Exemplo n.º 5
0
def to_stage_page():
    adb = AutoAdb()
    if in_stage_page():
        return True

    to_main_page()
    adb.click('temp_images/page/main-fight.png')
    # 可能正处在战斗关卡,自动战斗
    fight = StageFight.wind_up_stage_fight()
    if fight:
        return to_stage_page()
    return True
Exemplo n.º 6
0
def fight_finish():
    adb = AutoAdb()

    # 等待战斗结束
    timer = Timer()
    while True:
        print('\r等待战斗结束 %ds ...' % timer.get_duration(), end='')
        skip_dialog()
        time.sleep(3)  # 每次循环加一个等待时间,降低cpu占用
        if adb.check('temp_images/fight/fight-finish.png'):
            print(' √ 总耗时: %ds' % timer.get_duration())
            break

    # 战斗结束
    fight_result = None
    ending_loc = Location(adb, None, 1160, 690)
    while True:
        if fight_result is None:
            # 处理新船
            new_ship = adb.check('temp_images/fight/new-ship.png')
            if new_ship:
                print('发现新船!!')
                fight_result = True
                ending_loc.click()
                adb.click('temp_images/confirm-btn.png')
                continue
            # 处理失败
            fail_confirm = adb.click('temp_images/fight/fail-confirm.png')
            if fail_confirm:
                fight_result = False
                # 战队难以成型时点击确定
                adb.wait('temp_images/confirm-btn.png', max_wait_time=3).click()
                break
        # 持续点击右下角
        ending_loc.click()
        # 回到 stage列表页面 或 敌人列表页面 也说明战斗已经结束
        if adb.check('temp_images/page/in-stage.png',  # stage列表
                     'temp_images/page/in-enemy.png',  # enemy列表
                     'temp_images/page/in-daily.png'):  # 日常任务结束后的界面
            fight_result = True
            break
        if adb.check('temp_images/page/in-operation.png'):
            print('误入演习界面,退出。。。')
            PageUtils.back()
            continue

    print('战斗胜利~(~ ̄▽ ̄)~' if fight_result else '战斗失败 >_<')
    # 战斗结束后可能出现紧急任务提示
    # 由于是透明遮罩, 所以无法根据其他元素是否显示而做出反应, 只能等一定的时间
    adb.wait('temp_images/confirm-btn.png', max_wait_time=2).click()
    return fight_result
Exemplo n.º 7
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
Exemplo n.º 8
0
def deal_sos_sign():
    adb = AutoAdb()
    adb.wait('temp_images/sos/sos-signal.png').click()

    # 将已经开启的潜艇关卡解决掉
    goto_stage_page = adb.click('temp_images/sos/goto-stage-page.png')
    if goto_stage_page:
        # 有些情况会直接进入关卡,因此不需要“点击关卡”
        print('发现已经开启的关卡,即将进入战斗。。。')
        if PageUtils.in_enemy_page():
            StageFight.fight_all_enemy()
        else:
            StageFight.fight_stage(['temp_images/sos/stage-icon.png'])
        return True
    # 搜索新的信号
    print('搜索新的信号。。。')
    adb.click('temp_images/sos/search-signal.png')
    while True:
        if adb.check('temp_images/sos/no-chance.png'):
            print('已经没有新的信号,SOS关卡执行完毕,脚本退出')
            PageUtils.to_stage_page()
            exit()

        # 如果有确认按钮,则点击确认,前往关卡
        adb.click('temp_images/confirm-btn.png')
        # 如果已经发现了关卡按钮,则点击
        click_stage = adb.click('temp_images/sos/stage-icon.png')
        if click_stage:
            print('进入SOS关卡战斗。。。')
            confirmed = StageFight.confirm_stage_team()
            if not confirmed:
                continue
            return True
Exemplo n.º 9
0
def run():
    StageFight.wind_up_stage_fight()

    adb = AutoAdb(test_device=True)
    temp_list = PathUtils.get_temp_rel_path_list(
        'temp_images/target-stage-hard')
    while True:
        # 如果发现次数为0,则终止
        if adb.click('temp_images/stage/no-chance-for-hard.png'):
            print('困难关卡机会已用尽,程序终止')
            break
        StageFight.fight_stage(temp_list)
    print('困难关卡已经结束')
Exemplo n.º 10
0
def fight_in_stage():
    auto_adb = AutoAdb()
    while True:
        # 寻找敌人
        res = provoke_enemy()
        if not res:
            break

        print('战斗开始 >>>')
        auto_adb.wait('temp_images/fight/fight-finish.png', cycle_interval=5)
        print(' 战斗结束 !')
        ending_loc = Location(auto_adb, None, 1040, 660)
        while True:
            in_stage = auto_adb.check('temp_images/stage/in-stage.png')
            in_unit = auto_adb.check('temp_images/stage/in-unit.png')
            if in_stage or in_unit:
                break

            new_ship = auto_adb.check('temp_images/fight/new-ship.png')
            if new_ship:
                print('发现新船!!')
                ending_loc.click()
                auto_adb.click('temp_images/fight/new-ship-confirm.png')
                continue

            fail_confirm = auto_adb.click('temp_images/fight/fail-confirm.png')
            if fail_confirm:
                input('战斗失败!! 请整理后按下任何按键以继续 ...')
                continue

            ending_loc.click()

        # 可能出现紧急任务提示
        # 由于是透明遮罩, 所以无法根据其他元素是否显示而做出反应, 只能等一定的时间
        auto_adb.wait('temp_images/fight/urgent-task.png',
                      max_wait_time=3).click()
Exemplo n.º 11
0
def fight():
    adb = AutoAdb()
    # 战斗前各种按钮的点击
    while True:
        if PageUtils.in_fight_page():
            break
        click = adb.click('temp_images/fight/fight.png')
        if click:
            continue
        retired = PortUtils.check_port_full()
        if retired:  # 如果发生了退役操作,则再次点击确认按钮
            AutoAdb().wait('temp_images/fight/fight.png').click()
            continue
        low_mood = adb.check('temp_images/fight/low-mood.png')
        if low_mood:
            print('低心情状态,脚本终止')
            exit()

    print('战斗开始 >>>')
    return fight_finish()
Exemplo n.º 12
0
def skip_dialog():
    adb = AutoAdb()
    skipped = adb.click('temp_images/fight/skip-dialog.png')
    if skipped:
        print('跳过剧情 》》》')
        adb.click('temp_images/confirm-btn.png')