Skip to content

fix: 修复剧变节点进度解析 (#2506) - #2510

Merged
ShadowLemoon merged 4 commits into
OneDragon-Anything:mainfrom
kawayiYokami:fix/issue-2506-defense-node
Jul 19, 2026
Merged

fix: 修复剧变节点进度解析 (#2506)#2510
ShadowLemoon merged 4 commits into
OneDragon-Anything:mainfrom
kawayiYokami:fix/issue-2506-defense-node

Conversation

@kawayiYokami

@kawayiYokami kawayiYokami commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

修复内容

  • OCR 将剧变节点进度 2/5 连写为 215 时,按首尾数字解析为 2/5,不再误判全部完成。
  • 正常进度与仅显示总节点数的已完成状态保持原有行为。

验证

  • uv run pytest zzz-od-test/test/zzz_od/application/shiyu_defense/test_choose_node_idx.py
  • uv run ruff check zzz-od-test/test/zzz_od/application/shiyu_defense/test_choose_node_idx.py

关联测试 PR:OneDragon-Anything/zzz-od-test#18

Fixes #2506

Summary by CodeRabbit

  • Bug Fixes
    • 优化“剧变节点”进度读取的解析方式,提升 OCR 结果下的识别稳定性。
    • 改进最大节点判断与“全部完成”状态处理,减少误判或过早结束。
    • 进一步调整后续节点选择/退出逻辑,解析异常时可更安全地继续执行。
  • Documentation
    • 更新合并与评审流程文档,补充合并后的分支清理提示,并强化测试仓分支切换与基线合并要求。

@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a8de982f-a221-4b2e-a54d-e75a29deb55d

📥 Commits

Reviewing files that changed from the base of the PR and between 6136218 and 7137601.

📒 Files selected for processing (2)
  • skills/zzz-od-dev-pr-finishing/SKILL.md
  • skills/zzz-od-dev-pr-review/SKILL.md

📝 Walkthrough

Walkthrough

式舆防卫战改用单个数字字符解析剧变节点 OCR 进度,并据此更新最大节点索引和下一节点索引;同时补充测试仓分支准备及合并后分支清理的 PR 流程说明。

Changes

剧变节点进度处理

Layer / File(s) Summary
OCR 进度解析与节点分支
src/zzz_od/application/shiyu_defense/shiyu_defense_app.py
choose_node_idx 从 OCR 文本提取单个数字字符,以首尾数字计算当前与总节点数;检测到单个数字时判定完成,解析失败时将下一节点索引设为 1。

PR 流程文档

Layer / File(s) Summary
测试与合并后分支流程
skills/zzz-od-dev-pr-review/SKILL.md, skills/zzz-od-dev-pr-finishing/SKILL.md
明确测试仓需创建同名分支并基于最新 main 合并;补充合并后仅提示删除本地与远程分支的说明。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 标题准确概括了修复剧变节点进度解析的问题,和本次改动一致。
Linked Issues check ✅ Passed 改动修正了OCR将进度误识别为215导致提前判定完成的问题,符合[#2506]的核心诉求。
Out of Scope Changes check ✅ Passed 仅涉及剧变节点进度OCR解析逻辑调整,未见与目标无关的额外改动。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/zzz_od/application/shiyu_defense/shiyu_defense_app.py`:
- Around line 102-115: 在处理多个 OCR 数字的分支中,更新进度解析逻辑以校验 current 和 total 的合法性:要求
current 不大于 total,且 total 不小于 1;校验失败时不要写入
critical_max_node_idx,也不要判定完成,改为沿用现有的解析失败流程。保留合法进度的日志、配置更新和完成判定行为。
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cd47bc1b-8d32-4c41-a965-2fba7f8bdb7f

📥 Commits

Reviewing files that changed from the base of the PR and between 91add0b and 6136218.

📒 Files selected for processing (1)
  • src/zzz_od/application/shiyu_defense/shiyu_defense_app.py

Comment on lines +102 to +115
if len(digits) >= 2:
current = int(digits[0])
total = int(digits[-1])
log.info('剧变节点进度 %d/%d', current, total)
self.config.critical_max_node_idx = total
next_idx = current + 1
if next_idx > total:
return self.round_success(ShiyuDefenseApp.STATUS_ALL_FINISHED)
elif len(digits) == 1:
# 只有一个数字,可能是 "5",说明已完成
total = int(digits[0])
log.info('剧变节点进度 已完成 %d', total)
self.config.critical_max_node_idx = total
return self.round_success(ShiyuDefenseApp.STATUS_ALL_FINISHED)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

增加对 OCR 解析结果的基础合法性校验

提取首尾数字作为进度的方法在遇到极端的 OCR 误读(例如解析出 current > total)或未来游戏更新中节点数达到两位数(例如 "10/10" 会被拆分为 ['1', '0', '1', '0'],导致 current=1, total=0)时,会解析出错误的数值。这不仅会导致误判为全部完成,还会将错误的 total 值覆写到配置 critical_max_node_idx 中。

建议增加基础的数值合法性校验,若不合法则回退到解析失败的逻辑,以保护配置数据的完整性。

🛡️ 建议的修复
-            if len(digits) >= 2:
-                current = int(digits[0])
-                total = int(digits[-1])
-                log.info('剧变节点进度 %d/%d', current, total)
-                self.config.critical_max_node_idx = total
-                next_idx = current + 1
-                if next_idx > total:
-                    return self.round_success(ShiyuDefenseApp.STATUS_ALL_FINISHED)
-            elif len(digits) == 1:
-                # 只有一个数字,可能是 "5",说明已完成
-                total = int(digits[0])
-                log.info('剧变节点进度 已完成 %d', total)
-                self.config.critical_max_node_idx = total
-                return self.round_success(ShiyuDefenseApp.STATUS_ALL_FINISHED)
+            if len(digits) >= 2:
+                current = int(digits[0])
+                total = int(digits[-1])
+                if current > total or total == 0:
+                    log.info('OCR 进度解析结果异常 (current=%d, total=%d): %s', current, total, progress_text)
+                    next_idx = 1
+                else:
+                    log.info('剧变节点进度 %d/%d', current, total)
+                    self.config.critical_max_node_idx = total
+                    next_idx = current + 1
+                    if next_idx > total:
+                        return self.round_success(ShiyuDefenseApp.STATUS_ALL_FINISHED)
+            elif len(digits) == 1:
+                # 只有一个数字,可能是 "5",说明已完成
+                total = int(digits[0])
+                if total == 0:
+                    log.info('OCR 进度解析结果异常 (total=0): %s', progress_text)
+                    next_idx = 1
+                else:
+                    log.info('剧变节点进度 已完成 %d', total)
+                    self.config.critical_max_node_idx = total
+                    return self.round_success(ShiyuDefenseApp.STATUS_ALL_FINISHED)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if len(digits) >= 2:
current = int(digits[0])
total = int(digits[-1])
log.info('剧变节点进度 %d/%d', current, total)
self.config.critical_max_node_idx = total
next_idx = current + 1
if next_idx > total:
return self.round_success(ShiyuDefenseApp.STATUS_ALL_FINISHED)
elif len(digits) == 1:
# 只有一个数字,可能是 "5",说明已完成
total = int(digits[0])
log.info('剧变节点进度 已完成 %d', total)
self.config.critical_max_node_idx = total
return self.round_success(ShiyuDefenseApp.STATUS_ALL_FINISHED)
if len(digits) >= 2:
current = int(digits[0])
total = int(digits[-1])
if current > total or total == 0:
log.info('OCR 进度解析结果异常 (current=%d, total=%d): %s', current, total, progress_text)
next_idx = 1
else:
log.info('剧变节点进度 %d/%d', current, total)
self.config.critical_max_node_idx = total
next_idx = current + 1
if next_idx > total:
return self.round_success(ShiyuDefenseApp.STATUS_ALL_FINISHED)
elif len(digits) == 1:
# 只有一个数字,可能是 "5",说明已完成
total = int(digits[0])
if total == 0:
log.info('OCR 进度解析结果异常 (total=0): %s', progress_text)
next_idx = 1
else:
log.info('剧变节点进度 已完成 %d', total)
self.config.critical_max_node_idx = total
return self.round_success(ShiyuDefenseApp.STATUS_ALL_FINISHED)
🧰 Tools
🪛 Ruff (0.15.21)

[warning] 111-111: Comment contains ambiguous (FULLWIDTH COMMA). Did you mean , (COMMA)?

(RUF003)


[warning] 111-111: Comment contains ambiguous (FULLWIDTH COMMA). Did you mean , (COMMA)?

(RUF003)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/zzz_od/application/shiyu_defense/shiyu_defense_app.py` around lines 102 -
115, 在处理多个 OCR 数字的分支中,更新进度解析逻辑以校验 current 和 total 的合法性:要求 current 不大于 total,且
total 不小于 1;校验失败时不要写入
critical_max_node_idx,也不要判定完成,改为沿用现有的解析失败流程。保留合法进度的日志、配置更新和完成判定行为。

DoctorReid and others added 3 commits July 19, 2026 12:44
…e-node

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
…e-node

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>
- pr-review + pr-finishing: PR 合并后提示删本地 + remote 分支(只提示,不主动)
- pr-review: 审 PR 时无论有无配套测试仓 PR,都先本地建同名分支占位(防补测试忘记切分支 → 误 commit 测试仓 main,即 OneDragon-Anything#2348 的 4ca301d 教训)

Co-Authored-By: Claude Code <noreply@anthropic.com>
@ShadowLemoon
ShadowLemoon merged commit f1fb2b5 into OneDragon-Anything:main Jul 19, 2026
6 of 8 checks passed
DoctorReid added a commit that referenced this pull request Jul 19, 2026
* fix: 修复剧变节点进度解析 (#2506)

* docs(skill): 补合并后删分支提示 + 测试仓分支占位方法论

- pr-review + pr-finishing: PR 合并后提示删本地 + remote 分支(只提示,不主动)
- pr-review: 审 PR 时无论有无配套测试仓 PR,都先本地建同名分支占位(防补测试忘记切分支 → 误 commit 测试仓 main,即 #2348 的 4ca301d 教训)

Co-Authored-By: Claude Code <noreply@anthropic.com>

* docs(game): 式舆防卫战(选关)+ 快捷手册 建档 + 玩法 doc(对应 #2510 L4 建档)

战斗 app 首次建档(L4 导航触发):式舆防卫战选关主界面(前哨档案+节点01-05+剧变节点进度)+ 快捷手册(5 TAB 入口)+ 式舆防卫战玩法。截图归档测试仓 fix/issue-2506-defense-node 分支。

Co-Authored-By: Claude Code <noreply@anthropic.com>

* docs(skill): onboard 方法论强化 + 防卫战 source_image 归档名(对应 #2510)

- AGENTS.md 加「改/建 skill」节(触发 skill-guide + design.md + 写方法论,工具无关)
- onboard skill:覆盖检查写方法论(去 mock_screen 等具体 API)+ source_image 归档后用 screens/<screen>/<state>.webp + 玩法 doc 触发 gameplay skill;design.md 同步
- convert_to_webp.py 加覆盖提醒
- 式舆防卫战 + 快捷手册 source_image 更新为归档 state 名完整路径

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>

* docs(game): 画面 doc source_image 统一为测试仓相对路径(对应 #2510)

23 个旧 doc 的 source_image 从 .debug 临时名/英文 fixture 名/只 state 名统一为 screens/<screen>/<state>.webp(自描述可找);顺带修正 doc 名 ≠ 测试仓名(3D地图 map_3d_default→默认、仓库 storage_drive_disc_default→默认、战斗画面 _xxx.png→默认/精英、大世界 _xxx→普通 等)。待补的吼吼饼铺/委托助手不动。

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>

* feat(backend): analyze_screen 返回 vision_hint 能力边界提示

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>

* docs(skill): 处理 #2517 CodeRabbit review(周期/建模统一 + source_image 契约 + convert_to_webp 移 design + vision_hint docstring)

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>

* docs(review): screenshot_archive 加图流程补多子态标题 source_image 同步(#2517 CodeRabbit)

Co-Authored-By: Claude Code <noreply@anthropic.com>
Co-Authored-By: glm-5.2 <noreply@bigmodel.cn>

---------

Co-authored-by: kawayiYokami <95584793+kawayiYokami@users.noreply.github.com>
Co-authored-by: Claude Code <noreply@anthropic.com>
Co-authored-by: glm-5.2 <noreply@bigmodel.cn>
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Jul 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[一条龙日常] 新一期剧变节点,3、4、5未打就认为已完成215

3 participants