Example #1
0
def run():
    print('每日任务开始。。。')
    print('目前仅支持 ”商船护卫“、”海域突进“、“斩首行动” 三个类别。')
    print('“战术研修”和“破交作战”由于战力要求和操控要求比较高,因此暂不能自动化。')
    print()
    adb = AutoAdb()

    task_list = [{
        'loc': Location(adb, None, 160, 400, '商船护卫'),
        'day': [1, 4, 7]
    }, {
        'loc': Location(adb, None, 370, 400, '海域突进'),
        'day': [2, 5, 7]
    }, {
        'loc': Location(adb, None, 900, 400, '斩首行动'),
        'day': [3, 6, 7]
    }]

    week_day = datetime.datetime.now().weekday() + 1
    for task in task_list:
        task_loc = task['loc']
        if week_day not in task['day']:
            continue

        PageUtils.to_stage_page()
        adb.wait(
            'temp_images/daily-task/daily-task/goto-daily-task.png').click()
        task_loc.click()
        Location(adb, None, 640, 400).click()
        # 执行方法
        print('今天是周%d,%s开放' % (week_day, task_loc.remark))
        TaskHelper(task_loc.remark).run()
    PageUtils.to_main_page()
Example #2
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
Example #3
0
def wind_up_stage_fight():
    if PageUtils.in_fight_page():
        print('正在战斗。。。')
        fight_finish()

    if PageUtils.in_enemy_page():
        print('扫荡剩余敌军。。。')
        fight_all_enemy()
        return True
    return False
Example #4
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('指挥喵处理完毕')
Example #5
0
def wind_up_stage_fight():
    timer = Timer()
    while PageUtils.in_fight_page():
        print('\r战斗中。。。 %ds ' % timer.get_duration(), end='')
        time.sleep(5)

    if PageUtils.in_enemy_page():
        print('进行关卡收尾。。。')
        fight_all_enemy()
        return True
    return False
def deal_missions(adb):
    print('领取任务奖励。。。')
    while True:
        have_receive_all = adb.wait(
            'temp_images/daily-task/missions/receive-all.png').click()
        if have_receive_all:
            adb.wait('temp_images/click-to-continue.png').click()
        else:
            break
    print('领取完毕')
    PageUtils.to_main_page()
Example #7
0
def run():
    print('处理求救信号关卡。。。')
    # 如果已经在关卡中,则先战斗
    StageFight.wind_up_stage_fight()

    PageUtils.to_stage_page()
    while True:
        res = deal_sos_sign()
        if not res:
            print('所有求救信号已处理完毕')
            PageUtils.to_main_page()
            break
Example #8
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
Example #9
0
def fight_all_enemy():
    team_leader = TeamLeader()
    while True:
        team_leader.provoke_enemy()
        fight()
        # 如果在演习界面
        if PageUtils.in_operation_page():
            print('误入演习界面,退出')
            PageUtils.back()
            time.sleep(1)

        # 如果在单元界面,说明关卡已经结束
        if PageUtils.in_stage_page():
            print('关卡战斗结束')
            break
Example #10
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 #11
0
def fight_all_enemy():
    team_leader = TeamLeader()
    while True:
        team_leader.provoke_enemy()
        fight()
        # 如果在单元界面,说明关卡已经结束
        if PageUtils.in_stage_page():
            print('关卡战斗结束')
            break
Example #12
0
def fight_all_enemy():
    team_leader = TeamLeader()
    while True:
        team_leader.provoke_enemy()
        fight_result = fight()
        # 如果在单元界面,说明关卡已经结束
        if PageUtils.in_stage_page():
            print('所有敌船均被击沉 <( ̄︶ ̄)>' if fight_result else '未能击沉所有敌船 (。﹏。*)')
            return fight_result
Example #13
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
Example #14
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 #15
0
    def provoke_enemy(self):
        adb = self.adb
        # 这里要多等待几秒, 因为经常会有个动画影响寻敌
        time.sleep(3)

        if PageUtils.in_stage_page():  # 关卡已经结束
            return False

        # 弹药为空且当前是第一队时切换队伍
        if self.current_team_num == 1 and adb.check(
                'temp_images/stage/bullet-empty.png'):
            self.switch()

        # 页面滑动工具类
        slider = Slider()
        # 敌人的模板列表
        image_rel_path_list = PathUtils.get_temp_rel_path_list(
            'temp_images/enemy')
        while True:
            print('寻找敌人 ... ')
            enemy_loc = adb.get_location(*image_rel_path_list)
            if enemy_loc is None:
                # 有时没找到敌人是已经进入确认界面了
                if adb.check('temp_images/fight/fight.png'):
                    return True
                # 滑动界面寻找敌人
                slider.slide()
                continue

            # 如果当前是第一队, 且找到的是boss, 则切换到第二队开始寻找敌人
            if self.current_team_num == 1 and 'boss' in enemy_loc.temp_rel_path:
                self.switch()
                continue

            # 有时敌人离状态栏太近,这时加大Y轴
            if enemy_loc.pos_y < 65:
                enemy_loc.pos_y = 65
            # 点击敌人位置
            enemy_loc.click()
            # 等待进击按钮出现, 期间会不断处理意外情况, 如果指定时间内出现按钮, 则执行结束, 否则再次循环
            res = adb.wait('temp_images/fight/fight.png',
                           max_wait_time=8,
                           episode=self.accident_when_run).is_valuable()
            if res:
                return True
            else:
                # 如果点击后未进入确认界面, 说明那里不可到达, 此时去除image_rel_path_list中的值
                image_rel_path_list.remove(enemy_loc.temp_rel_path)
                # 如果list为空了,则恢复到原有列表
                if len(image_rel_path_list) == 0:
                    image_rel_path_list = PathUtils.get_temp_rel_path_list(
                        'temp_images/enemy')
Example #16
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()
Example #17
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