Skip to content

feat:自动刷取日常本#200

Open
lisadnsess wants to merge 18 commits into
1bananachicken:devfrom
lisadnsess:dev
Open

feat:自动刷取日常本#200
lisadnsess wants to merge 18 commits into
1bananachicken:devfrom
lisadnsess:dev

Conversation

@lisadnsess
Copy link
Copy Markdown

@lisadnsess lisadnsess commented May 24, 2026

可刷取前四大类日常本,暂时刷不了boss本

Summary by Sourcery

为日常副本添加新的自动刷图/自动战斗系统,包括自定义识别/动作、日志记录以及用于自动运行标准(非 Boss)关卡的流水线。

新功能:

  • 引入一个自动战斗模块,使用自定义识别逻辑来选择并进入普通日常副本,并通过基于模型的分类和 OCR 完成检查来驱动战斗。
  • 添加可复用的工具识别器,用于日志记录、循环计数、图像捕获和动态流水线修改,以支持自动化运行。
  • 提供用于结构化日志记录以及屏幕移动/角色控制的自定义动作,以在自动化过程中导航关卡。
  • 定义新的 AutoFight 流水线以及 AutoDailyFight 任务配置,用于编排自动化日常刷图工作流。

增强点:

  • 为自动战斗组件建立统一的日志辅助工具,支持可配置的控制台日志级别和文件输出。
Original summary in English

Summary by Sourcery

Add a new auto-farming/autofight system for daily instances, including custom recognition/actions, logging, and pipelines to automate running standard (non-boss) stages.

New Features:

  • Introduce an autofight module with custom recognition logic to select and enter normal daily instances and drive combat using model-based classification and OCR completion checks.
  • Add reusable utility recognizers for logging, loop counting, image capture, and dynamic pipeline modification to support automated runs.
  • Provide custom actions for structured logging and screen movement/character control to navigate stages during automation.
  • Define new AutoFight pipelines and an AutoDailyFight task configuration to orchestrate automated daily farming workflows.

Enhancements:

  • Set up a unified logging helper for autofight components with configurable console log levels and file output.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 24, 2026

审阅者指南

引入 AutoFight 系统,自动运行每日副本的前四个类别,包括基于神经网络的战斗自动化、灵活的流水线覆盖(pipeline overrides)、日志/工具实用程序以及动作封装器(action wrappers),并将这些全部注册到 MAA 的代理/资源系统中,同时新增对应的 pipeline/task JSON 配置。

MouseMoveAction 运行行为的时序图

sequenceDiagram
    participant Caller
    participant MouseMoveAction
    participant Context
    participant Controller1
    participant Controller2

    Caller->>MouseMoveAction: run(context, argv)
    MouseMoveAction->>Context: tasker.controller
    Context-->>MouseMoveAction: Controller1
    MouseMoveAction->>Context: clone()
    Context-->>MouseMoveAction: cloned_context
    MouseMoveAction->>cloned_context: tasker.controller
    cloned_context-->>MouseMoveAction: Controller2

    MouseMoveAction->>Controller1: post_key_down(18)
    MouseMoveAction-->>MouseMoveAction: sleep(1)
    MouseMoveAction->>Controller2: post_key_down(87).wait()
    MouseMoveAction-->>MouseMoveAction: sleep(1)
    MouseMoveAction->>Controller2: post_key_up(87).wait()

    MouseMoveAction-->>Caller: CustomAction.RunResult(success=True)
Loading

文件级变更

Change Details Files
添加自定义识别类,用于选择每日副本、使用神经网络分类器驱动自动战斗、控制每日战斗流程,并提供日志/计数器/图像工具。
  • 实现 AF_ChooseNormalInstance,将逻辑副本名称映射到 pipeline 期望值,并为普通每日副本覆盖后续节点。
  • 实现 AF_AutoFightCls 和 AF_AutoFightClsTest,使用 NeuralNetworkClassify 模型加 OCR,通过键盘/鼠标输入反复触发攻击,直到满足胜利条件或超时。
  • 实现 DF_Action,在运行时重连每日战斗流水线的一部分,将进入副本、移动、自动战斗和寻箱节点串联起来。
  • 新增 UF_Logger、UF_GetImage、UF_Count、UF_CountClean 和 UF_ChangePipeline 辅助工具,用于结构化日志记录、持续画面捕获、可重置的循环计数,以及动态修改 pipeline。
