Skip to content

Automated PR 2026.09.25 - #1839

Merged
github-actions[bot] merged 16 commits into
masterfrom
dev
Sep 25, 2026
Merged

github-actions[bot] merged 16 commits into
masterfrom
dev

Conversation

@github-actions

@github-actions github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Automated PR created by GitHub Actions. Merge dev into master

Sourcery 摘要

扩展时装识别、每周活动和战斗自动化,同时引入可复用的可配置战斗运行时和多帧图像匹配功能。

新功能:

  • 支持玉岚狐庭时装,并使用多帧图像资源和 GIF 风格的匹配方式。
  • 添加可选的每周琐事流程,用于保存摸鱼奖励。
  • 添加摸鱼页面的导航以及图像/OCR 资源。

错误修复:

  • 在不同爬塔类型之间重置战斗状态时,保留各活动独立的爬塔次数。
  • 等待更长时间以确保商城页面出现,从而提高商店导航的可靠性。

改进:

  • 围绕可配置策略、类型化选项、生命周期作用域状态和运行时钩子分发,重构通用战斗处理逻辑。
  • 支持将多帧匹配行为直接附加到现有图像规则,并在图像等待/点击辅助方法中使用该功能。
  • 将活动战斗集成到共享战斗框架中,包括可配置的准备流程、预设、绿色标记、随机行动以及按任务统计结果。

测试:

  • 增加对战斗运行时状态/选项处理以及随机行动触发条件的测试覆盖。

杂项:

  • 更新本地化内容,并清理细微的格式问题和调试输出。
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:

  • Add support for the 玉岚狐庭 costume with multi-frame image assets and GIF-style matching.
  • Add an optional Weekly Trifles workflow for saving Touch Fish rewards.
  • Add navigation and image/OCR assets for the Touch Fish page.

Bug Fixes:

  • Preserve independent activity climb counts while resetting battle state between climb types.
  • Improve store navigation reliability by waiting longer for the mall page to appear.

Enhancements:

  • Refactor general battle handling around configurable strategies, typed options, lifecycle-scoped state, and runtime hook dispatch.
  • Support attaching multi-frame matching behavior directly to existing image rules and using it in image wait/click helpers.
  • Integrate activity battles with the shared battle framework, including configurable preparation, presets, green marks, random actions, and per-task result counting.

Tests:

  • Add coverage for battle runtime state/options handling and random-action gating.

Chores:

  • Add localization updates and clean up minor formatting and debug output.

m123711 and others added 16 commits September 12, 2026 12:27
…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
- 默认仅仅使用全部存储按钮
- 会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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

嘿——我发现了 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


Sourcery 对开源项目免费——如果您喜欢我们的审查,请考虑分享 ✨
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


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread tasks/base_task.py

def wait_until_appear(self,
target: RuleImage | RuleOcr,
target: RuleImage | RuleGif | RuleOcr,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment on lines +380 to +381
runtime.pub_ctx.per_task['drop'] = 1
runtime.pri_ctx['_bw_setup_probe'].per_task['drop'] = 1

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment on lines +415 to +419
runtime.update_options({
'setup': {'x': 1},
'completion': {'y': 2},
'success': {'z': 3},
})

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@github-actions
github-actions Bot merged commit 71fa432 into master Sep 25, 2026
2 checks passed
tokisakijsq1 added a commit to tokisakijsq1/OnmyojiAutoScript that referenced this pull request Sep 28, 2026
合并上游 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 已不存在),
与本次合并无关。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants