feat: 防卫战重置点击确认兜底 - #2437
Conversation
📝 WalkthroughWalkthrough在 ShiyuDefenseApp 的多间模式弱点识别流程中新增“三间选择”界面确认按钮检测与点击处理逻辑,并调整需重置分支中“重置全部”操作,移除后续多余的确认点击,同时将等待时长从 0.3 秒调整为 1 秒。 Changes速刃防线多间模式流程调整
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant App as ShiyuDefenseApp
participant Screen as 三间选择界面
participant Reset as 重置全部流程
App->>Screen: 检测“确认”按钮
alt 检测到确认
App->>Screen: 点击“确认”
alt 点击成功
Screen-->>App: 等待
else 点击失败
App->>Screen: 重试点击
end
else 未检测到
App->>App: 继续既有弱点识别流程
end
App->>Reset: 执行“重置全部”(need_reset 为真)
Reset-->>App: 等待1秒(原0.3秒)
Estimated review time: ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/zzz_od/application/shiyu_defense/shiyu_defense_app.py (2)
199-200: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win“重置全部”点击成功时同样存在重复等待。
与上面同一模式:Line 199 的
success_wait=1在点击成功时已内部sleep(1),Line 200 的round_retry('已重置', wait=1)又外层sleep(1),点击成功场景下共计约 2 秒。此次将success_wait从 0.3 调整为 1(PR 目标之一),使该重复等待从原先的额外 0.3 秒放大到额外 1 秒,代价被放大了。建议去掉success_wait=1,仅保留外层wait=1。🐛 建议修复
if need_reset: - self.round_by_click_area('式舆防卫战-三间选择', '重置全部', success_wait=1) + self.round_by_click_area('式舆防卫战-三间选择', '重置全部') return self.round_retry('已重置', wait=1)🤖 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 199 - 200, The “重置全部” click path in shiyu_defense_app should not double-sleep on success. In the sequence using self.round_by_click_area(...) followed by self.round_retry('已重置', wait=1), remove the success_wait=1 from round_by_click_area so the click-success case only uses the outer round_retry wait. Keep the retry flow unchanged and make sure the behavior matches the same pattern used elsewhere in Shiyu defense click handling.
176-182: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win确认点击成功后存在重复等待,实际延迟约为预期的两倍。
round_by_click_area(..., success_wait=1)在点击成功时内部已通过round_success(wait=1)触发time.sleep(1);随后 Line 180 又调用self.round_wait('点击确认', wait=1)再次sleep(1),导致点击成功后总共等待约 2 秒而非预期的 1 秒。对比同文件其他位置(如 Line 141-146)的写法:调用round_by_find_and_click_area时不传success_wait,仅在外层显式wait=1,只等待一次。建议二选一,去掉内部success_wait或去掉外层显式wait。🐛 建议修复:去除重复等待
result = self.round_by_find_area(self.last_screenshot, '式舆防卫战-三间选择', '确认') if result.is_success: - click = self.round_by_click_area('式舆防卫战-三间选择', '确认', success_wait=1) + click = self.round_by_click_area('式舆防卫战-三间选择', '确认') if click.is_success: return self.round_wait('点击确认', wait=1) return self.round_retry('点击确认失败', wait=1)🤖 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 176 - 182, In shiyu_defense_app.py, the confirmation flow in the area-selection branch is waiting twice after a successful click: `round_by_click_area(..., success_wait=1)` already sleeps via `round_success`, and `round_wait('点击确认', wait=1)` adds another delay. Update the `round_by_find_area` / `round_by_click_area` / `round_wait` sequence so only one wait is applied, matching the pattern used elsewhere in this class (e.g. the `round_by_find_and_click_area` flow). Either remove the `success_wait` argument from `round_by_click_area` or remove the outer `round_wait` call, but keep the behavior consistent and single-delay only.
🤖 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.
Nitpick comments:
In `@src/zzz_od/application/shiyu_defense/shiyu_defense_app.py`:
- Around line 199-200: The “重置全部” click path in shiyu_defense_app should not
double-sleep on success. In the sequence using self.round_by_click_area(...)
followed by self.round_retry('已重置', wait=1), remove the success_wait=1 from
round_by_click_area so the click-success case only uses the outer round_retry
wait. Keep the retry flow unchanged and make sure the behavior matches the same
pattern used elsewhere in Shiyu defense click handling.
- Around line 176-182: In shiyu_defense_app.py, the confirmation flow in the
area-selection branch is waiting twice after a successful click:
`round_by_click_area(..., success_wait=1)` already sleeps via `round_success`,
and `round_wait('点击确认', wait=1)` adds another delay. Update the
`round_by_find_area` / `round_by_click_area` / `round_wait` sequence so only one
wait is applied, matching the pattern used elsewhere in this class (e.g. the
`round_by_find_and_click_area` flow). Either remove the `success_wait` argument
from `round_by_click_area` or remove the outer `round_wait` call, but keep the
behavior consistent and single-delay only.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 98744fdb-69d1-4525-afcb-ee513aa7634b
📒 Files selected for processing (1)
src/zzz_od/application/shiyu_defense/shiyu_defense_app.py
变更说明
验证
Summary by CodeRabbit