agent/custom/autofight/test_AF.py
agent/custom/autofight/test_UF.py
agent/custom/autofight/test_DF.py
添加用于日志记录和视口/屏幕移动的自定义动作类,以及一个用于键鼠编排的简单角色控制器。
  • 实现 UF_ActionLogger,用于基于 custom_action_param 的动作级日志记录。
  • 实现 UF_ActionMoveScreen,根据检测框或显式坐标滑动屏幕,从屏幕中心对齐到目标位置。
  • 实现 MouseMoveAction,用两个 controller 协调基础移动(例如按下 Alt 和短暂的 W 移动),为更复杂的角色控制搭建脚手架。
agent/custom/autofight/test_AUF.py
agent/custom/autofight/CharacterController.py
引入共享日志工具,并在代理框架中注册所有新的自定义识别/动作,通过 autofight 包对外暴露。
  • 创建 logger 模块,优先使用 loguru,实现带颜色的控制台输出、位于 debug/custom 下的轮转压缩日志文件,以及用于在运行时修改控制台日志级别的辅助函数;当 loguru 不可用时,提供日志回退实现。
  • 新增 autofight.init,聚合并按需为所有自定义识别和动作类添加 AgentServer 或 Resource 装饰器,通过 all 导出,并对外暴露 change_console_level。
  • 创建 test_PPH 模块占位,预留未来 PinkPawsHeist 逻辑。
agent/custom/autofight/logger.py
agent/custom/autofight/__init__.py
agent/custom/autofight/test_PPH.py
添加新的与 AutoFight 相关的 pipeline 和 task JSON 定义,将新的自定义逻辑接入资源系统。
  • 创建 AutoFight 相关 pipeline JSON(Action、AutoFight、DailyFight、PinkPawsHeistLevelOne),用于定义自动每日战斗和特殊战斗所使用的节点图。
  • 添加 AutoDailyFight task JSON,利用新引入的 pipelines 和自定义识别/动作驱动新的每日自动刷本行为。
  • 更新 interface.json 或相关资源,在 UI/任务列表中暴露新的 AutoFight 入口。
assets/resource/base/pipeline/AutoFight/Action.json
assets/resource/base/pipeline/AutoFight/AutoFight.json
assets/resource/base/pipeline/AutoFight/DailyFight.json
assets/resource/base/pipeline/AutoFight/PinkPawsHeistLevelOne.json
assets/resource/tasks/AutoDailyFight.json
assets/interface.json

提示与命令

与 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 来触发新的审查!

自定义你的体验

访问你的控制面板 以:

  • 启用或禁用审查功能,例如 Sourcery 自动生成的 Pull Request 总结、审阅者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查指令。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

Introduce an AutoFight system to automatically run the first four categories of daily instances, including neural-network-based combat automation, flexible pipeline overrides, logging/util tooling, and action wrappers, and register all of these with the MAA agent/resource system plus new pipeline/task JSON configs.

Sequence diagram for MouseMoveAction run behavior

sequenceDiagram
    participant Caller
    participant MouseMoveAction
    participant Context
    participant Controller1
    participant Controller2

    Caller->>MouseMoveAction: run(context, argv)
    MouseMoveAction->>Context: tasker.controller
    Context-->>MouseMoveAction: Controller1
    MouseMoveAction->>Context: clone()
    Context-->>MouseMoveAction: cloned_context
    MouseMoveAction->>cloned_context: tasker.controller
    cloned_context-->>MouseMoveAction: Controller2

    MouseMoveAction->>Controller1: post_key_down(18)
    MouseMoveAction-->>MouseMoveAction: sleep(1)
    MouseMoveAction->>Controller2: post_key_down(87).wait()
    MouseMoveAction-->>MouseMoveAction: sleep(1)
    MouseMoveAction->>Controller2: post_key_up(87).wait()

    MouseMoveAction-->>Caller: CustomAction.RunResult(success=True)
Loading

File-Level Changes

Change Details Files
Add custom recognition classes to choose daily instances, drive auto-combat using a neural network classifier, control flow for daily fights, and provide logging/counter/image utilities.
  • Implement AF_ChooseNormalInstance to map logical instance names to pipeline expectations and override subsequent nodes for normal daily instances.
  • Implement AF_AutoFightCls and AF_AutoFightClsTest that use a NeuralNetworkClassify model plus OCR to repeatedly trigger attacks via keyboard/mouse input until a victory condition or timeout.
  • Implement DF_Action to rewire parts of the daily-fight pipeline at runtime, chaining instance entry, movement, auto-fight, and box-finding nodes.
  • Add UF_Logger, UF_GetImage, UF_Count, UF_CountClean, and UF_ChangePipeline helpers for structured logging, continuous frame capture, loop counting with reset, and dynamic pipeline modification.
agent/custom/autofight/test_AF.py
agent/custom/autofight/test_UF.py
agent/custom/autofight/test_DF.py
Add custom action classes for logging and viewport/screen movement, plus a simple character controller for keyboard/mouse orchestration.
  • Implement UF_ActionLogger for action-level logging driven by custom_action_param.
  • Implement UF_ActionMoveScreen to swipe the screen based on either a detection box or explicit coordinates, aligning from screen center to target.
  • Implement MouseMoveAction to coordinate two controllers for basic movement (e.g., Alt press and short W movement), scaffolding for more complex character control.
agent/custom/autofight/test_AUF.py
agent/custom/autofight/CharacterController.py
Introduce a shared logging utility and register all new custom recognition/actions with the agent framework, exposing them via the autofight package.
  • Create logger module that prefers loguru with colored console output, rotating compressed file logs under debug/custom, and a helper to change console log level at runtime, with a logging fallback when loguru is unavailable.
  • Add autofight.init to aggregate and conditionally decorate all custom recognition and action classes with AgentServer or Resource decorators, exporting them via all and exposing change_console_level.
  • Stub out a test_PPH module as a placeholder for future PinkPawsHeist logic.
agent/custom/autofight/logger.py
agent/custom/autofight/__init__.py
agent/custom/autofight/test_PPH.py
Add new AutoFight-related pipeline and task JSON definitions to wire the new custom logic into the asset system.
  • Create AutoFight pipeline JSONs (Action, AutoFight, DailyFight, PinkPawsHeistLevelOne) to define the node graph used for automatic daily and special fights.
  • Add an AutoDailyFight task JSON that drives the new daily auto-farming behavior using the introduced pipelines and custom recognitions/actions.
  • Update interface.json or related assets to expose the new AutoFight entry points in the UI/tasks list.
assets/resource/base/pipeline/AutoFight/Action.json
assets/resource/base/pipeline/AutoFight/AutoFight.json
assets/resource/base/pipeline/AutoFight/DailyFight.json
assets/resource/base/pipeline/AutoFight/PinkPawsHeistLevelOne.json
assets/resource/tasks/AutoDailyFight.json
assets/interface.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

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - 我发现了两个问题,并给出了一些整体性反馈:

  • UF_GetImage.analyze() 在没有任何延迟的情况下运行一个无限循环,而且在 context.tasker.stopping 被设置时并不会真正返回,这可能导致高 CPU 使用率以及节点永远不结束;建议在循环中加入一个小的 sleep,并在停止时显式 return。
  • 若干处理器的返回类型与其基类不一致(例如 MouseMoveAction.run 标注的返回类型是 bool,但实际返回 CustomAction.RunResult;UF_Count.analyze 有时会返回 None 而不是 AnalyzeResult),这可能在 MAA 框架中导致意料之外的行为;请将返回值和注解与预期接口对齐。
  • 在 AF_AutoFightCls/AF_AutoFightClsTest 和 DF_Action 等类中还残留了许多调试打印和大块被注释掉的代码;清理这些内容会让新的流水线更加易读、易维护。
用于 AI Agent 的提示词
请根据这次代码评审中的评论进行修改:

## 整体评论
- UF_GetImage.analyze() 在没有任何延迟的情况下运行一个无限循环,而且在 context.tasker.stopping 被设置时并不会真正返回,这可能导致高 CPU 使用率以及节点永远不结束;建议在循环中加入一个小的 sleep,并在停止时显式 return。
- 若干处理器的返回类型与其基类不一致(例如 MouseMoveAction.run 标注的返回类型是 bool,但实际返回 CustomAction.RunResult;UF_Count.analyze 有时会返回 None 而不是 AnalyzeResult),这可能在 MAA 框架中导致意料之外的行为;请将返回值和注解与预期接口对齐。
- 在 AF_AutoFightCls/AF_AutoFightClsTest 和 DF_Action 等类中还残留了许多调试打印和大块被注释掉的代码;清理这些内容会让新的流水线更加易读、易维护。

## 具体评论

### 评论 1
<location path="agent/custom/autofight/__init__.py" line_range="64" />
<code_context>
+        decorated_func = resource.custom_action(func.__name__)(func)
+        globals()[func.__name__] = decorated_func
+    __all__ = [func.__name__ for func in FUNCTIONS_RECOGNITION] + ["resource"]  # 添加实例到导出列表
+__all__.append("change_console_level")
+# 定义导出列表:包含所有函数和recognition_handler实例
</code_context>
<issue_to_address>
**issue (bug_risk):**`loguru` 不可用时,`change_console_level` 可能不存在。

在 `logger.py` 中,只有在 `loguru` 可用时才会定义 `change_console_level`,但这个模块始终会把它追加到 `__all__` 中。当未安装 `loguru` 时,从该包导入 `change_console_level` 会失败。请在 `ImportError` 分支中为 `change_console_level` 定义一个 no-op 的后备实现,或者只在它实际被定义时才将其加入 `__all__`。
</issue_to_address>

### 评论 2
<location path="agent/custom/autofight/CharacterController.py" line_range="14-19" />
<code_context>
+import ast
+
+
+class MouseMoveAction(CustomAction):
+    def run(
+            self,
+            context: Context,
+            argv: CustomAction.RunArg,
+    ) -> bool:
+        # info_logger = json.loads(argv.custom_action_param).get("info")
+        # debug_logger = json.loads(argv.custom_action_param).get("debug")
</code_context>
<issue_to_address>
**issue (bug_risk):** `run` 方法标注的返回类型与实际返回值不一致。

该方法被标注为返回 `bool`,但实际返回的是 `CustomAction.RunResult`(包括注释掉的提前返回)。请将返回类型修改为 `CustomAction.RunResult`(或合适的别名),或者调整实现以始终返回 `bool`。
</issue_to_address>

Sourcery 对开源项目免费——如果你觉得这次评审有帮助,请考虑分享一下 ✨
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English

Hey - I've found 2 issues, and left some high level feedback:

  • UF_GetImage.analyze() runs an infinite loop without any delay and does not actually return when context.tasker.stopping is set, which can lead to high CPU usage and the node never terminating; consider adding a small sleep and an explicit return on stop.
  • Several handlers have inconsistent return types with their base classes (e.g., MouseMoveAction.run is annotated to return bool but returns CustomAction.RunResult, UF_Count.analyze sometimes returns None instead of an AnalyzeResult), which can cause unexpected behavior in the MAA framework; align return values and annotations with the expected interfaces.
  • There are many leftover debug prints and large blocks of commented-out code in classes like AF_AutoFightCls/AF_AutoFightClsTest and DF_Action; cleaning these up will make the new pipelines easier to read and maintain.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- UF_GetImage.analyze() runs an infinite loop without any delay and does not actually return when context.tasker.stopping is set, which can lead to high CPU usage and the node never terminating; consider adding a small sleep and an explicit return on stop.
- Several handlers have inconsistent return types with their base classes (e.g., MouseMoveAction.run is annotated to return bool but returns CustomAction.RunResult, UF_Count.analyze sometimes returns None instead of an AnalyzeResult), which can cause unexpected behavior in the MAA framework; align return values and annotations with the expected interfaces.
- There are many leftover debug prints and large blocks of commented-out code in classes like AF_AutoFightCls/AF_AutoFightClsTest and DF_Action; cleaning these up will make the new pipelines easier to read and maintain.

## Individual Comments

### Comment 1
<location path="agent/custom/autofight/__init__.py" line_range="64" />
<code_context>
+        decorated_func = resource.custom_action(func.__name__)(func)
+        globals()[func.__name__] = decorated_func
+    __all__ = [func.__name__ for func in FUNCTIONS_RECOGNITION] + ["resource"]  # 添加实例到导出列表
+__all__.append("change_console_level")
+# 定义导出列表:包含所有函数和recognition_handler实例
</code_context>
<issue_to_address>
**issue (bug_risk):** `change_console_level` may not exist when `loguru` is unavailable.

