fix(ui): #267 character panel reflects vitae/buffed skills and attributes
Retail CACQualities::EnchantAttribute (0x00594570), EnchantAttribute2nd (0x00594670, already ported for #6), and EnchantSkill (0x005947b0) are the three enchantment-composition functions the Character window's Attributes and Skills tabs depend on. Primary attributes never reference the vitae singleton in retail (only Attribute2nd/Skill do) — confirmed directly from the decompiled function bodies, not assumed. EnchantmentMath.GetMod gains requiredType/includeVitae parameters (default to the prior behavior) so a numeric StatMod key collision across domains (e.g. key=1 is both Strength and MaxHealth) can't leak a buff into the wrong computation. Spellbook.GetAttributeMod/GetSkillMod and LocalPlayerState.GetEffectiveAttribute/GetEffectiveSkill/ GetSkillVitaeModifier wire the retail chain through to the panel. CharacterSheetProvider now reports the effective value as the main number and CharacterSkill.CurrentLevel is no longer an alias of BaseLevel (this also activates the previously-dead SkillValueColor buffed/debuffed row coloring). CharacterStatController's footer-title parenthetical is cited from gmAttributeUI::DisplaySelectionFooter_Attribute (0x0049d280) and gmSkillUI::DisplaySelectionFooter_Trained (0x0049b860) + SkillInfoRegion::GetVitaeModifier (0x004f0fa0): skills show up to two segments (vitae's own contribution, then the buff-only residual), while vitae-immune attributes show at most one; no parenthetical when the delta is zero. The panel now refreshes on Spellbook.EnchantmentsChanged, not only raw property/attribute updates. Core goldens cover the user-reported 33% vitae example (303->203, "(-100)" exactly), buff+vitae composition, and the attribute vitae-immunity finding. Provider/controller tests cover the full row-click -> footer-title path and live refresh. Full solution suite passes with zero failures. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
f6275f4501
commit
cf2605fa4a
11 changed files with 1089 additions and 53 deletions
|
|
@ -181,6 +181,76 @@ public sealed class LocalPlayerState
|
|||
public AttributeSnapshot? GetAttribute(AttributeKind kind) =>
|
||||
_attrs.TryGetValue(kind, out var a) ? a : null;
|
||||
|
||||
/// <summary>The optional wired spellbook — read-only exposure of the same
|
||||
/// reference passed to the constructor. Issue #267: lets presentation
|
||||
/// code (e.g. <c>CharacterSheetProvider</c>) subscribe to
|
||||
/// <see cref="Spells.Spellbook.EnchantmentsChanged"/> for live character-sheet
|
||||
/// refresh without duplicating the reference in its own constructor.</summary>
|
||||
public Spellbook? Spellbook => _spellbook;
|
||||
|
||||
/// <summary>
|
||||
/// Issue #267 — effective (post-buff) primary-attribute value. Retail
|
||||
/// <c>CACQualities::EnchantAttribute</c> (0x00594570): primary attributes
|
||||
/// do NOT receive vitae (only <see cref="GetMaxApprox"/>'s secondary
|
||||
/// attributes and <see cref="GetEffectiveSkill"/>'s skills do). Returns
|
||||
/// the unenchanted base when no spellbook is wired (back-compat) or the
|
||||
/// attribute hasn't arrived yet.
|
||||
/// </summary>
|
||||
public int? GetEffectiveAttribute(AttributeKind kind)
|
||||
{
|
||||
AttributeSnapshot? attr = GetAttribute(kind);
|
||||
if (attr is null) return null;
|
||||
uint baseValue = attr.Value.Current;
|
||||
if (_spellbook is null) return (int)baseValue;
|
||||
EnchantmentMath.VitalMod mod = _spellbook.GetAttributeMod(AttributeKindToId(kind));
|
||||
return EnchantmentMath.EnchantAttribute(mod, baseValue);
|
||||
}
|
||||
|
||||
/// <summary>Reverse of <see cref="AttributeIdToKind"/> — the wire
|
||||
/// PropertyAttribute id (1..6) for a given <see cref="AttributeKind"/>.</summary>
|
||||
public static uint AttributeKindToId(AttributeKind kind) => kind switch
|
||||
{
|
||||
AttributeKind.Strength => 1u,
|
||||
AttributeKind.Endurance => 2u,
|
||||
AttributeKind.Quickness => 3u,
|
||||
AttributeKind.Coordination => 4u,
|
||||
AttributeKind.Focus => 5u,
|
||||
AttributeKind.Self => 6u,
|
||||
_ => 0u,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Issue #267 — effective (post-vitae, post-buff) skill level. Retail
|
||||
/// <c>CACQualities::EnchantSkill</c> (0x005947b0). Returns the
|
||||
/// unenchanted base when no spellbook is wired (back-compat) or the
|
||||
/// skill hasn't arrived yet.
|
||||
/// </summary>
|
||||
public int? GetEffectiveSkill(uint skillId)
|
||||
{
|
||||
SkillSnapshot? skill = GetSkill(skillId);
|
||||
if (skill is null) return null;
|
||||
uint baseValue = skill.Value.CurrentLevel;
|
||||
if (_spellbook is null) return (int)baseValue;
|
||||
EnchantmentMath.VitalMod mod = _spellbook.GetSkillMod(skillId);
|
||||
return EnchantmentMath.EnchantSkill(mod, baseValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Issue #267 — vitae's isolated contribution to a skill's effective
|
||||
/// level (retail <c>SkillInfoRegion::GetVitaeModifier</c> 0x004f0fa0),
|
||||
/// separate from any buff delta. Always ≤ 0. Returns 0 when no spellbook
|
||||
/// is wired, no vitae is active, or the skill hasn't arrived yet.
|
||||
/// </summary>
|
||||
public int GetSkillVitaeModifier(uint skillId)
|
||||
{
|
||||
if (_spellbook is null) return 0;
|
||||
SkillSnapshot? skill = GetSkill(skillId);
|
||||
if (skill is null) return 0;
|
||||
return EnchantmentMath.SkillVitaeModifier(
|
||||
_spellbook.ActiveEnchantments,
|
||||
skill.Value.CurrentLevel);
|
||||
}
|
||||
|
||||
/// <summary>Snapshot of the local player's current property bundle.</summary>
|
||||
public PropertyBundle Properties => _properties;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue