Skip to content

Dev c#1619

Open
LGG686 wants to merge 2 commits into
runhey:devfrom
LGG686:dev-c
Open

Dev c#1619
LGG686 wants to merge 2 commits into
runhey:devfrom
LGG686:dev-c

Conversation

@LGG686
Copy link
Copy Markdown
Contributor

@LGG686 LGG686 commented Jun 8, 2026

Summary by Sourcery

为额外的服装战主题添加支持,并通过可选资源统一战斗素材的处理方式。

新特性:

  • 为服装战 1–14 引入战斗信息图片资源,用于检测战斗信息区域。
  • 新增服装战类型 13 和 14,并提供对应的图片资源和配置条目。

改进:

  • 重构服装战主题模型,将其统一为覆盖战斗 1–14 的映射,包括胜利/失败资源,并可动态跳过未使用或未收集的资源。
  • 更新服装战图片元数据和本地化条目,以与新的战斗主题和战斗信息资源保持一致。
Original summary in English

Summary by Sourcery

Add support for additional costume battle themes and unify battle asset handling with optional resources.

New Features:

  • Introduce battle info image assets for costume battles 1–14 to detect battle information regions.
  • Add new costume battle types 13 and 14 with corresponding image assets and configuration entries.

Enhancements:

  • Refactor costume battle theme model to a unified mapping over battles 1–14, including win/lose assets, and skip unused or uncollected resources dynamically.
  • Update costume battle image metadata and localization entries to align with new battle themes and battle info assets.

LGG686 added 2 commits June 8, 2026 21:04
- 将 battle_theme_model 改为字典推导式风格,与其他配置保持一致
- 在 check_costume_battle 方法中添加未采集资源跳过逻辑
- 将 I_WIN/I_DE_WIN/I_FALSE 改为动态命名,支持所有主题自定义资源
- 新增登云问翠和茸茨跃动战斗皮肤配置
- 更新翻译
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - 我发现了 1 个问题,并留下了一些高层次的反馈:

  • 新的 battle_theme_model 字典推导目前与数值范围 range(1, 15)COSTUME_BATTLE_{i} 命名强耦合;建议考虑直接遍历 BattleType 成员(或一个专门的列表),而不是依赖硬编码下标,这样可以避免未来枚举或名称发生偏移时导致 getattr 失败。
  • battle_theme_model 中,将属性名作为字符串存储,并在 check_costume_battle 中通过 getattr 解析,会增加一层间接性;如果可能,考虑直接存储实际的 RuleImage 属性,或一个直接描述 ROI 的小数据结构,以减少拼写错误和运行时错误的风险。
  • check_costume_battle 中的 hasattr(costume_battle_assets, value) 判断会静默地跳过缺失的资源;如果某些战斗预期必须存在特定资源,你可能希望区分可选和必需键(例如通过拆分模型或增加显式标记),以免必需资源缺失时悄无声息地失败。
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `battle_theme_model` dict comprehension is tightly coupled to the numeric range `range(1, 15)` and `COSTUME_BATTLE_{i}` naming; consider iterating over `BattleType` members themselves (or a dedicated list) instead of hardcoded indices to avoid future enum/name drift causing `getattr` failures.
- In `battle_theme_model`, mapping to attribute names as strings and resolving them with `getattr` in `check_costume_battle` adds a layer of indirection; if possible, consider storing the actual `RuleImage` attributes or a small data structure describing ROIs directly to reduce the risk of typos and runtime errors.
- The `hasattr(costume_battle_assets, value)` guard in `check_costume_battle` silently skips missing assets; if certain assets are expected to be present for some battles, you might want to distinguish between optional and required keys (e.g., by splitting the model or adding an explicit flag) so that missing required assets don’t fail quietly.

## Individual Comments

### Comment 1
<location path="tasks/Component/Costume/costume_base.py" line_range="127-128" />
<code_context>
         logger.info(f'Switch battle theme {battle_type}')
         costume_battle_assets = CostumeBattleAssets()
         for key, value in battle_theme_model[battle_type].items():
+            if not hasattr(costume_battle_assets, value):
+                # 尚未采集完成的资产,跳过
+                continue
             assert_value: RuleImage = getattr(costume_battle_assets, value)
</code_context>
<issue_to_address>
**issue (bug_risk):** Silently skipping missing assets via hasattr can hide configuration or naming errors.

This guard makes incomplete asset collections safer, but it also hides genuine mistakes in `CostumeBattleAssets` (e.g., typos like a misnamed `I_WIN_13`), causing unexpected behavior with no logs or exceptions.

Consider differentiating optional vs required assets: keep `hasattr` + `continue` for optional ones, but for required keys either assert their presence or at least log a warning when `hasattr` is False. This preserves flexibility while surfacing real configuration errors.
</issue_to_address>

Sourcery 对开源项目免费使用 - 如果你觉得我们的评审有帮助,欢迎分享 ✨
帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈改进代码评审。
Original comment in English

Hey - I've found 1 issue, and left some high level feedback:

  • The new battle_theme_model dict comprehension is tightly coupled to the numeric range range(1, 15) and COSTUME_BATTLE_{i} naming; consider iterating over BattleType members themselves (or a dedicated list) instead of hardcoded indices to avoid future enum/name drift causing getattr failures.
  • In battle_theme_model, mapping to attribute names as strings and resolving them with getattr in check_costume_battle adds a layer of indirection; if possible, consider storing the actual RuleImage attributes or a small data structure describing ROIs directly to reduce the risk of typos and runtime errors.
  • The hasattr(costume_battle_assets, value) guard in check_costume_battle silently skips missing assets; if certain assets are expected to be present for some battles, you might want to distinguish between optional and required keys (e.g., by splitting the model or adding an explicit flag) so that missing required assets don’t fail quietly.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new `battle_theme_model` dict comprehension is tightly coupled to the numeric range `range(1, 15)` and `COSTUME_BATTLE_{i}` naming; consider iterating over `BattleType` members themselves (or a dedicated list) instead of hardcoded indices to avoid future enum/name drift causing `getattr` failures.
- In `battle_theme_model`, mapping to attribute names as strings and resolving them with `getattr` in `check_costume_battle` adds a layer of indirection; if possible, consider storing the actual `RuleImage` attributes or a small data structure describing ROIs directly to reduce the risk of typos and runtime errors.
- The `hasattr(costume_battle_assets, value)` guard in `check_costume_battle` silently skips missing assets; if certain assets are expected to be present for some battles, you might want to distinguish between optional and required keys (e.g., by splitting the model or adding an explicit flag) so that missing required assets don’t fail quietly.

## Individual Comments

### Comment 1
<location path="tasks/Component/Costume/costume_base.py" line_range="127-128" />
<code_context>
         logger.info(f'Switch battle theme {battle_type}')
         costume_battle_assets = CostumeBattleAssets()
         for key, value in battle_theme_model[battle_type].items():
+            if not hasattr(costume_battle_assets, value):
+                # 尚未采集完成的资产,跳过
+                continue
             assert_value: RuleImage = getattr(costume_battle_assets, value)
</code_context>
<issue_to_address>
**issue (bug_risk):** Silently skipping missing assets via hasattr can hide configuration or naming errors.

This guard makes incomplete asset collections safer, but it also hides genuine mistakes in `CostumeBattleAssets` (e.g., typos like a misnamed `I_WIN_13`), causing unexpected behavior with no logs or exceptions.

Consider differentiating optional vs required assets: keep `hasattr` + `continue` for optional ones, but for required keys either assert their presence or at least log a warning when `hasattr` is False. This preserves flexibility while surfacing real configuration errors.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +127 to +128
if not hasattr(costume_battle_assets, value):
# 尚未采集完成的资产,跳过
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): 通过 hasattr 静默跳过缺失资源,可能会隐藏配置或命名错误。

这个保护逻辑可以让不完整的资源集合更安全,但同时也会掩盖 CostumeBattleAssets 中的真实错误(例如像误写为 I_WIN_13 这样的拼写问题),从而在没有日志或异常的情况下导致意外行为。

建议区分可选资源和必需资源:对可选项保持 hasattr + continue 的逻辑,而对于必需键,要么显式断言其存在,要么在 hasattr 为 False 时至少记录一个警告日志。这样既保留了灵活性,又能暴露真实的配置错误。

Original comment in English

issue (bug_risk): Silently skipping missing assets via hasattr can hide configuration or naming errors.

This guard makes incomplete asset collections safer, but it also hides genuine mistakes in CostumeBattleAssets (e.g., typos like a misnamed I_WIN_13), causing unexpected behavior with no logs or exceptions.

Consider differentiating optional vs required assets: keep hasattr + continue for optional ones, but for required keys either assert their presence or at least log a warning when hasattr is False. This preserves flexibility while surfacing real configuration errors.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 8, 2026

Change Summary

  • 这次改动把战斗主题资源映射从仅覆盖部分主题,扩展为统一覆盖 costume_battle_1costume_battle_14
  • 除了新增 13、14 两套主题资源外,还为 1-14 全量补入了 I_BATTLE_INFO 识别图,并在切换战斗皮肤时一起替换。
  • 运行时对 I_WIN / I_DE_WIN / I_FALSE 改成可选覆盖,缺失资源时直接跳过,不再依赖 8、12 的显式特例。
  • 中文文案补齐了 costume_battle_12/13/14costume_main_13/14 的显示名称。

Reconstructed Intent

点击此处展开 - 这次改动最可能是为了把“战斗主题适配”从零散特例改成统一模型,降低后续继续加主题时的改动面。 - 更像是在尝试解决:不同战斗皮肤下,通用 `I_BATTLE_INFO` 识别不稳定,因此为每套战斗主题补专属战斗信息图,连同胜利/失败图一起按主题覆盖。 - 新增 13、14 主题本身是显式目标,但从代码行为看,作者同时想把现有 1-12 的战斗页识别链路也纳入同一套替换机制。

Observed Constraints

点击此处展开 - 这套实现依赖 `BattleType` 枚举名与 `COSTUME_BATTLE_{i}`、资源属性名 `I_*_{i}`、目录 `battle{i}` 三者严格同构;任何一处命名漂移都会在运行时失配。 - `check_costume_battle` 只会替换当前对象上已经存在的同名资产,因此它默认依赖消费方已经暴露 `I_BATTLE_INFO`、`I_WIN`、`I_FALSE` 等通用键。 - `I_WIN` / `I_DE_WIN` / `I_FALSE` 现在被视为“可缺省资源”,实现默认只有 8、12、13、14 真正采集完整,其余主题缺失时允许静默回退到原始通用资产。 - `I_LOCAL` 仍保留 `roi_back` 不替换的旧约束,说明作者认为绿标定位的后景范围必须继续沿用原链路。

Intent Alignment

  • 实现与推断 intent 基本一致:它确实把战斗主题切换扩展到了 13、14,并把战斗页识别资产统一纳入主题覆盖。
  • 但这次不只是“新增两套主题资源”,还把 1-14 全部主题的 I_BATTLE_INFO 行为一起改了,属于比标题更广的行为面扩张。
  • 对“资源未采集完整也能继续工作”的 intent 也做了覆盖,但通过静默跳过实现,留下了配置错误与资源缺失难区分的不确定性。

Release Risk

  • 风险等级:中
  • 最值得关注的是战斗页进入/识别链路被整体改动了:凡是启用战斗皮肤替换的任务,现在都会优先使用主题化 I_BATTLE_INFO,影响面大于 13、14 两个新主题本身。
  • 13、14 的胜利/失败资源首次接入后,会改变战斗结束判定前提;如果 ROI 或素材采样偏差较大,容易表现为结算页卡住、误判未结束或误判失败。
  • 资源缺失被静默跳过后,运行时会混用“主题化资产 + 通用资产”,这能提高兼容性,但也让异常更难在发布前暴露。

Validation Gaps

点击此处展开 - 未看到针对 1-14 各主题的战斗页识别回归验证,尤其是 `I_BATTLE_INFO` 替换后是否仍能稳定驱动 `GeneralBattle` 的进出战判断。 - 未看到 13、14 主题下胜利、失败、封魔特殊结算三条分支的链路验证。 - 未看到“资源缺失时应回退哪些键、哪些键必须命中”的显式验证,因此当前行为更像容错策略,而不是被验证过的约束。

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • api.github.com
  • github.com

💡 Tip: api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:

tools:
  github:
    mode: gh-proxy

See GitHub Tools for more information on gh-proxy mode.

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.github.com"
    - "github.com"

See Network Configuration for more information.

Generated by PR Review Intent for issue #1619 · gpt54 1.2M ·

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 8, 2026

Findings

  • C3 [风险]
    位置:tasks/Component/Costume/costume_base.pycheck_costume_battle
    原因:这里对 CostumeBattleAssets 缺失属性直接 continue,会把素材漏采集和属性名写错都静默吞掉,战斗主题切换失败时没有任何告警。
    修改:把 I_WINI_DE_WINI_FALSE 这类可选资源与 I_LOCALI_EXITI_FRIENDSI_BATTLE_INFO 这类必需资源分开处理,至少对必需资源缺失记录 warning 或直接失败。

Warning

Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • api.github.com
  • github.com

💡 Tip: api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:

tools:
  github:
    mode: gh-proxy

See GitHub Tools for more information on gh-proxy mode.

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.github.com"
    - "github.com"

See Network Configuration for more information.

Generated by PR Review Checklist for issue #1619 · gpt54 3.6M ·

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