feat:自动刷取日常本#200
Conversation
审阅者指南引入 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)
文件级变更
提示与命令与 Sourcery 交互
自定义你的体验访问你的控制面板 以:
获取帮助Original review guide in EnglishReviewer's GuideIntroduce 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 behaviorsequenceDiagram
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)
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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>帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续评审。
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>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") |
There was a problem hiding this comment.
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.
| class MouseMoveAction(CustomAction): | ||
| def run( | ||
| self, | ||
| context: Context, | ||
| argv: CustomAction.RunArg, | ||
| ) -> bool: |
There was a problem hiding this comment.
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.
|
解决一下conflicts |
|
需修改部分:
可优化部分:
|
# Conflicts: # assets/interface.json
可刷取前四大类日常本,暂时刷不了boss本
Summary by Sourcery
为日常副本添加新的自动刷图/自动战斗系统,包括自定义识别/动作、日志记录以及用于自动运行标准(非 Boss)关卡的流水线。
新功能:
增强点:
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:
Enhancements: