Automated PR 2026.09.25 - #1839
Conversation
…ntime context injection - extract battle_wait_options decorator/with-context so plan and options are managed independently - replace BattleWaitContext with PublicContext/PrivateContext and PerTaskState/PerBattleState dataclasses - wrap _bw_* hooks via runtime in BattleWait.__new__, injecting singleton pub_ctx and per-hook pri_ctx - add hook_enabled_update lifecycle: completion stays disabled until success/failure settles - centralize hook events/sequence/options defaults into module-level constants - add BattleResult enum and migrate hooks to write pub.per_battle.success - update tests: runtime injection/distribution/scope coverage, xfail not-yet-migrated cases
…event dataclasses
- 默认仅仅使用全部存储按钮 - 会ocr当前福运御守数量,不足则不执行 - 因为是新增功能所以默认关闭 - 主要目的是让真蛇每周打一次即可获得全部奖励,同时避免周常活动遗漏
…and config-driven loadout - add per-task/per-battle states and options for the new battle wait hooks - add loadout_default/loadout_show/state_show and loadout_from_config for config-driven setup - add randomclick_gate with start_delay/execution_limit/cooldown/trigger_probability gates - dispatch options per plan in runtime.update_options and extract setup_hook enable/disable - wire ActivityShikigami ScriptTask to Battle loadout flow - add tests for randomclick_gate and remove debug prints
…e climb counting add Battle.battle_count_reached to compare per-task count against task limit add Battle.battle_state_reset to clear per_task/per_battle state on task switch restore ActivityShikigami count_map increment on battle success and reset battle state when climbing type switches migrate battle_wait strategy usage docs into battle_wait_strategy docstring and prune outdated examples
fix(GameUi): refresh page_main_goto_summon template to match current game version
feat(WeeklyTrifles):每周琐事新增执行惠比寿的摸鱼行动功能
…ng works #1824 - add RuleGif.attach_to to swap GIF match methods onto a RuleImage instance - switch COSTUME_MAIN_17 replacement from set_asset to in-place attach_to - retune pet_house 17_a/17_b frame ROI and images
There was a problem hiding this comment.
嘿——我发现了 3 个问题
面向 AI Agent 的提示
请处理这次代码审查中的评论:
## 单独评论
### 评论 1
<location path="tasks/base_task.py" line_range="286" />
<code_context>
def wait_until_appear(self,
- target: RuleImage | RuleOcr,
+ target: RuleImage | RuleGif | RuleOcr,
skip_first_screenshot=False,
wait_time: int = None) -> bool:
</code_context>
<issue_to_address>
**issue (bug_risk):** `RuleGif` 被用于 `wait_until_appear` 和 `wait_until_appear_then_click` 的注解中,但此 diff 没有将其导入 `tasks/base_task.py`;如果未启用延迟注解求值,导入 `base_task.py` 时会抛出 `NameError`。
**建议修复:** 添加 `from module.atom.gif import RuleGif`,或启用延迟注解。
</issue_to_address>
### 评论 2
<location path="tests/tasks/Component/GeneralBattle/test_battle_wait.py" line_range="380-381" />
<code_context>
+ battle_wait = _make_runtime_probe()
+ getattr(battle_wait, '_bw_setup_probe')()
+ runtime.pub_ctx.cross['keep'] = 1
+ runtime.pub_ctx.per_task['drop'] = 1
+ runtime.pri_ctx['_bw_setup_probe'].per_task['drop'] = 1
+
+ # 换一个 owner 触发 reset_per_task: cross 保留, per_task 清空
</code_context>
<issue_to_address>
**issue (testing):** 运行时测试仍将 `runtime.pub_ctx.per_task` 以及私有的 per-task/per-battle 状态视为字典,但生产代码现在存储的是 `PerTaskState` 和数据类实例;诸如 `per_task['drop'] = 1` 的赋值会抛出 `TypeError`,字典比较也无效。
**触发条件:** 这些运行时状态测试在数据类迁移后执行时。
**建议修复:** 设置并断言数据类字段,例如 `runtime.pub_ctx.per_task.count`,而不是使用字典索引。
</issue_to_address>
### 评论 3
<location path="tests/tasks/Component/GeneralBattle/test_battle_wait.py" line_range="415-419" />
<code_context>
+ getattr(battle_wait, '_bw_completion_probe')()
+ getattr(battle_wait, '_bw_success_probe')()
+
+ runtime.update_options({
+ 'setup': {'x': 1},
+ 'completion': {'y': 2},
+ 'success': {'z': 3},
+ })
+
+ # pub 拿整份 options
</code_context>
<issue_to_address>
**issue (testing):** 测试调用 `runtime.update_options` 时未传入必需的 `plan` 参数,因此每次调用都会抛出 `TypeError`,而不是测试选项的分发或清除。
**触发条件:** 运行时选项测试执行时。
**建议修复:** 为每次 `runtime.update_options` 调用传入当前的 `BattleWaitPlan`,或在 API 中将 `plan` 设为可选参数。
</issue_to_address>Sourcery 评估
需要人工审查。 有 3 个问题需要优先处理;此外,新的全局战斗运行时会改变活动战斗的准备、预设选择、标记、完成和计数逻辑,因此状态或钩子错误可能会启动错误的战斗、消耗游戏内资源,或错误记录奖励。回滚可以阻止进一步损害,但无法恢复已经执行的战斗,也无法恢复已被改变的资源和奖励;选择加入的摸鱼流程同样可能改变已存储的每周尝试次数。
阻塞性问题:tasks/base_task.py:286、tests/tasks/Component/GeneralBattle/test_battle_wait.py:381、tests/tasks/Component/GeneralBattle/test_battle_wait.py:419
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/base_task.py" line_range="286" />
<code_context>
def wait_until_appear(self,
- target: RuleImage | RuleOcr,
+ target: RuleImage | RuleGif | RuleOcr,
skip_first_screenshot=False,
wait_time: int = None) -> bool:
</code_context>
<issue_to_address>
**issue (bug_risk):** `RuleGif` is used in the `wait_until_appear` and `wait_until_appear_then_click` annotations, but this diff does not import it into `tasks/base_task.py`; without postponed annotation evaluation, importing `base_task.py` raises `NameError`.
**Suggested fix:** Add `from module.atom.gif import RuleGif` or enable postponed annotations.
</issue_to_address>
### Comment 2
<location path="tests/tasks/Component/GeneralBattle/test_battle_wait.py" line_range="380-381" />
<code_context>
+ battle_wait = _make_runtime_probe()
+ getattr(battle_wait, '_bw_setup_probe')()
+ runtime.pub_ctx.cross['keep'] = 1
+ runtime.pub_ctx.per_task['drop'] = 1
+ runtime.pri_ctx['_bw_setup_probe'].per_task['drop'] = 1
+
+ # 换一个 owner 触发 reset_per_task: cross 保留, per_task 清空
</code_context>
<issue_to_address>
**issue (testing):** The runtime tests still treat `runtime.pub_ctx.per_task` and private per-task/per-battle state as dictionaries, but production code now stores `PerTaskState` and dataclass instances; assignments such as `per_task['drop'] = 1` raise `TypeError` and dictionary comparisons are invalid.
**Triggers:** When these runtime state tests execute after the dataclass migration.
**Suggested fix:** Set and assert dataclass fields, such as `runtime.pub_ctx.per_task.count`, rather than using dictionary indexing.
</issue_to_address>
### Comment 3
<location path="tests/tasks/Component/GeneralBattle/test_battle_wait.py" line_range="415-419" />
<code_context>
+ getattr(battle_wait, '_bw_completion_probe')()
+ getattr(battle_wait, '_bw_success_probe')()
+
+ runtime.update_options({
+ 'setup': {'x': 1},
+ 'completion': {'y': 2},
+ 'success': {'z': 3},
+ })
+
+ # pub 拿整份 options
</code_context>
<issue_to_address>
**issue (testing):** The tests call `runtime.update_options` without the required `plan` argument, so each call raises `TypeError` instead of testing option distribution or clearing.
**Triggers:** When the runtime option tests execute.
**Suggested fix:** Pass the active `BattleWaitPlan` to every `runtime.update_options` call or make `plan` optional in the API.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 3 findings to address first, and the new global battle runtime changes preparation, preset selection, marking, completion, and counting for activity battles, so a state or hook error could start the wrong battles, consume in-game resources, or record rewards incorrectly. Reverting would stop future damage but would not restore battles already run or resources and rewards already changed; the opt-in touch-fish flow can likewise alter stored weekly attempts.
Blocking findings: tasks/base_task.py:286, tests/tasks/Component/GeneralBattle/test_battle_wait.py:381, tests/tasks/Component/GeneralBattle/test_battle_wait.py:419
|
|
||
| def wait_until_appear(self, | ||
| target: RuleImage | RuleOcr, | ||
| target: RuleImage | RuleGif | RuleOcr, |
There was a problem hiding this comment.
issue (bug_risk): RuleGif 被用于 wait_until_appear 和 wait_until_appear_then_click 的注解中,但此 diff 没有将其导入 tasks/base_task.py;如果未启用延迟注解求值,导入 base_task.py 时会抛出 NameError。
建议修复: 添加 from module.atom.gif import RuleGif,或启用延迟注解。
Original comment in English
issue (bug_risk): RuleGif is used in the wait_until_appear and wait_until_appear_then_click annotations, but this diff does not import it into tasks/base_task.py; without postponed annotation evaluation, importing base_task.py raises NameError.
Suggested fix: Add from module.atom.gif import RuleGif or enable postponed annotations.
| runtime.pub_ctx.per_task['drop'] = 1 | ||
| runtime.pri_ctx['_bw_setup_probe'].per_task['drop'] = 1 |
There was a problem hiding this comment.
issue (testing): 运行时测试仍将 runtime.pub_ctx.per_task 以及私有的 per-task/per-battle 状态视为字典,但生产代码现在存储的是 PerTaskState 和数据类实例;诸如 per_task['drop'] = 1 的赋值会抛出 TypeError,字典比较也无效。
触发条件: 这些运行时状态测试在数据类迁移后执行时。
建议修复: 设置并断言数据类字段,例如 runtime.pub_ctx.per_task.count,而不是使用字典索引。
Original comment in English
issue (testing): The runtime tests still treat runtime.pub_ctx.per_task and private per-task/per-battle state as dictionaries, but production code now stores PerTaskState and dataclass instances; assignments such as per_task['drop'] = 1 raise TypeError and dictionary comparisons are invalid.
Triggers: When these runtime state tests execute after the dataclass migration.
Suggested fix: Set and assert dataclass fields, such as runtime.pub_ctx.per_task.count, rather than using dictionary indexing.
| runtime.update_options({ | ||
| 'setup': {'x': 1}, | ||
| 'completion': {'y': 2}, | ||
| 'success': {'z': 3}, | ||
| }) |
There was a problem hiding this comment.
issue (testing): 测试调用 runtime.update_options 时未传入必需的 plan 参数,因此每次调用都会抛出 TypeError,而不是测试选项的分发或清除。
触发条件: 运行时选项测试执行时。
建议修复: 为每次 runtime.update_options 调用传入当前的 BattleWaitPlan,或在 API 中将 plan 设为可选参数。
Original comment in English
issue (testing): The tests call runtime.update_options without the required plan argument, so each call raises TypeError instead of testing option distribution or clearing.
Triggers: When the runtime option tests execute.
Suggested fix: Pass the active BattleWaitPlan to every runtime.update_options call or make plan optional in the API.
合并上游 master(71fa432,PR runhey#1839):GeneralBattle 战斗等待框架重构、 每周摸鱼、玉岚狐庭皮肤、召唤入口模板更新等。 冲突处理与适配: - assets/i18n/zh-CN.json: 保留双方新增键(上游 save_touch_fish + 本地 百鬼指定好友/现世妖约) - tasks/ActivityShikigami/script_task.py: 采用上游版本(继承 Battle + loadout_from_config 新入口),本地未单独改过此文件 - battle_wait.py: battle_wait_with_strategy 显式声明 battle_wait_plan/ options 关键字参数。上游装饰器 inner 以关键字传入 plan,而 EvoZone/ FallenSun/RealmRaid/RyouToppa 的转发式 battle_wait(*args, **kwargs) 接不住该关键字,原实现在第一个 hook 就会 TypeError(上游遗留缺口) 验证:toolkit/python 冒烟通过(四个装饰器任务 + ActivityShikigami loadout 入口均能进入等待循环并正常收尾);test_randomclick_gate 9 通过; test_battle_wait 为上游自带的失效用例(导入 _DEFAULT_PER_BATTLE 已不存在), 与本次合并无关。
Automated PR created by GitHub Actions. Merge dev into master
Sourcery 摘要
扩展时装识别、每周活动和战斗自动化,同时引入可复用的可配置战斗运行时和多帧图像匹配功能。
新功能:
错误修复:
改进:
测试:
杂项:
Original summary in English
Summary by Sourcery
Extend costume recognition, weekly activities, and battle automation while introducing a reusable configurable battle runtime and multi-frame image matching.
New Features:
Bug Fixes:
Enhancements:
Tests:
Chores: