Skip to content

feat(AutoCoffeePro): 添加 NanallyPro 和 LacrimosaPro 自动化游戏模式 - #363

Draft
xiaoao114511 wants to merge 1 commit into
1bananachicken:devfrom
xiaoao114511:BetterCoffee
Draft

feat(AutoCoffeePro): 添加 NanallyPro 和 LacrimosaPro 自动化游戏模式#363
xiaoao114511 wants to merge 1 commit into
1bananachicken:devfrom
xiaoao114511:BetterCoffee

Conversation

@xiaoao114511

@xiaoao114511 xiaoao114511 commented Jun 22, 2026

Copy link
Copy Markdown

关联内容

  • 无直接关联 Issue,将自制独立游戏机器人功能迁移为 MaaNTE CustomAction

变更摘要

  • 新增 NanallyPro / LacrimosaPro 两个 Python CustomAction
  • 新增主编排器 AutoCoffeePro CustomAction
  • 新增 4 个 Pipeline JSON 文件,含 OCR/TemplateMatch 识别节点
  • 新增 2 个任务配置文件及可选项
  • 更新 interface.json 注册新任务,更新 5 个 locale 文件

验证

  • Draft 阶段,先看架构方向是否正确,细节(ROI、占位图、循环逻辑)等确认后再完善。

Summary by Sourcery

添加一个新的 AutoCoffeePro 编排器,以及配套的自定义动作/工具,用基于识别的流水线和任务配置来自动化两种游戏模式。

New Features:

  • 引入 AutoCoffeePro 自定义动作,作为自动关卡运行的全流程编排器。
  • 添加 NanallyPro 和 LacrimosaPro 自定义动作,以处理两种不同的自动化游戏模式。
  • 为新的自动化流程提供基于背景差分的自定义识别能力,以及共享的输入/点击工具。
  • 在界面和资源文件中注册新的 AutoCoffeePro 流水线和按模式划分的任务配置。

Enhancements:

  • 通过自定义动作包导出暴露新的 AutoCoffeePro、NanallyPro 和 LacrimosaPro 动作。
Original summary in English

Summary by Sourcery

Add a new AutoCoffeePro orchestrator and supporting custom actions/utilities to automate two game modes with recognition-based pipelines and task configs.

New Features:

  • Introduce the AutoCoffeePro custom action as a full-loop orchestrator for automated level runs.
  • Add NanallyPro and LacrimosaPro custom actions to handle two distinct automated gameplay modes.
  • Provide background-diff based custom recognitions and shared input/click utilities for the new automation flows.
  • Register new AutoCoffeePro pipelines and per-mode task configurations in the interface and resource files.

Enhancements:

  • Expose the new AutoCoffeePro, NanallyPro, and LacrimosaPro actions through the custom action package exports.

- 新增 NanallyPro(自动点击锤子)和 LacrimosaPro(检测并服务顾客果汁)两个 CustomAction
- 新增 4 个 Pipeline JSON 文件,含 OCR/TemplateMatch 识别节点
- 新增主编排器 AutoCoffeePro CustomAction
- 新增 2 个任务配置文件及可选项
- 更新 interface.json 注册新任务
- 更新 5 个语言文件的界面文案
@sourcery-ai

sourcery-ai Bot commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

审查者指南(Reviewer's Guide)

实现了一个新的 AutoCoffeePro 编排器 CustomAction,以及 NanallyPro 和 LacrimosaPro 模式动作、共享工具和背景差分识别,并将它们接入 Maa 的流水线(pipelines)、任务以及界面/本地化元数据中,以支持完整的自动化游戏循环。

AutoCoffeePro 编排玩法循环的时序图

sequenceDiagram
    participant Pipeline_AutoCoffeeProRun as AutoCoffeeProRun
    participant AutoCoffeeProAction as AutoCoffeePro
    participant Context as Context
    participant Controller as controller
    participant NanallyProAction as NanallyPro
    participant LacrimosaProAction as LacrimosaPro

    Pipeline_AutoCoffeeProRun->>AutoCoffeeProAction: run(context, argv)
    AutoCoffeeProAction->>Context: tasker.controller
    AutoCoffeeProAction->>AutoCoffeeProAction: parse argv.custom_action_param

    loop rounds 1..max_rounds
        AutoCoffeeProAction->>Context: run_recognition(level_node, get_image(controller))
        AutoCoffeeProAction->>Controller: post_touch_down/up (click_rect_multiple)
        AutoCoffeeProAction->>Context: run_recognition(start_node, get_image(controller))
        AutoCoffeeProAction->>Controller: post_touch_down/up (click_rect_multiple)

        alt mode == nanally
            AutoCoffeeProAction->>Context: run_action("NanallyProRun")
            Context->>NanallyProAction: run(context, argv)
            NanallyProAction->>Context: run_recognition(hammer_recognition_node, get_image(controller))
            NanallyProAction->>Controller: post_touch_down/up (click_rect_multiple)
        else mode == lacrimosa
            AutoCoffeeProAction->>Context: run_action("LacrimosaProRun")
            Context->>LacrimosaProAction: run(context, argv)
            LacrimosaProAction->>Context: run_recognition(juice_recognition_node, get_image(controller))
            LacrimosaProAction->>Context: run_recognition(glasses_recognition_node, get_image(controller))
            LacrimosaProAction->>Context: run_recognition(tomato_recognition_node, get_image(controller))
            LacrimosaProAction->>Controller: post_touch_down/up (click_rect_multiple)
        end

        AutoCoffeeProAction->>Context: run_recognition(exit_node, get_image(controller))
        AutoCoffeeProAction->>Controller: post_touch_down/up (click_rect_multiple)
        AutoCoffeeProAction->>Context: run_recognition(success_node/fail_node, get_image(controller))
        alt fail detected
            AutoCoffeeProAction->>Context: run_recognition(retry_node, get_image(controller))
            AutoCoffeeProAction->>Controller: post_touch_down/up (click_rect_multiple)
        else success or fallback
            AutoCoffeeProAction->>Context: run_recognition(finish_node, get_image(controller))
            AutoCoffeeProAction->>Controller: post_touch_down/up (click_rect_multiple)
        end
    end

    AutoCoffeeProAction-->>Pipeline_AutoCoffeeProRun: RunResult(success)
Loading

文件级变更

Change Details Files
添加 AutoCoffeePro 编排器 CustomAction,用于运行可配置的多轮游戏循环,并将每轮具体行为委托给模式特定的流水线动作。
  • agent.custom.action 包中注册 AutoCoffeeProAction,并通过 __all__ 暴露出来,以便 Maa 发现。
  • 实现从 custom_action_param 解析参数(模式、轮数上限、超时时间以及流水线节点名称),支持 JSON 处理并提供合理默认值。
  • 添加主要运行循环:检查任务停止状态,通过识别节点执行关卡选择,运行所选模式动作节点,然后处理退出/结果逻辑(重试/完成)。
  • 实现关卡选择、模式分发(Nanally/Lacrimosa 动作节点)以及退出/结果处理等辅助方法,基于 Maa 的 context.run_recognitionrun_action API。
agent/custom/action/__init__.py
agent/custom/action/AutoCoffeePro/auto_coffee_pro.py
agent/custom/action/AutoCoffeePro/__init__.py
引入 NanallyPro 和 LacrimosaPro 模式 CustomAction,为两种不同游戏模式实现具体的关卡内自动化逻辑。
  • 添加 NanallyProAction:在可配置的循环时长和间隔内反复定位并点击锤子识别节点,若超时或任务停止则中止。
  • 添加 LacrimosaProAction:通过识别检测顾客的果汁需求,然后依次寻找并点击玻璃杯和番茄工具,支持可配置的服务次数、超时时间和时序参数。
  • 每种模式都会解析自身的 custom_action_param JSON,以调整识别节点名称和时序参数,并根据循环完成情况和超时条件返回成功/失败。
  • 通过 AutoCoffeePro 包以及顶层自定义动作 __all__ 列表导出 NanallyProAction 和 LacrimosaProAction 以供注册。
agent/custom/action/AutoCoffeePro/modes.py
agent/custom/action/AutoCoffeePro/__init__.py
agent/custom/action/__init__.py
添加 BackgroundDiffPro 自定义识别工具,以通过背景减除支持前景目标(顾客)检测,并在场景切换间进行重置。
  • 实现 BackgroundDiffPro CustomRecognition:为每个 region_name 捕获一张干净的灰度背景图,然后对后续帧执行绝对差分、阈值分割、形态学处理、轮廓过滤与框提取。
  • 支持通过 custom_recognition_param 配置,包括 region_name、差分阈值、面积阈值、形态学卷积核、捕获延迟以及可选的 ROI 坐标。
  • 通过在帧尺寸变化时重新捕获背景,并在识别结果中返回主要边界框以及详细的框列表/数量,来保证鲁棒性。
  • 添加 BackgroundDiffProReset CustomRecognition,用于清空缓存的背景状态,以在下次使用时强制重新捕获。
agent/custom/action/AutoCoffeePro/background.py
添加在新动作中复用的控制器/视觉辅助工具。
  • 提供 get_image 封装,用于基于 controller.post_screencap/cached_image 统一获取截图。
  • 添加 click_rectclick_rect_multiple 辅助函数,以在边界框中心点击,并支持可配置的重复次数和延迟以提高可靠性。
  • 实现 press_key_fpress_key_esc 键盘交互辅助函数,以及带超时和可选停止钩子的通用 wait_for_condition 轮询工具。
  • 引入 match_template_in_region,在指定区域内基于 OpenCV 进行模板匹配,支持可选的绿色通道遮罩,并对无效输入以及 NaN/Inf 匹配结果进行健壮处理。
agent/custom/action/AutoCoffeePro/utils.py
通过流水线、任务以及界面/本地化资源,将新的自动化模式接入 Maa 配置。
  • assets/interface.json 中注册 AutoCoffeePro、NanallyPro 和 LacrimosaPro 任务,并通过新的任务 JSON 定义暴露可配置选项。
  • 在 AutoCoffeePro 目录下新增四个流水线 JSON 文件(核心编排器、识别配置、NanallyPro、LacrimosaPro),定义 Python CustomAction 所引用的 OCR/模板匹配节点。
  • 更新多个本地化文件,为新任务和选项在各支持语言中提供本地化名称与描述。
assets/interface.json
assets/resource/base/pipeline/AutoCoffeePro/AutoCoffeePro.json
assets/resource/base/pipeline/AutoCoffeePro/AutoCoffeeProRecognition.json
assets/resource/base/pipeline/AutoCoffeePro/LacrimosaPro.json
assets/resource/base/pipeline/AutoCoffeePro/NanallyPro.json
assets/resource/tasks/LacrimosaPro.json
assets/resource/tasks/NanallyPro.json
assets/resource/locales/interface/en_us.json
assets/resource/locales/interface/ja_jp.json
assets/resource/locales/interface/ko_kr.json
assets/resource/locales/interface/zh_cn.json
assets/resource/locales/interface/zh_tw.json

技巧与命令(Tips and commands)

与 Sourcery 交互

  • 触发新审查: 在 pull request 中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 从审查评论生成 GitHub issue: 在审查评论下回复,请求 Sourcery 基于该评论创建 issue。你也可以直接回复 @sourcery-ai issue,从该评论创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai,即可随时生成标题。也可以在 pull request 中评论 @sourcery-ai title 来(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文任意位置写上 @sourcery-ai summary,即可在该位置生成 PR 摘要。也可以在 pull request 中评论 @sourcery-ai summary 来(重新)生成摘要。
  • 生成审查者指南: 在 pull request 中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 中评论 @sourcery-ai resolve,可一次性解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,这会很有用。
  • 关闭所有 Sourcery 审查: 在 pull request 中评论 @sourcery-ai dismiss,可关闭所有已有的 Sourcery 审查。若你希望以全新的审查开始,这尤其有用——别忘了再评论 @sourcery-ai review 来触发新的审查!

自定义你的体验

访问你的 dashboard 以:

  • 启用或禁用诸如 Sourcery 生成的 pull request 摘要、审查者指南等审查功能。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Implements a new AutoCoffeePro orchestrator CustomAction plus NanallyPro and LacrimosaPro mode actions, shared utilities and background-diff recognition, and wires them into Maa pipelines, tasks, and interface/locale metadata to support a full automated gameplay loop.

Sequence diagram for AutoCoffeePro orchestrated gameplay loop

sequenceDiagram
    participant Pipeline_AutoCoffeeProRun as AutoCoffeeProRun
    participant AutoCoffeeProAction as AutoCoffeePro
    participant Context as Context
    participant Controller as controller
    participant NanallyProAction as NanallyPro
    participant LacrimosaProAction as LacrimosaPro

    Pipeline_AutoCoffeeProRun->>AutoCoffeeProAction: run(context, argv)
    AutoCoffeeProAction->>Context: tasker.controller
    AutoCoffeeProAction->>AutoCoffeeProAction: parse argv.custom_action_param

    loop rounds 1..max_rounds
        AutoCoffeeProAction->>Context: run_recognition(level_node, get_image(controller))
        AutoCoffeeProAction->>Controller: post_touch_down/up (click_rect_multiple)
        AutoCoffeeProAction->>Context: run_recognition(start_node, get_image(controller))
        AutoCoffeeProAction->>Controller: post_touch_down/up (click_rect_multiple)

        alt mode == nanally
            AutoCoffeeProAction->>Context: run_action("NanallyProRun")
            Context->>NanallyProAction: run(context, argv)
            NanallyProAction->>Context: run_recognition(hammer_recognition_node, get_image(controller))
            NanallyProAction->>Controller: post_touch_down/up (click_rect_multiple)
        else mode == lacrimosa
            AutoCoffeeProAction->>Context: run_action("LacrimosaProRun")
            Context->>LacrimosaProAction: run(context, argv)
            LacrimosaProAction->>Context: run_recognition(juice_recognition_node, get_image(controller))
            LacrimosaProAction->>Context: run_recognition(glasses_recognition_node, get_image(controller))
            LacrimosaProAction->>Context: run_recognition(tomato_recognition_node, get_image(controller))
            LacrimosaProAction->>Controller: post_touch_down/up (click_rect_multiple)
        end

        AutoCoffeeProAction->>Context: run_recognition(exit_node, get_image(controller))
        AutoCoffeeProAction->>Controller: post_touch_down/up (click_rect_multiple)
        AutoCoffeeProAction->>Context: run_recognition(success_node/fail_node, get_image(controller))
        alt fail detected
            AutoCoffeeProAction->>Context: run_recognition(retry_node, get_image(controller))
            AutoCoffeeProAction->>Controller: post_touch_down/up (click_rect_multiple)
        else success or fallback
            AutoCoffeeProAction->>Context: run_recognition(finish_node, get_image(controller))
            AutoCoffeeProAction->>Controller: post_touch_down/up (click_rect_multiple)
        end
    end

    AutoCoffeeProAction-->>Pipeline_AutoCoffeeProRun: RunResult(success)
Loading

File-Level Changes

Change Details Files
Add AutoCoffeePro orchestrator CustomAction that runs a configurable multi-round gameplay loop and delegates per-round behavior to mode-specific pipeline actions.
  • Registers AutoCoffeeProAction in agent.custom.action package and exposes it via all for Maa to discover.
  • Implements parameter parsing from custom_action_param (mode, round limits, timeouts, and pipeline node names) with JSON handling and sane defaults.
  • Adds main run loop that checks task stopping state, performs level selection via recognition nodes, runs the selected mode action node, and then handles exit/result with retry/finish logic.
  • Implements helper methods for level selection, mode dispatch (Nanally/Lacrimosa action nodes), and exit/result handling using Maa context.run_recognition and run_action APIs.
agent/custom/action/__init__.py
agent/custom/action/AutoCoffeePro/auto_coffee_pro.py
agent/custom/action/AutoCoffeePro/__init__.py
Introduce NanallyPro and LacrimosaPro mode CustomActions implementing the concrete in-level automation logic for two distinct game modes.
  • Adds NanallyProAction that repeatedly locates and clicks a hammer recognition node within a configurable loop duration and interval, aborting on timeout or task stop.
  • Adds LacrimosaProAction that detects customer juice demand via recognition, then sequentially finds and clicks glasses and tomato tools, with configurable service count, timeouts, and timing parameters.
  • Each mode parses its own custom_action_param JSON for tuning recognition node names and timing, and returns success/failure based on loop completion and timeout conditions.
  • Exports NanallyProAction and LacrimosaProAction through the AutoCoffeePro package and top-level custom action all list for registration.
agent/custom/action/AutoCoffeePro/modes.py
agent/custom/action/AutoCoffeePro/__init__.py
agent/custom/action/__init__.py
Add BackgroundDiffPro custom recognition utilities to support foreground-object (customer) detection via background subtraction and reset behavior between scenes.
  • Implements BackgroundDiffPro CustomRecognition that captures a clean grayscale background per region_name, then performs absolute differencing, thresholding, morphology, contour filtering, and box extraction on subsequent frames.
  • Supports configuration via custom_recognition_param including region_name, diff_threshold, area thresholds, morphology kernel, capture delay, and optional ROI coordinates.
  • Ensures robustness by recapturing background when frame shape changes and returning the primary bounding box plus detailed box list/count in the recognition result.
  • Adds BackgroundDiffProReset CustomRecognition that clears the cached background state to force recapture on next use.
agent/custom/action/AutoCoffeePro/background.py
Add shared controller/vision helper utilities used across the new actions.
  • Provides get_image wrapper around controller.post_screencap/cached_image for consistent screenshot acquisition.
  • Adds click_rect and click_rect_multiple helpers to click the center of a bounding box with configurable repetition and delays for reliability.
  • Implements press_key_f and press_key_esc helpers for key-based interactions, and a generic wait_for_condition polling utility with timeout and optional stopping hook.
  • Introduces match_template_in_region for OpenCV-based template matching within a specified region, including optional green-channel masking and robust handling of invalid inputs and NaN/Inf match results.
agent/custom/action/AutoCoffeePro/utils.py
Wire new automation modes into Maa configuration via pipelines, tasks, and interface/locale resources.
  • Registers AutoCoffeePro, NanallyPro, and LacrimosaPro tasks in assets/interface.json and exposes configurable options via new task JSON definitions.
  • Adds four new pipeline JSON files under AutoCoffeePro (core orchestrator, recognition setup, NanallyPro, LacrimosaPro) defining OCR/template-match nodes referenced by the Python CustomActions.
  • Updates multiple locale files to provide localized names/descriptions for the new tasks and options across supported languages.
assets/interface.json
assets/resource/base/pipeline/AutoCoffeePro/AutoCoffeePro.json
assets/resource/base/pipeline/AutoCoffeePro/AutoCoffeeProRecognition.json
assets/resource/base/pipeline/AutoCoffeePro/LacrimosaPro.json
assets/resource/base/pipeline/AutoCoffeePro/NanallyPro.json
assets/resource/tasks/LacrimosaPro.json
assets/resource/tasks/NanallyPro.json
assets/resource/locales/interface/en_us.json
assets/resource/locales/interface/ja_jp.json
assets/resource/locales/interface/ko_kr.json
assets/resource/locales/interface/zh_cn.json
assets/resource/locales/interface/zh_tw.json

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant