Repository navigation
支持彼世逢魔 - #1862
支持彼世逢魔#1862
Conversation
- config_general_battle: 新增 GreenMarkEnum 及 green_mark_type/green_mark_name 字段 - general_battle: green_mark 拆分为 green_mark_choose 与 green_mark_name - gb/click.json: 补齐 random_left/right/top/bottom,修复 assets_extract 会误删 assets.py 中被 GameUi default_pages 引用的手维护资产 来自 mine
- 新增 tasks/OtherWorldTwilight/,支持队长/队员/单人三种模式 - script_task: 队长建房邀请、队员接受邀请、单人直接挑战三种流程 - 注册 config_model / config_menu(Soul Zones) / config_manual - 补充 zh_CN.xml 与 assets/i18n/zh-CN.json 翻译 来自 mine
- 可用于处理受背景影响较大的模板,比如送的一整套周年庆庭院+主题的阴阳寮图标(暂未处理) - 新增 "Masked template matching":掩码取模板同目录 xxx_mask.png,非零参与匹配、零忽略, match/match_all/match_all_any 一并支持,掩码缺失或尺寸不符自动回退普通匹配 - 新增零方差模板拦截与匹配结果 nan/inf 清洗,防同色区域的假阳性与静默漏检 - "Multi-scale template matching" 接入 method 分发与 test_match - 记录 last_score/last_scale 供测试工具回显真实分数与命中尺度 - 修复 match_multi_scale 回写 roi_front 使用循环残值的问题
There was a problem hiding this comment.
嘿——我发现了 3 个问题
面向 AI 代理的提示
请处理这次代码审查中的评论:
## 个别评论
### 评论 1
<location path="tasks/OtherWorldTwilight/config.py" line_range="33-36" />
<code_context>
+class OWTBattleConfig(GeneralBattleConfig):
+ hide_fields = dynamic_hide('preset_enable', 'preset_group', 'preset_team', 'green_mark', 'green_mark_type')
+
+ @field_validator('green_mark_type')
+ @classmethod
+ def green_mark_type_validator(cls, v):
+ return GreenMarkEnum.NAME
+
+
</code_context>
<issue_to_address>
**issue (bug_risk):** 验证器仅在执行验证时返回 `GreenMarkEnum.NAME`,但 `green_mark_type` 没有设置 `validate_default=True`;因此,对于新创建的 `OWTBattleConfig`,Pydantic 会原样保留默认值 `CHOOSE`,导致隐藏的 OWT 设置无法可靠地选择基于名称的标记。
**触发条件:** 创建 `OWTBattleConfig()` 时未显式提供 `green_mark_type`。
**建议修复:** 将字段默认值设置为 `GreenMarkEnum.NAME`,或通过 `Field(..., validate_default=True)` 启用默认值验证;避免使用验证器来替换默认值。
```suggestion
green_mark_type: GreenMarkEnum = Field(default=GreenMarkEnum.NAME, description='green_mark_type_help')
```
</issue_to_address>
### 评论 2
<location path="tasks/OtherWorldTwilight/script_task.py" line_range="57-59" />
<code_context>
+ logger.info('Create team')
+ self.ui_click(self.I_OWT_TEAM, self.I_CHECK_TEAM, interval=1)
+ # 创建房间
+ self.create_room()
+ self.ensure_private()
+ self.create_ensure()
+ # 邀请队友
+ success = True
</code_context>
<issue_to_address>
**issue (bug_risk):** `create_room`、`ensure_private` 和 `create_ensure` 的返回值都被丢弃了。如果创建房间失败,仍会调用 `ensure_private()`,并且由于等待永远不会出现的房间控件而无限循环,而不是终止队长流程。
**触发条件:** 账号没有挑战券,或创建房间的点击操作未生效。
**建议修复:** 检查每个返回值,并在创建房间或确认失败时设置 `success=False`/退出队长流程。
</issue_to_address>
### 评论 3
<location path="module/atom/image.py" line_range="175" />
<code_context>
+ """
+ 判断模板在参与匹配的区域内是否逐通道恒为常量。
+
+ CCOEFF_NORMED 归一化时分母来自各通道的方差,参与区域内只要有通道完全没有起伏,
+ 分母就是 0,OpenCV 会走特判:无掩码时整张结果矩阵被填成 1.0(恒假阳性,且落点固定
+ 在 roi_back 左上角),带掩码时整张变成 0/0 的 nan。两种都让这条规则失去意义,
+ 这里提前拦掉,而不是把异常数值当成命中。
+ """
+ if template is None or template.size == 0:
</code_context>
<issue_to_address>
**nitpick:** 文档字符串声称只要有一个通道的方差为零,CCOEFF_NORMED 的分母就会为零,但实现仅拒绝所有参与通道都为常量的模板。因此,文档中描述的条件并不符合实际行为,可能会误导维护人员,使其不清楚哪些模板是有意被拒绝的。
**建议修复:** 描述实际的“所有通道均为常量”条件,或者如果预期条件是按通道拒绝,则修改实现。
```suggestion
CCOEFF_NORMED 归一化时分母来自各通道的方差,参与区域内所有通道都完全没有起伏时,
```
</issue_to_address>Sourcery 评估
需要人工审查。 有 2 个发现需要优先处理;此外,这还新增了一个多模式自动化任务,并修改了共享的战斗目标选择和图像匹配行为,因此缺陷可能会选择错误的角色或错误地执行战斗,并消耗有限数量的游戏内尝试次数或资源。回滚可以停止新行为,但已经发生的运行所执行的操作以及消耗的资源无法完全撤销。
阻塞性发现:tasks/OtherWorldTwilight/config.py:36、tasks/OtherWorldTwilight/script_task.py:59
Original comment in English
Hey - I've found 3 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="tasks/OtherWorldTwilight/config.py" line_range="33-36" />
<code_context>
+class OWTBattleConfig(GeneralBattleConfig):
+ hide_fields = dynamic_hide('preset_enable', 'preset_group', 'preset_team', 'green_mark', 'green_mark_type')
+
+ @field_validator('green_mark_type')
+ @classmethod
+ def green_mark_type_validator(cls, v):
+ return GreenMarkEnum.NAME
+
+
</code_context>
<issue_to_address>
**issue (bug_risk):** The validator returns `GreenMarkEnum.NAME` only when validation runs, but `green_mark_type` has no `validate_default=True`; Pydantic therefore leaves the default `CHOOSE` untouched for a newly created `OWTBattleConfig`, so the hidden OWT setting does not reliably select name-based marking.
**Triggers:** When `OWTBattleConfig()` is created without explicitly providing `green_mark_type`.
**Suggested fix:** Set the field default to `GreenMarkEnum.NAME` or enable validation of defaults with `Field(..., validate_default=True)`; avoid using a validator to replace the default.
```suggestion
green_mark_type: GreenMarkEnum = Field(default=GreenMarkEnum.NAME, description='green_mark_type_help')
```
</issue_to_address>
### Comment 2
<location path="tasks/OtherWorldTwilight/script_task.py" line_range="57-59" />
<code_context>
+ logger.info('Create team')
+ self.ui_click(self.I_OWT_TEAM, self.I_CHECK_TEAM, interval=1)
+ # 创建房间
+ self.create_room()
+ self.ensure_private()
+ self.create_ensure()
+ # 邀请队友
+ success = True
</code_context>
<issue_to_address>
**issue (bug_risk):** The return values of `create_room`, `ensure_private`, and `create_ensure` are discarded. If room creation fails, `ensure_private()` is called anyway and loops indefinitely waiting for room controls that cannot appear, instead of terminating the leader flow.
**Triggers:** When the account has no challenge ticket or the room creation click does not take effect.
**Suggested fix:** Check each return value and set `success=False`/exit the leader flow when room creation or confirmation fails.
</issue_to_address>
### Comment 3
<location path="module/atom/image.py" line_range="175" />
<code_context>
+ """
+ 判断模板在参与匹配的区域内是否逐通道恒为常量。
+
+ CCOEFF_NORMED 归一化时分母来自各通道的方差,参与区域内只要有通道完全没有起伏,
+ 分母就是 0,OpenCV 会走特判:无掩码时整张结果矩阵被填成 1.0(恒假阳性,且落点固定
+ 在 roi_back 左上角),带掩码时整张变成 0/0 的 nan。两种都让这条规则失去意义,
+ 这里提前拦掉,而不是把异常数值当成命中。
+ """
+ if template is None or template.size == 0:
</code_context>
<issue_to_address>
**nitpick:** The docstring claims that a single channel with zero variance makes the CCOEFF_NORMED denominator zero, but the implementation rejects only templates where every participating channel is constant. The documented criterion therefore does not describe the actual behavior and can mislead maintainers about which templates are intentionally rejected.
**Suggested fix:** Describe the actual all-channels-constant condition, or change the implementation if the intended criterion is per-channel rejection.
```suggestion
CCOEFF_NORMED 归一化时分母来自各通道的方差,参与区域内所有通道都完全没有起伏时,
```
</issue_to_address>Sourcery assessment
Needs a human reviewer. 2 findings to address first, and this adds a new multi-mode automation task and changes shared battle targeting and image-matching behavior, so a defect could select the wrong character or run battles incorrectly and consume a bounded number of in-game attempts or resources. Reverting stops the new behavior, but actions and consumed resources from runs that already occurred cannot be fully undone.
Blocking findings: tasks/OtherWorldTwilight/config.py:36, tasks/OtherWorldTwilight/script_task.py:59
| self.create_room() | ||
| self.ensure_private() | ||
| self.create_ensure() |
There was a problem hiding this comment.
issue (bug_risk): create_room、ensure_private 和 create_ensure 的返回值都被丢弃了。如果创建房间失败,仍会调用 ensure_private(),并且由于等待永远不会出现的房间控件而无限循环,而不是终止队长流程。
触发条件: 账号没有挑战券,或创建房间的点击操作未生效。
建议修复: 检查每个返回值,并在创建房间或确认失败时设置 success=False/退出队长流程。
Original comment in English
issue (bug_risk): The return values of create_room, ensure_private, and create_ensure are discarded. If room creation fails, ensure_private() is called anyway and loops indefinitely waiting for room controls that cannot appear, instead of terminating the leader flow.
Triggers: When the account has no challenge ticket or the room creation click does not take effect.
Suggested fix: Check each return value and set success=False/exit the leader flow when room creation or confirmation fails.
Change Summary
Reconstructed Intent点击此处展开
Observed Constraints点击此处展开
Intent Alignment
Release Risk
Validation Gaps点击此处展开
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "ab.chatgpt.com"See Network Configuration for more information.
|
Findings
Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "ab.chatgpt.com"See Network Configuration for more information.
|
- OWTBattleConfig 重声明 green_mark_type 默认为 NAME,pydantic v2 默认值不触发 validator,原写法默认仍落在 CHOOSE - run_leader 检查 create_room/create_ensure 返回值,失败提前退出队长流程, 不再无限等待不会出现的房间控件 - image: 多尺度分支复用结果清洗,修正零方差模板注释中单通道/全通道的措辞
|
@runhey 顺便提一嘴,体服又双叒叕改ui了,下周实装的话估计挺多地方会报错 |
emm。到时候顺手统一一下所有的这些通用图片呗。我记得有些任务是自个单独截图的 |
|
mark 没有看到图片呀,这个很有用的吗?使用场景是什么都的呢? |
mark的还没加呢,可以应用于十周年庭院+主题(那个卷轴)的阴阳寮图标(就是受背景影响大的模板,中心镂空之类的),实测普通匹配识别不了,只能降低阈值或者把图片再改小点。(可以加这个匹配方法备用🤓) |
|
加绿标蛮简单的 |
|
你看mark,能不能加一个新的检测类型,类似于“Template matching” |
加了呀,打开标记工具就能看到,顺便把多尺度也加上去了。就是这个mark图要自己处理下 |
|
噢我的不好意思 |
- OWTBattleConfig 重声明 green_mark_type 默认 NAME:pydantic v2 默认值不触发 validator,原写法默认仍落 CHOOSE(上游 1c0a01f) - 队长流程检查 create_room/create_ensure 返回值,建房失败提前退出,不再无限等待不会出现的房间控件(上游 1c0a01f) - 多尺度模板匹配循环内接入结果清洗,防极端缩放档同色模板 nan/inf 假阳性;修正零方差判断注释的单通道/全通道措辞(上游 1c0a01f) - annotator 静态资源响应加 Cache-Control: no-cache,防浏览器启发式缓存旧 JS(上游 f476727) - 零方差与结果清洗同族 4 处英文日志中文化 验证:OWT 默认值离线断言 NAME 生效、多尺度匹配冒烟通过、app.py 导入正常;彼世逢魔实机流程待真机验证
/ runhey#1886) 2026-10-10 游戏更新改了 UI 美术,上游同日开了三个素材修复 PR,本提交移植与本库相关的部分。 注意:本库与上游 runhey/master 已长期分叉(共同祖先 2025-11-15;上游多 757 个提交、本库多 1062 个), 故按文件取用,而非合并分支。 --- 取自 runhey#1891(smallwin-jq 退出战斗确认按钮) - gb/gb_exit_ensure.png 换用其素材(135x63 -> 95x46) - I_EXIT_ENSURE 的 roi 同步收紧:roi_front=(701,414,95,46)、roi_back=(648,388,220,96) (原为固定位置比对 (674,388,135,63);新框完全落在金色"确定"按钮内,并容许弹窗轻微位移) - gb/image.json 标注元数据同步 - 该 PR 其余 5 个文件只是注释/排序等装饰性改动,未采纳 - 交叉校验:与本地独立截取的同一弹窗素材在重叠区一致性 0.9874 --- 取自 runhey#1892(weirj2016-ai 悬赏封印独立奖励识别图) - 新增 tasks/WantedQuests/wq/ui_rewardnew.png (239x24) 与规则 I_UI_REWARDNEW (threshold 0.7) - tasks/base_task.py:ui_get_reward() / ui_reward_appear_click() 增加 reward_image 参数, 默认仍用通用 I_UI_REWARD,行为不变;悬赏的奖励弹窗与通用那张不同型 - tasks/WantedQuests/script_task.py:两处宝箱奖励调用改为传 reward_image=self.I_UI_REWARDNEW 本库悬赏探索继承探索任务,其"小纸人奖励"路径仍用通用 I_UI_REWARD(已修),未改动 - 未采用上游的 I_UI_REWARDnew 别名写法(本库类直接继承 assets,用 I_UI_REWARDNEW 即可) --- 取自 runhey#1893(m123711 换御魂确认按钮) - tasks/Component/SwitchSoul/ss/ss_sou_switch_sure.png 换用其素材(180x61,与 roi_front 尺寸一致,无代码改动) --- 取自 runhey#1886(allesgutefy 组队邀请默认勾选框) - check_and_invite() 点击 I_I_NO_DEFAULT 后 sleep(0.8),避免 UI 状态未刷新导致误判 未采纳:runhey#1885(本库已有 run_task_or_default_general_battle)、runhey#1862 彼世逢魔, 以及 runhey#1872/runhey#1870/runhey#1873/runhey#1847/runhey#1822(对应任务本库未启用)。 旧素材均本地备份为同名 .bak-20261010(未纳入版本库)。
/ runhey#1886) 2026-10-10 游戏更新改了 UI 美术,上游同日开了三个素材修复 PR,本提交移植与本库相关的部分。 注意:本库与上游 runhey/master 已长期分叉(共同祖先 2025-11-15;上游多 757 个提交、本库多 1062 个), 故按文件取用,而非合并分支。 --- 取自 runhey#1891(smallwin-jq 退出战斗确认按钮) - gb/gb_exit_ensure.png 换用其素材(135x63 -> 95x46) - I_EXIT_ENSURE 的 roi 同步收紧:roi_front=(701,414,95,46)、roi_back=(648,388,220,96) (原为固定位置比对 (674,388,135,63);新框完全落在金色"确定"按钮内,并容许弹窗轻微位移) - gb/image.json 标注元数据同步 - 该 PR 其余 5 个文件只是注释/排序等装饰性改动,未采纳 - 交叉校验:与本地独立截取的同一弹窗素材在重叠区一致性 0.9874 --- 取自 runhey#1892(weirj2016-ai 悬赏封印独立奖励识别图) - 新增 tasks/WantedQuests/wq/ui_rewardnew.png (239x24) 与规则 I_UI_REWARDNEW (threshold 0.7) - tasks/base_task.py:ui_get_reward() / ui_reward_appear_click() 增加 reward_image 参数, 默认仍用通用 I_UI_REWARD,行为不变;悬赏的奖励弹窗与通用那张不同型 - tasks/WantedQuests/script_task.py:两处宝箱奖励调用改为传 reward_image=self.I_UI_REWARDNEW 本库悬赏探索继承探索任务,其"小纸人奖励"路径仍用通用 I_UI_REWARD(已修),未改动 - 未采用上游的 I_UI_REWARDnew 别名写法(本库类直接继承 assets,用 I_UI_REWARDNEW 即可) --- 取自 runhey#1893(m123711 换御魂确认按钮) - tasks/Component/SwitchSoul/ss/ss_sou_switch_sure.png 换用其素材(180x61,与 roi_front 尺寸一致,无代码改动) --- 取自 runhey#1886(allesgutefy 组队邀请默认勾选框) - check_and_invite() 点击 I_I_NO_DEFAULT 后 sleep(0.8),避免 UI 状态未刷新导致误判 未采纳:runhey#1885(本库已有 run_task_or_default_general_battle)、runhey#1862 彼世逢魔, 以及 runhey#1872/runhey#1870/runhey#1873/runhey#1847/runhey#1822(对应任务本库未启用)。 旧素材均本地备份为同名 .bak-20261010(未纳入版本库)。
Sourcery 摘要
接入彼世逢魔自动化流程,并增强图像匹配与战斗绿标能力。
新功能:
错误修复:
改进:
Original summary in English
Sourcery 总结
集成 OtherWorldTwilight 自动化流程,并增强战斗标记和图像匹配功能。
新功能:
错误修复:
改进:
Original summary in English
Sourcery 总结
集成“彼世逢魔”自动化流程,并增强战斗绿标与图像匹配能力。
新功能:
错误修复:
增强功能:
杂项:
Original summary in English
Summary by Sourcery
集成“彼世逢魔”自动化流程,并增强战斗绿标与图像匹配能力。
New Features:
Bug Fixes:
Enhancements:
Chores: