Skip to content

fix: 饰品提取识别挑战完成框/计算挑战次数#567

Open
JoshCai233 wants to merge 2 commits intoOneDragon-Anything:mainfrom
JoshCai233:fix_charge_plan
Open

fix: 饰品提取识别挑战完成框/计算挑战次数#567
JoshCai233 wants to merge 2 commits intoOneDragon-Anything:mainfrom
JoshCai233:fix_charge_plan

Conversation

@JoshCai233
Copy link
Copy Markdown
Contributor

@JoshCai233 JoshCai233 commented Jan 11, 2026

未标题-1 修复了这种情况识别失败

Summary by CodeRabbit

  • Bug Fixes

    • 修正了“再来一次”按钮的点击区域及尺寸,提升界面点击准确性与交互体验。
  • New Features

    • 多次运行挑战时改进了完成计数与奖励累计逻辑,按实际选择次数累计奖励并上限处理;在返回关卡后若仍有剩余次数,会提示重新选择次数以便重试。

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 11, 2026

Walkthrough

更新了战斗界面“再来一次”按钮点击区域,并在遗器提取操作中新增公有实例属性 choose_times(默认 1),用于按批次累积战斗成功计数、触发奖励回调以及控制后续重试/退出逻辑。

Changes

Cohort / File(s) 变更摘要
UI坐标更新
assets/game_data/screen_info/battle.yml
调整“再来一次按钮”区域坐标:从 [1180, 930, 1330, 960] 修改为 [1180, 930, 1400, 1000]
遗器提取逻辑
src/sr_od/app/div_uni/operations/ornamenet_extraction.py
新增公有实例属性 choose_times: int(初值 1);在 click_challenge_times 中若 run_times > 1choose_times = min(6, run_times)wait_battle_result 在 BATTLE_SUCCESS 时以 choose_times 增量累加 battle_success_times 并以该值调用奖励回调;after_battle_resultwait_back 的退出与重试判断改为基于 battle_success_times + choose_times
清单/元信息
manifest_file (变更摘要)
少量行变更记录(+2/-2),无额外 API/导出声明改动。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • 新版本的副本挑战次数 #544 — 修改相同文件 src/sr_od/app/div_uni/operations/ornamenet_extraction.py,涉及 click_challenge_times / 多次挑战选择行为,与本次 choose_times 的引入和使用直接相关.

Poem

🐰 月下小兔轻轻跳,按钮坐标往外跑,
选择次数记心间,批次累加更周到,
战斗胜利叮咚响,奖励回调来报到 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 71.43% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题准确地概括了主要变更:修复了饰品提取中对挑战完成框的识别问题并优化了挑战次数的计算逻辑。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bec8f2f and fb56377.

📒 Files selected for processing (1)
  • src/sr_od/app/div_uni/operations/ornamenet_extraction.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/sr_od/app/div_uni/operations/ornamenet_extraction.py

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @src/sr_od/app/div_uni/operations/ornamenet_extraction.py:
- Around line 34-35: The field self.completed_times is incorrectly initialized
to -1 and misdocumented; change its initial value to 0 and update the docstring
to reflect its actual meaning ("本次战斗实际完成的挑战次数" or similar). Update the
declaration of self.completed_times (the symbol completed_times in
ornamenet_extraction.py) from -1 to 0 so subsequent logic (e.g., increments that
affect battle_fail_times, battle_success_times and get_reward_callback) no
longer underflow, and replace the current comment that mirrors run_times with a
concise description of its meaning.
- Around line 176-181: The bug is that completed_times is only set in
click_challenge_times() and not recalculated when a retry path returns to
wait_battle_result(), causing battle_success_times to overshoot run_times;
update logic so completed_times is recalculated before each battle attempt or
before incrementing counters (e.g., in wait_battle_result() or right when
handling ScreenState.BATTLE_SUCCESS/BATTLE_FAIL in round_by_op_result()) by
computing completed_times = min(remaining = run_times - (battle_success_times +
battle_fail_times), originally_requested_times) or cap the increment applied to
battle_success_times/battle_fail_times to not exceed run_times, ensuring
completed_times and the increments never push totals past run_times.
🧹 Nitpick comments (1)
src/sr_od/app/div_uni/operations/ornamenet_extraction.py (1)

123-123: 建议在 else 分支中显式设置 completed_times。

虽然将初始值改为 1 可以解决问题,但为了代码清晰性和防御性编程,建议在 run_times == 1 的情况下也显式设置 completed_times = 1

♻️ 建议的改进
         log.info('本次挑战次数 %d', self.run_times)
         if self.run_times > 1:
             self.completed_times = min(6, self.run_times)
             op = ChooseChallengeTimes(self.ctx, min(6, self.run_times), mission_type='饰品提取')
             return self.round_by_op_result(op.execute())
         else:
+            self.completed_times = 1
             return self.round_success()
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 077457d and 7c5d763.

📒 Files selected for processing (2)
  • assets/game_data/screen_info/battle.yml
  • src/sr_od/app/div_uni/operations/ornamenet_extraction.py
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-10-13T12:07:30.874Z
Learnt from: JoshCai233
Repo: OneDragon-Anything/StarRailOneDragon PR: 521
File: src/sr_od/app/sim_uni/sim_uni_app.py:61-87
Timestamp: 2025-10-13T12:07:30.874Z
Learning: 在 `_check_points_reward()` 中,`OperationRoundResult` 的语义与常规不同:`FAIL` 表示"奖励未完成,需要继续执行自动化",而 `SUCCESS` 和 `RETRY` 表示"提前返回,跳过自动化"。这是因为调用方使用 `if result != FAIL: return` 来判断是否跳过后续的自动化脚本执行。

Applied to files:

  • src/sr_od/app/div_uni/operations/ornamenet_extraction.py
📚 Learning: 2025-12-21T03:02:25.697Z
Learnt from: JoshCai233
Repo: OneDragon-Anything/StarRailOneDragon PR: 521
File: src/script_chainer/win_exe/script_runner.py:96-102
Timestamp: 2025-12-21T03:02:25.697Z
Learning: In Python code across the project (e.g., src/script_chainer/win_exe/script_runner.py), prefer using the project's log module for logging to files instead of using print statements for console output. Print does not write to log files, so replace prints with logger calls (e.g., log.info, log.debug, log.error) and ensure proper logging configuration is in place.

Applied to files:

  • src/sr_od/app/div_uni/operations/ornamenet_extraction.py
🧬 Code graph analysis (1)
src/sr_od/app/div_uni/operations/ornamenet_extraction.py (1)
src/one_dragon/base/operation/operation.py (2)
  • round_by_op_result (766-787)
  • status (51-55)
🔇 Additional comments (1)
assets/game_data/screen_info/battle.yml (1)

52-53: 坐标扩展合理,有助于提高按钮识别率。

"再来一次按钮"的点击区域从 [1330, 960] 扩展到 [1400, 1000],这与PR目标中修复识别失败的问题相符。扩大的区域应该能够更好地覆盖多次挑战模式下的按钮显示范围。

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