Skip to content
This repository was archived by the owner on Sep 20, 2026. It is now read-only.

fix(tooltips): handle unreferenced aura upgrade values - #218

Merged
cauyxy merged 1 commit into
masterfrom
codex/fix-guzheng-upgrade-preview
Aug 6, 2026
Merged

cauyxy merged 1 commit into
masterfrom
codex/fix-guzheng-upgrade-preview

Conversation

@pengx17

@pengx17 pengx17 commented Aug 6, 2026

Copy link
Copy Markdown
Member

Context

古筝从金色升级到钻石时,Shift 升级预览仍显示“每层 Tempo 造成 15 伤害并获得 15 护盾”,没有展示应有的 15 → 30

根因是这两个值来自 {aura.*.mod}:Aura 外层引用玩家 Tempo,倍率内层才引用物品的 Custom_0。游戏原生 RenderTooltip 对这类 ReferencedAttribute == null、但带属性样式的 token 调用格式化函数时,没有传入 tooltip component,导致现有升级投影补丁缺少重算上下文。

协作过程

sequenceDiagram
    participant U as 用户
    participant C as Codex
    participant G as 游戏原生 Tooltip
    participant P as 升级投影
    U->>C: 提供古筝升级预览无数值变化的截图
    C->>G: 对照实时模板数据与反编译渲染路径
    Note over C,G: 确认金色 Custom_0=15、钻石 Custom_0=30,且原生无 ReferencedAttribute 分支漏传 component
    C->>P: 复刻古筝的玩家属性 × 物品属性倍率结构
    P-->>C: 投影可正确计算 15 → 30
    C->>G: 在同步渲染作用域内交接 Aura token 上下文
    C-->>U: 完成修复并加入回归测试
Loading

方案讨论

考虑过修改投影算法和直接改写原生 RenderTooltip。投影算法本身在获得 Aura token 后能够正确计算 30,因此没有扩大其职责;直接 transpile 原生方法则依赖 IL 结构,游戏更新后更脆弱。

最终采用范围受限的上下文交接:仅在 CardTooltipData.RenderTooltip 同步调用期间捕获 ReferencedAttribute == null 的可着色 Aura token,并在原生省略 component 的格式化调用中消费。线程本地状态在渲染结束时清理,避免跨 tooltip 泄漏。

最终方案

  • 为 tooltip 渲染增加线程本地作用域。
  • 在 Aura Resolve() 后捕获原生遗漏的 component 上下文。
  • 现有升级值后处理优先使用原生 component;为空时消费本次渲染捕获的 Aura token。
  • 新增古筝形态的回归用例,验证无 ReferencedAttribute.mod token 从 15 投影为 30。

验证情况

  • dotnet run --project tests/UpgradePreviewTooltip.Tests/UpgradePreviewTooltip.Tests.csproj -p:ManagedPath=".../Managed"
  • dotnet build src/BazaarPlusPlus/BazaarPlusPlus.csproj -c Release --no-restore -p:ManagedPath=".../Managed" -p:BPPInstallerSourcePath=".../resources" -p:BuildProductionPackage=false(0 warnings / 0 errors)
  • ./run.sh format-check
  • git diff --check

已知局限 / 后续工作

  • 尚未在游戏内手动复现古筝悬浮提示;本 PR 通过实时模板结构对应的专项测试覆盖数值链路。
  • 此 PR 仅修复升级提示上下文缺失,不处理此前观察到的偶发商店刷新卡顿。

@pengx17
pengx17 marked this pull request as ready for review August 6, 2026 04:06
Copilot AI lite review requested due to automatic review settings August 6, 2026 04:06

Copilot AI 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.

Pull request overview

This PR fixes upgrade-preview tooltip value fusion for certain Aura .mod tokens where the game’s native tooltip rendering path omits the ITooltipComponent argument when ReferencedAttribute == null, preventing BazaarPlusPlus’s upgrade value projection from recomputing the upgraded value (e.g., Guzheng 15 → 30).

Changes:

  • Add a thread-local render scope around CardTooltipData.RenderTooltip and capture “unreferenced but styled” Aura components immediately after TooltipComponentAura.Resolve().
  • Extend UpgradePreviewValueRegistry to provide a per-render fallback ITooltipComponent when the native formatter passes null.
  • Add a Guzheng-shaped regression scenario to the upgrade preview tooltip tests.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/UpgradePreviewTooltip.Tests/Program.cs Adds a regression scenario modeling Guzheng’s player-attribute × card-attribute multiplier structure.
src/BazaarPlusPlus/Patches/Tooltips/UpgradePreviewValuePatch.cs Introduces Harmony patches to establish a render scope and capture Aura components for fallback projection.
src/BazaarPlusPlus/Game/Tooltips/UpgradePreviewValueRegistry.cs Implements thread-local render depth + fallback component storage/consumption to recover missing projection context.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +192 to +201
AssertTrue(
guzhengProjection.TryResolve(guzhengToken, out var upgradedGuzhengMultiplier),
"Projected Guzheng aura token should resolve."
);
AssertFloatEqual(
30f,
upgradedGuzhengMultiplier,
"Guzheng Damage and Shield per Tempo should upgrade from 15 to 30."
);

@cauyxy
cauyxy merged commit 8bdd557 into master Aug 6, 2026
1 check passed
@cauyxy
cauyxy deleted the codex/fix-guzheng-upgrade-preview branch August 6, 2026 11:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants