This repository was archived by the owner on Sep 20, 2026. It is now read-only.
fix(event-preview): resolve dynamic reward totals - #195
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves event and level-up reward preview text by resolving previously-unfilled dynamic {ability.*} / {aura.*} placeholders at presentation time using the game’s native ITValue.GetValue(ValueContext) evaluation, rather than relying solely on static-cache substitution.
Changes:
- Add a live placeholder-resolution path (
LiveAbilityValueResolver) and thread it through event preview, choice pools, and level-up reward candidate formatting. - Implement live ability/aura evaluation in the runtime via
ValueContext(run)+CardAbilityValueReader.TryEvaluate*. - Add/extend tests covering missing static totals (PvP loss aggregation, hand+stash counts, nested aggregates) and level-up tooltip rendering.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/CollectionEncounterTooltip.Tests/EventPreviewLocalizationTests.cs | Adds a focused test proving live fallback fills a missing {ability.0} total. |
| tests/CollectionEncounterTooltip.Tests/EncounterPreviewModuleTests.cs | Extends module-level snapshot test coverage to include live-resolved totals in compiled preview output. |
| tests/CollectionEncounterTooltip.Tests/CollectionLevelUpTooltipTextTests.cs | Adds a level-up tooltip test ensuring dynamic totals are resolved via the live resolver. |
| tests/CollectionEncounterTooltip.Tests/CollectionEncounterTooltip.Tests.csproj | Adds BazaarGameClient reference required for new runtime model-based tests. |
| tests/CollectionEncounterTooltip.Tests/CardAbilityValueReaderTests.cs | Introduces unit tests validating native live evaluation for player attrs, card counts, and nested aggregates. |
| src/BazaarPlusPlus/GameInterop/Cards/CardAbilityValueReader.cs | Adds TryEvaluate* that evaluates ITValue against a ValueContext for dynamic totals. |
| src/BazaarPlusPlus/Game/EventPreview/LevelUpPreviewTextFormatter.cs | Threads live resolver through reward selection and description formatting. |
| src/BazaarPlusPlus/Game/EventPreview/EventPreviewLocalization.cs | Adds LiveAbilityValueResolver plumbing to resolve missing cached ability/aura placeholders. |
| src/BazaarPlusPlus/Game/EventPreview/EncounterPreviewModule.cs | Wires live evaluation into both event and level-up preview request paths. |
| src/BazaarPlusPlus/Game/EventPreview/EncounterPreviewGameRuntime.cs | Implements live evaluation against the current Run using ValueContext. |
| src/BazaarPlusPlus/Game/EventPreview/EncounterEventDetailResolver.cs | Ensures live resolution is used across event description, choices, and pool summaries. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+89
to
+91
| valueText = value.ValueText; | ||
| unit = value.Unit; | ||
| return true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
事件和升级奖励的预览文案会在静态缓存阶段替换
{ability.*}/{aura.*}。固定值可以直接读取,但依赖当前 run 的表达式无法在缓存构建时求值,因此会留下空占位,例如:[6]。对当前 GameData 的盘点发现 29 个静态阶段无法解析的占位符,其中 28 个是有效的动态值:18 个玩家属性引用,10 个卡牌计数引用;另 1 个
{aura.3}没有对应 aura,属于游戏数据中的无效引用,且不经过当前预览链路。改动重点
ITValue.GetValue(ValueContext)的实时求值。协作过程
sequenceDiagram participant U as 用户 participant C as 实现 participant G as GameData participant D as 反编译游戏代码 participant T as 测试 U->>C: PvP 败场恢复声望未显示合计 U->>C: 查找并覆盖同类文案 C->>G: 盘点未解析占位符 G-->>C: 18 个玩家属性 + 10 个卡牌计数 C->>D: 验证游戏原生求值路径 D-->>C: ITValue + ValueContext(run) C->>T: 验证原生表达式及两条预览链 T-->>C: 事件、升级与架构测试通过方案讨论
ADR-001:动态总量的求值位置
Context
静态预览缓存没有当前 run、玩家属性、手牌或仓库状态,因此不能得出动态合计。
Considered Options
ValueContext,直接执行模板中的ITValue表达式图。Decision
采用方案 3。静态值继续从缓存读取;只有静态阶段缺失的基础 ability / aura 值才进入实时求值。
Consequences
最终方案
flowchart LR A["事件 / 升级奖励文案"] --> B{"静态缓存有值?"} B -->|是| C["使用缓存值"] B -->|否| D["当前 Run 的 ValueContext"] D --> E["游戏原生 ITValue 表达式"] E --> F["格式化实时合计"] C --> G["渲染预览"] F --> G E -->|上下文不足| H["仅跳过该占位符"]验证情况
dotnet csharpier check .git diff --checkCollectionEncounterTooltip.Tests:168 passedArchitecture.Tests:129 passed已知局限 / 后续工作
{aura.3}不会被猜测或伪造。