The narrow re-review of fix commits 0c8e1e7d+2d4168f9 found every code fix
oracle-verified but returned NOT CLOSED on five test/doc residuals plus
three nits and a follow-up filing. All fixed:
- R1: the claimed "external-change->user-commit->SetName" regression test
for F1 (the deleted _suppressNextFieldEvent latch) never existed — the
Runtime-layer randomize test doesn't touch the page. Added
CharacterCreationUiControllerTests.SummaryNameField_RealCommitAfter
ExternalRefreshWhileUnfocused_StillReachesSetName: drives Refresh with a
revision bump + changed snapshot.Name while the field is unfocused (the
programmatic SetText path that used to arm the latch), THEN performs a
real user commit (field.SetText + field.Submit(), the actual event path),
asserting SetName receives the player's typed text.
- R2: RetailSkillFormula.CalculateChargenScore and ChargenSkillScoreResolver
had zero direct coverage (the F12(d) test substitutes skillId*10). Added
a Untrained/Trained(+5)/Specialized(+10) theory, the divisor-zero skip
path, and a six-way AttributeId theory (Str=1..Self=6) to
RetailSkillFormulaTests.cs.
- R3: RetailSkillFormula.cs's doc comment claimed "no retail-authored skill
sets MinLevel above Untrained=1" without ever reading the field — ACE's
own SkillBase.cs hedges the same field "// 1-2?". MEASURED (not assumed)
against the installed EoR dat's global SkillTable
(CharacterCreationLiveDatTests.SkillTable_MinLevelDistribution_
NeverExceedsTrained): 23 skills at MinLevel 1, 15 at MinLevel 2, zero
above 2, of 38 priced skills. ACE's hedge was right; the doc comment now
states the measured fact and leans on the structural argument (the gate
holds for Trained/Specialized under any MinLevel in {1,2}) as load-
bearing, not the unverified data claim.
- R4: filed AP-228 — the Summary/Skills skill-row KEY sources from
ItemAppraisalTextFormatter.SkillName's hardcoded English switch, where
retail's own key is DAT-sourced (SkillBase->_name via %hs,
0x0047b90f-0x0047b915) — same divergence class as AP-226 filed the same
round, reversed polarity, also present at CC4's Skills page. Softened
AP-224's "ported exactly, not simplified" claim: it only ever covered the
row's VALUE/template, never its KEY.
- R5: this commit corrects 0c8e1e7d's gate claim. "Release build zero
warnings" was false: a clean `dotnet build -c Release -t:Rebuild` shows
25 pre-existing warnings (18 in tests/AcDream.Core.Tests, 7 in
tests/AcDream.App.Tests — Composition/HostInputCameraCompositionTests.cs,
Composition/WorldRenderCompositionTests.cs,
UI/Layout/OptionsPanelLiveMountProbeTests.cs), none in any file this
campaign or its residual round touched. History is not amended; this is
the correction.
Nits: the ChargenPreviewController ctor doc now also cites
gmCGSummaryPage::Update @0x0047baa0 (the per-heritage re-derive site — 0xc
Olthoi/0xd OlthoiAcid/else — not just the one-shot InitializePage seed) as
the stronger justification for why Rebuild re-derives the zoomed-out eye
per heritage on every change. RuntimeCharacterCreationState's F2 comment
("Finish becoming a permanent no-op") reworded: the same unconditional
_verificationPending = false assignment ran pre-fix too, so Finish was
never blocked — only the response FEEDBACK vanished (no dialog, no created
character, nothing), not the request itself. Filed #404 for
ChargenSkillScoreResolver's own independent SkillTable read alongside
ChargenTableReader's (cleanup follow-up, out of this round's scope).
Ledger: CC5 flipped REVIEW-CLOSED in the campaign plan (dual-lens
architectural PASS-with-items / retail-fidelity FAIL -> F1-F14 fix round
0c8e1e7d -> narrow re-review: all code oracle-verified, residuals R1-R5
test/doc -> this commit; re-reviewer pre-authorized lead diff-check close).
This commit's own sha is recorded by a follow-up ledger-only commit,
matching 2d4168f9's own pattern.
Gates: Release build 0 errors (25 pre-existing warnings, unrelated to this
round — see R5 above); App suite 5257/3 skips (was 5242/3), 0 failed;
Runtime suite 1726/0 (unchanged); the three new/measured tests (R1, R2's
ten cases, R3) all pass individually.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
213 lines
7.9 KiB
C#
213 lines
7.9 KiB
C#
using AcDream.App.Net;
|
|
using AcDream.Core.CharGen;
|
|
using DatReaderWriter.DBObjs;
|
|
using DatReaderWriter.Enums;
|
|
using DatReaderWriter.Types;
|
|
|
|
namespace AcDream.App.Tests.Net;
|
|
|
|
public sealed class RetailSkillFormulaTests
|
|
{
|
|
[Fact]
|
|
public void ZeroDivisorIsTheOnlyFormulaFailureGate()
|
|
{
|
|
SkillFormula invalid = Formula(w: 7, x: 1, y: 1, z: 0);
|
|
Assert.False(RetailSkillFormula.TryCalculate(invalid, 10u, 20u, out uint invalidResult));
|
|
Assert.Equal(0u, invalidResult);
|
|
|
|
SkillFormula zeroX = Formula(w: 7, x: 0, y: 2, z: 3);
|
|
Assert.True(RetailSkillFormula.TryCalculate(zeroX, 10u, 4u, out uint validResult));
|
|
Assert.Equal(5u, validResult);
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(9u, 4u, 2u)]
|
|
[InlineData(10u, 4u, 3u)]
|
|
[InlineData(11u, 4u, 3u)]
|
|
[InlineData(12u, 4u, 3u)]
|
|
public void DivisionRoundsToNearestWithExactHalvesUp(
|
|
uint numerator,
|
|
uint divisor,
|
|
uint expected)
|
|
{
|
|
SkillFormula formula = Formula(w: 0, x: 1, y: 0, z: divisor);
|
|
|
|
Assert.True(RetailSkillFormula.TryCalculate(
|
|
formula,
|
|
numerator,
|
|
0u,
|
|
out uint result));
|
|
Assert.Equal(expected, result);
|
|
}
|
|
|
|
[Fact]
|
|
public void AdditiveWordIsInsideTheNumerator()
|
|
{
|
|
SkillFormula formula = Formula(w: 3, x: 1, y: 1, z: 4);
|
|
|
|
Assert.True(RetailSkillFormula.TryCalculate(formula, 4u, 2u, out uint result));
|
|
|
|
Assert.Equal(2u, result);
|
|
}
|
|
|
|
[Fact]
|
|
public void NumeratorUsesUnsignedThirtyTwoBitWrap()
|
|
{
|
|
SkillFormula formula = Formula(w: 1, x: 2, y: 0, z: 2);
|
|
|
|
Assert.True(RetailSkillFormula.TryCalculate(
|
|
formula,
|
|
uint.MaxValue,
|
|
0u,
|
|
out uint result));
|
|
|
|
Assert.Equal(0x80000000u, result);
|
|
}
|
|
|
|
[Fact]
|
|
public void SignedDatStorageIsReinterpretedAsRetailUnsignedWords()
|
|
{
|
|
SkillFormula formula = Formula(w: -1, x: 0, y: 0, z: 1);
|
|
|
|
Assert.True(RetailSkillFormula.TryCalculate(formula, 0u, 0u, out uint result));
|
|
|
|
Assert.Equal(uint.MaxValue, result);
|
|
}
|
|
|
|
[Fact]
|
|
public void LiveResolverLooksUpTheDatFormulaAndTreatsMissingAttributesAsZero()
|
|
{
|
|
const uint skillId = 0x345u;
|
|
const uint firstAttributeId = 1u;
|
|
const uint secondAttributeId = 2u;
|
|
var skillTable = new SkillTable();
|
|
skillTable.Skills.Add((SkillId)skillId, new SkillBase
|
|
{
|
|
Formula = new SkillFormula
|
|
{
|
|
AdditiveBonus = 1,
|
|
Attribute1Multiplier = 1,
|
|
Attribute2Multiplier = 2,
|
|
Divisor = 3,
|
|
Attribute1 = (AttributeId)firstAttributeId,
|
|
Attribute2 = (AttributeId)secondAttributeId,
|
|
},
|
|
});
|
|
var resolver = new LiveSkillCreditResolver(skillTable);
|
|
|
|
uint result = resolver.Resolve(
|
|
skillId,
|
|
new Dictionary<uint, uint> { [firstAttributeId] = 8u });
|
|
|
|
Assert.Equal(3u, result);
|
|
Assert.Equal(0u, resolver.Resolve(0x999u, new Dictionary<uint, uint>()));
|
|
}
|
|
|
|
private static SkillFormula Formula(int w, int x, int y, uint z) => new()
|
|
{
|
|
AdditiveBonus = w,
|
|
Attribute1Multiplier = x,
|
|
Attribute2Multiplier = y,
|
|
Divisor = unchecked((int)z),
|
|
};
|
|
|
|
// ── CC5 re-review residual round, R2 (2026-08-16): RetailSkillFormula.
|
|
// ── CalculateChargenScore / ChargenSkillScoreResolver had zero direct
|
|
// ── coverage — the F12(d) test substitutes `skillId * 10` instead of
|
|
// ── exercising the real formula. ─────────────────────────────────────
|
|
|
|
/// <summary>
|
|
/// <see cref="RetailSkillFormula.CalculateChargenScore"/>'s level bonus:
|
|
/// Untrained adds nothing, Trained adds 5, Specialized adds 10, on top
|
|
/// of the SAME base <see cref="RetailSkillFormula.TryCalculate"/> result
|
|
/// (formula here: <c>w=0, x=1, y=0, z=1</c> against
|
|
/// <c>attribute1=5</c> -> base 5).
|
|
/// </summary>
|
|
[Theory]
|
|
[InlineData(ChargenSkillAdvancementClass.Untrained, 5u)]
|
|
[InlineData(ChargenSkillAdvancementClass.Trained, 10u)]
|
|
[InlineData(ChargenSkillAdvancementClass.Specialized, 15u)]
|
|
public void CalculateChargenScore_AddsTheLevelBonusOnTopOfTheBaseFormula(
|
|
ChargenSkillAdvancementClass level,
|
|
uint expected)
|
|
{
|
|
var skillBase = new SkillBase { Formula = Formula(w: 0, x: 1, y: 0, z: 1) };
|
|
|
|
uint result = RetailSkillFormula.CalculateChargenScore(skillBase, attribute1: 5u, attribute2: 0u, level);
|
|
|
|
Assert.Equal(expected, result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The divisor-zero skip path: <see cref="RetailSkillFormula.TryCalculate"/>'s
|
|
/// own failure gate short-circuits <see cref="RetailSkillFormula.CalculateChargenScore"/>
|
|
/// to a flat 0 BEFORE the level bonus is ever added — even for
|
|
/// Specialized, which would otherwise add 10.
|
|
/// </summary>
|
|
[Fact]
|
|
public void CalculateChargenScore_ZeroDivisor_ReturnsZero_RegardlessOfLevel()
|
|
{
|
|
var skillBase = new SkillBase { Formula = Formula(w: 7, x: 1, y: 1, z: 0) };
|
|
|
|
Assert.Equal(0u, RetailSkillFormula.CalculateChargenScore(
|
|
skillBase, 10u, 20u, ChargenSkillAdvancementClass.Untrained));
|
|
Assert.Equal(0u, RetailSkillFormula.CalculateChargenScore(
|
|
skillBase, 10u, 20u, ChargenSkillAdvancementClass.Trained));
|
|
Assert.Equal(0u, RetailSkillFormula.CalculateChargenScore(
|
|
skillBase, 10u, 20u, ChargenSkillAdvancementClass.Specialized));
|
|
}
|
|
|
|
/// <summary>
|
|
/// <see cref="ChargenSkillScoreResolver.Resolve"/>'s six-way
|
|
/// <c>ResolveAttribute</c> switch — one case per
|
|
/// <see cref="AttributeId"/> (Strength=1..Self=6) — resolving through a
|
|
/// formula that reads ONLY <c>Attribute1</c> (<c>x=1, y=0</c>) so the
|
|
/// result unambiguously reports which of the six
|
|
/// <see cref="ChargenAttributeValues"/> fields the switch actually read.
|
|
/// </summary>
|
|
[Theory]
|
|
[InlineData(AttributeId.Strength)]
|
|
[InlineData(AttributeId.Endurance)]
|
|
[InlineData(AttributeId.Coordination)]
|
|
[InlineData(AttributeId.Quickness)]
|
|
[InlineData(AttributeId.Focus)]
|
|
[InlineData(AttributeId.Self)]
|
|
public void ChargenSkillScoreResolver_ResolvesEachAttributeIdThroughTheSixWaySwitch(
|
|
AttributeId attributeId)
|
|
{
|
|
const uint skillId = 0x10u;
|
|
var skillTable = new SkillTable();
|
|
skillTable.Skills.Add((SkillId)skillId, new SkillBase
|
|
{
|
|
Formula = new SkillFormula
|
|
{
|
|
AdditiveBonus = 0,
|
|
Attribute1Multiplier = 1,
|
|
Attribute2Multiplier = 0,
|
|
Divisor = 1,
|
|
Attribute1 = attributeId,
|
|
// Attribute2 deliberately left at its zero default (Strength) —
|
|
// Attribute2Multiplier=0 means whatever it reads contributes
|
|
// nothing, so it cannot mask a wrong Attribute1 case.
|
|
},
|
|
});
|
|
var resolver = new ChargenSkillScoreResolver(skillTable);
|
|
ChargenAttributeValues attributes = AttributeValuesWith(attributeId, 42);
|
|
|
|
uint result = resolver.Resolve(skillId, attributes, ChargenSkillAdvancementClass.Untrained);
|
|
|
|
Assert.Equal(42u, result);
|
|
}
|
|
|
|
private static ChargenAttributeValues AttributeValuesWith(AttributeId attributeId, int value) =>
|
|
attributeId switch
|
|
{
|
|
AttributeId.Strength => new ChargenAttributeValues(value, 0, 0, 0, 0, 0),
|
|
AttributeId.Endurance => new ChargenAttributeValues(0, value, 0, 0, 0, 0),
|
|
AttributeId.Coordination => new ChargenAttributeValues(0, 0, value, 0, 0, 0),
|
|
AttributeId.Quickness => new ChargenAttributeValues(0, 0, 0, value, 0, 0),
|
|
AttributeId.Focus => new ChargenAttributeValues(0, 0, 0, 0, value, 0),
|
|
AttributeId.Self => new ChargenAttributeValues(0, 0, 0, 0, 0, value),
|
|
_ => default,
|
|
};
|
|
}
|