Skip to content

fix: 修复副本战斗失败/撤退后返回大世界卡在退出战斗的死循环 - #2467

Open
Jason25417 wants to merge 1 commit into
OneDragon-Anything:mainfrom
Jason25417:fix/back-to-world-exit-battle-loop
Open

fix: 修复副本战斗失败/撤退后返回大世界卡在退出战斗的死循环#2467
Jason25417 wants to merge 1 commit into
OneDragon-Anything:mainfrom
Jason25417:fix/back-to-world-exit-battle-loop

Conversation

@Jason25417

@Jason25417 Jason25417 commented Jul 9, 2026

Copy link
Copy Markdown

问题

一条龙在副本战斗失败 / 撤退后返回大世界时,返回大世界BackToNormalWorld)会卡在「按钮-退出战斗」的识别循环,直到 node_max_retry_times=60 耗尽后整个算子失败。由于它是被到处调用的通用返回步骤,这一次卡死会连锁导致后续多个日常应用失败(体力刷本收尾、活跃度奖励、丽都城募、丽都周纪等)。

复现

体力刷本 的副本自动战斗**失败(战斗结果-撤退)**后,画面停在战斗菜单,返回大世界 连续约 50 轮恒为「按钮-退出战斗」直至失败:

[04:15:41] 指令[ 区域巡防 机师与叛甲 ] 节点 自动战斗 -> 战斗失败 返回状态 战斗结果-撤退
...
[04:16:09] 指令[ 返回大世界 ] 节点 画面识别 返回状态 按钮-退出战斗
[04:16:11] 指令[ 返回大世界 ] 节点 画面识别 返回状态 按钮-退出战斗
        …(约 50 轮,恒为「按钮-退出战斗」,全程未出现「按钮-退出战斗-确认」)…
[04:17:48] [ERROR] 指令[ 返回大世界 ] 执行失败 返回状态 按钮-退出战斗
[04:17:48] [ERROR] 指令[ 体力刷本 ] 执行失败 返回状态 按钮-退出战斗

根因

check_screen_and_run(单节点,node_max_retry_times=60)中退出战斗的分支:

result = self.round_by_find_and_click_area(self.last_screenshot, '战斗-菜单', '按钮-退出战斗')
if result.is_success:
    self.click_exit_battle = True
    return self.round_retry(result.status, wait=1)
if self.click_exit_battle:  # 点确认框
    ...

round_by_find_and_click_area 的成功只代表模板找到并点击,不代表点击生效、确认框已弹出。当点击未真正推进时,下一轮仍会在第一处匹配到「按钮-退出战斗」并 return,使得点确认框的分支永远够不到,自锁到 60 轮耗尽。日志全程只有「按钮-退出战斗」、从未出现「按钮-退出战斗-确认」,正是此自锁的表现。

修复

复用仓库已有的 ExitInBattle——它用 until_find_all / until_not_find_all 做了「点退出战斗 → 等确认框出现 → 点确认 → 等确认框消失」的完整闭环,能保证点击真正生效后才推进:

result = self.round_by_find_area(self.last_screenshot, '战斗-菜单', '按钮-退出战斗')
if result.is_success:
    ExitInBattle(self.ctx).execute()
    return self.round_retry(result.status, wait=1)

测试

  • python -m py_compile 通过,模块可正常 import(无循环 import);
  • 本地打补丁后运行,副本战斗失败 / 撤退场景不再卡死。

Summary by CodeRabbit

  • Bug Fixes
    • 优化了战斗菜单中的“退出战斗”处理流程,点击后会更稳定地完成退出与确认框处理。
    • 保留原有重试机制,减少因弹窗状态变化导致的操作中断。

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6aaf1a9d-d8c6-4dc8-9890-43db53be5ece

📥 Commits

Reviewing files that changed from the base of the PR and between 350ec4c and 53d0b0c.

📒 Files selected for processing (1)
  • src/zzz_od/operation/back_to_normal_world.py

📝 Walkthrough

Walkthrough

BackToNormalWorld 中新增对 ExitInBattle 的依赖,退出战斗分支不再自行维护两步点击状态,改为调用 ExitInBattle(self.ctx).execute() 完成点击与确认闭环;同时移除 handle_init 中的 click_exit_battle 状态成员。

Changes

退出战斗逻辑重构

Layer / File(s) Summary
引入 ExitInBattle 并替换退出战斗处理逻辑
src/zzz_od/operation/back_to_normal_world.py
导入 ExitInBattle,移除 handle_init 中 click_exit_battle 状态成员的初始化,check_screen_and_run 中识别到“按钮-退出战斗”后改为调用 ExitInBattle(self.ctx).execute() 完成退出与确认闭环,再按原重试机制继续。

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: Usagi-wusaqi

🚥 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 标题准确概括了本次修复的核心问题:副本战斗失败或撤退后返回大世界时卡在退出战斗死循环。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

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