From cb2febec90e73c81b03d5fd6d4a2d8a05e9a7808 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 17 Sep 2026 05:05:09 +0200 Subject: [PATCH] Fix F3: two tiers and a no-reroll check in StatsReadTheLot A single-tier fixture cannot fail "GetTier ignores lot quality": every lot resolves to the only tier regardless of its own Quality. Added a second tier (Rare, threshold .5) and a second lot whose quality (.6) lands in it, and asserted GetTier resolves each lot to its own tier. Also asserts that minting a second instance from an existing lot does not re-roll the lot's quality. Verified by mutation, then reverted: GetTier hardcoded to a fixed quality, and CreateInstance(int) re-rolling the lot's quality, both fail this test. 36 of 36 tests pass on the real fix. Co-Authored-By: Claude Opus 5 --- tests/Aetheria.Shared.Tests/LoadoutTests.cs | 26 ++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/LoadoutTests.cs b/tests/Aetheria.Shared.Tests/LoadoutTests.cs index 69258453b..b684d2552 100644 --- a/tests/Aetheria.Shared.Tests/LoadoutTests.cs +++ b/tests/Aetheria.Shared.Tests/LoadoutTests.cs @@ -469,23 +469,43 @@ public sealed class LoadoutTests : IDisposable { using var cache = Open(); var settings = RunSaveTests.TestSettings(); - settings.Tiers = new[] { new RarityTier { Name = "Common", Quality = .2f, Rarity = 0, Color = new float3(1, 1, 1) } }; + // Two tiers with distinct quality thresholds: a single-tier fixture cannot fail "GetTier ignores lot + // quality", since every lot would resolve to the only tier regardless of its own Quality. + settings.Tiers = new[] + { + new RarityTier { Name = "Common", Quality = .2f, Rarity = 0, Color = new float3(1, 1, 1) }, + new RarityTier { Name = "Rare", Quality = .5f, Rarity = 1, Color = new float3(1, 1, 1) } + }; var items = new ItemManager(cache, new ProvenanceLedger(), settings, _ => { }); var lamp = cache.GetByName("Lamp"); - var lotId = items.Lots.Add(new Lot + var commonLot = items.Lots.Add(new Lot { Design = cache.RefOf(lamp), Origin = new Attributed(), Quality = .2f, Roles = new List { new RoleFill { Role = "lens", Quality = .9f } } }); - var instance = (EquippableItem) items.CreateInstance(lotId); + var rareLot = items.Lots.Add(new Lot + { + Design = cache.RefOf(lamp), + Origin = new Attributed(), + Quality = .6f, + Roles = new List() + }); + var instance = (EquippableItem) items.CreateInstance(commonLot); + var rareInstance = (EquippableItem) items.CreateInstance(rareLot); var withRole = new PerformanceStat { FromRole = "lens", Min = 0, Max = 1, QualityExponent = 1 }; var noRole = new PerformanceStat { Min = 0, Max = 1, QualityExponent = 1 }; Assert.Equal(.9f, items.Evaluate(withRole, instance), 3); Assert.Equal(.2f, items.Evaluate(noRole, instance), 3); Assert.Equal(.2f, items.GetTier(instance).tier.Quality, 3); + Assert.Equal(.5f, items.GetTier(rareInstance).tier.Quality, 3); + + // Minting a second instance from an existing lot must not re-roll the lot's quality. + var secondInstance = (EquippableItem) items.CreateInstance(commonLot); + Assert.Equal(.2f, items.Lots[commonLot].Quality, 3); + Assert.Equal(.2f, items.GetTier(secondInstance).tier.Quality, 3); } [Fact]