From 32b14b966b0d0fc3cdcbfdc14078551d5db8683e Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Thu, 8 Oct 2026 16:12:48 +0200 Subject: [PATCH] Pin ManufacturerPreference: neutral without galaxy or faction, zero outside allegiance, table-bound distance Kills the five Stryker survivors of the first pass on LoadoutGenerator.cs availability and preference. Tests only; builds against the prior commit. Co-Authored-By: Claude Sonnet 5.5 --- .../RunStartGearTests.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/tests/Aetheria.Shared.Tests/RunStartGearTests.cs b/tests/Aetheria.Shared.Tests/RunStartGearTests.cs index 800081852..3b5766dcd 100644 --- a/tests/Aetheria.Shared.Tests/RunStartGearTests.cs +++ b/tests/Aetheria.Shared.Tests/RunStartGearTests.cs @@ -89,4 +89,46 @@ public sealed partial class RunStartTests Assert.NotEmpty(present); Assert.All(present, product => Assert.False(generator.IsAvailable(product), product.Name)); } + + // Preference only weighs by distance when there is a galaxy and a faction to weigh for. + [Fact] + public void PreferenceIsNeutralWithoutAGalaxyOrAFaction() + { + var galaxy = MainSectorGalaxy(); + var (product, absent) = AbsentMaker("AbsentNeutral"); + var faction = galaxy.Factions.First(); + var noGalaxy = new LoadoutGenerator(ref _items.Random, _items, null, null, faction, .5f); + var noFaction = new LoadoutGenerator(ref _items.Random, _items, galaxy, galaxy.Entrance, null, .5f); + Assert.Equal(1f, noGalaxy.ManufacturerPreference(product.Manufacturer)); + Assert.Equal(1f, noFaction.ManufacturerPreference(product.Manufacturer)); + } + + // A maker the generator's faction does not name weighs nothing, present or not. + [Fact] + public void AMakerOutsideAllegianceWeighsNothing() + { + var galaxy = MainSectorGalaxy(); + var (product, _) = AbsentMaker("AbsentUnnamed"); + var generator = GeneratorFor(galaxy, "Hermit"); + var stranger = galaxy.Factions.First(); + Assert.Equal(0f, generator.ManufacturerPreference(product.Manufacturer)); + Assert.Equal(0f, generator.ManufacturerPreference(_cache.RefOf(stranger))); + } + + // The distance table decides: a present maker whose home the table does not reach adds no distance, an absent + // maker is one jump past the table's farthest zone, and an empty table adds none either way. + [Fact] + public void ADistanceTableOnlyDistancesTheMakersItNames() + { + var galaxy = MainSectorGalaxy(); + var (product, absent) = AbsentMaker("AbsentOffTable"); + var present = galaxy.Factions.First(f => galaxy.HomeZones.TryGetValue(f, out var home) && home != galaxy.Entrance); + var friend = GeneratorFor(galaxy, "Ally", absent, present); + var table = new GalaxyZone { Distance = new Dictionary { { galaxy.Entrance, 0 } } }; + var generator = new LoadoutGenerator(ref _items.Random, _items, galaxy, table, friend.Faction, .5f); + Assert.Equal(1f, generator.ManufacturerPreference(_cache.RefOf(present))); // home not in the table: distance 0 + Assert.Equal(.5f, generator.ManufacturerPreference(product.Manufacturer)); // absent: 0 + 1 + var empty = new LoadoutGenerator(ref _items.Random, _items, galaxy, new GalaxyZone { Distance = new Dictionary() }, friend.Faction, .5f); + Assert.Equal(1f, empty.ManufacturerPreference(product.Manufacturer)); + } }