In `logger.py`, `change_console_level` is only defined when `loguru` is available, but this module always appends it to `__all__`. When `loguru` is not installed, importing `change_console_level` from this package will fail. Please either define a no-op fallback for `change_console_level` in the `ImportError` branch or only add it to `__all__` when it is actually defined.
</issue_to_address>

### Comment 2
<location path="agent/custom/autofight/CharacterController.py" line_range="14-19" />
<code_context>
+import ast
+
+
+class MouseMoveAction(CustomAction):
+    def run(
+            self,
+            context: Context,
+            argv: CustomAction.RunArg,
+    ) -> bool:
+        # info_logger = json.loads(argv.custom_action_param).get("info")
+        # debug_logger = json.loads(argv.custom_action_param).get("debug")
</code_context>
<issue_to_address>
**issue (bug_risk):** The `run` method’s annotated return type does not match the actual return value.

The method is annotated as returning `bool`, but it returns `CustomAction.RunResult` (including in the commented early return). Please either change the return type to `CustomAction.RunResult` (or the appropriate alias) or adjust the implementation to return a `bool` consistently.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

decorated_func = resource.custom_action(func.__name__)(func)
globals()[func.__name__] = decorated_func
__all__ = [func.__name__ for func in FUNCTIONS_RECOGNITION] + ["resource"] # 添加实例到导出列表
__all__.append("change_console_level")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk):loguru 不可用时,change_console_level 可能不存在。

logger.py 中,只有在 loguru 可用时才会定义 change_console_level,但这个模块始终会把它追加到 __all__ 中。当未安装 loguru 时,从该包导入 change_console_level 会失败。请在 ImportError 分支中为 change_console_level 定义一个 no-op 的后备实现,或者只在它实际被定义时才将其加入 __all__

Original comment in English

issue (bug_risk): change_console_level may not exist when loguru is unavailable.

In logger.py, change_console_level is only defined when loguru is available, but this module always appends it to __all__. When loguru is not installed, importing change_console_level from this package will fail. Please either define a no-op fallback for change_console_level in the ImportError branch or only add it to __all__ when it is actually defined.

Comment on lines +14 to +19
class MouseMoveAction(CustomAction):
def run(
self,
context: Context,
argv: CustomAction.RunArg,
) -> bool:
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (bug_risk): run 方法标注的返回类型与实际返回值不一致。

该方法被标注为返回 bool,但实际返回的是 CustomAction.RunResult(包括注释掉的提前返回)。请将返回类型修改为 CustomAction.RunResult(或合适的别名),或者调整实现以始终返回 bool

Original comment in English

issue (bug_risk): The run method’s annotated return type does not match the actual return value.

The method is annotated as returning bool, but it returns CustomAction.RunResult (including in the commented early return). Please either change the return type to CustomAction.RunResult (or the appropriate alias) or adjust the implementation to return a bool consistently.

@EeeMaoY
Copy link
Copy Markdown
Collaborator

EeeMaoY commented May 24, 2026

解决一下conflicts

@EeeMaoY EeeMaoY changed the title 自动刷取日常本 feat:自动刷取日常本 May 24, 2026
@EeeMaoY
Copy link
Copy Markdown
Collaborator

EeeMaoY commented May 24, 2026

需修改部分:

  1. pipeline中很多templatematch匹配文本图片类更换为OCR(这部分可不作i18n,文本与游戏内一段完整文本匹配就可以自动完成i18n)
  2. logger参考.claude\skills\maa-logging\SKILL.md使用通用工具输出(其他skill也可作参考,给ai的skill暂时当作开发文档用()),python内用logger或PrintT,pipeline内用focus

可优化部分:

  1. interface/task内容i18n
  2. 修改pipeline节点名或增加“desc”以增强可读性
  3. 增加双倍领取可选项
  4. 副本选择改为option-suboption形式,例如“经验及甲硬币-合订本”,具体参考钓鱼任务里的"FishBuyBaitAuto"
  5. 删去ppl节点中用于mpe的坐标

@lisadnsess lisadnsess reopened this May 26, 2026
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.

2 participants