From 5177154c178c14f90a02baea76eda81c84514740 Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 23 Oct 2026 12:45:20 +0200 Subject: [PATCH 1/9] Economy batch 1: Zhestokost munitions chain (unapplied, for operator review) Dry run on the composed catalog: zero shape faults introduced; 49 records added, 4 changed. Review page published separately. Co-Authored-By: Claude Opus 5.5 --- tools/AetherDb/Economy/Munitions.cs | 227 ++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 tools/AetherDb/Economy/Munitions.cs diff --git a/tools/AetherDb/Economy/Munitions.cs b/tools/AetherDb/Economy/Munitions.cs new file mode 100644 index 000000000..9f0dfd075 --- /dev/null +++ b/tools/AetherDb/Economy/Munitions.cs @@ -0,0 +1,227 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using GameCult.Caching; + +// Economy content, batch 1: the munitions chain. Rounds (the Ammo commodity ballistic weapons draw), the energetics behind them, +// and the parts that fill the roles of ballistic guns, missile racks and the mine launcher: barrel, feed mechanism, warhead, +// thruster and dispenser. Zhestokost is the faction this chain is written around (its arsenal commissions plan foundry output, +// ammunition and transport together), so it is the faction that places the chain's station kinds until other factions' batches +// place them too. +// +// Goods owned by other chains are named here only as interface goods: written when no record holds the key yet, never +// overwritten, and given no recipe. Their own batch writes them unconditionally and owns their recipe, so the batch order +// does not decide their content. +public sealed class Munitions : EconomyBatch +{ + private EconomyAuthor _a; + + public override void Author(EconomyAuthor author) + { + _a = author; + + // The kind this chain adds. Energetics and loading are sited apart from other industry because a loading accident must not + // take a yard with it; that separation is the reason it is its own kind rather than a line in a fabrication station. + _a.Put(new StationKindData + { + Name = "Munitions Works", + Description = "Makes energetics (nitrocellulose, propellant, high explosive), loads rounds, primers, fuzes, warheads and rocket motors; sited apart from other industry so an accident takes only itself.", + StandIns = new List() + }, StationKindData.KeyOf("munitions-works")); + + // Zhestokost has no station model of any kind yet. Its first planned model is the supply depot (ruling faction-station-models), + // so its industrial kinds stand in on the depot until their own models land. One hop: depot itself has no Zhestokost stand-in. + var zhestokost = FactionRef("Zhestokost"); + foreach (var kind in new[] { "processing", "fabrication", "munitions-works" }) + StandIn(kind, zhestokost, "depot"); + + // Interface goods: named by this chain, owned by another. + var steel = Interface("steel", "Steel", "Rolled and drawn structural steel: bar, sheet and billet.", 1f, 30, simple: true); + var ammonia = Interface("ammonia", "Ammonia", "Ammonia ice and gas skimmed from cold bodies; the nitrogen in fertiliser and in every explosive.", 0.6f, 15, simple: true); + var oxygen = Interface("oxygen", "Oxygen", "Liquid oxygen, cracked from water ice or recovered from life support.", 1.1f, 8, simple: true); + var pulp = Interface("cellulose-pulp", "Cellulose Pulp", "Washed cellulose from algae and bacterial vats: the stock for paper, packaging, fibre and guncotton.", 0.8f, 20, simple: true); + var actuator = Interface("actuator", "Actuator", "A sealed motor and gear train that moves a load on command; the same unit opens a hatch, feeds a gun or folds laundry.", 2f, 400, simple: false); + var diamond = Existing("Diamond"); + var board = Existing("Circuit Board"); + var potassium = Existing("Potassium"); + var methane = Existing("Methane"); + var water = Existing("Water"); + + // Chemistry: processing stations, the same acid plants that feed agriculture. + var nitric = Simple("nitric-acid", "Nitric Acid", "Concentrated nitric acid from ammonia burned over a catalyst and absorbed in water.", 1.5f, 40); + Recipe(nitric, "processing", 300, 12, 2, + "The towers that burn ammonia into acid make fertiliser for the farms and nitrate for the arsenal. In Zhestokost the arsenal commission sets each season's split, so a hold of acid bound for a munitions works instead of an agriculture station tells you which plan won this year.", + new[] { "fertiliser" }, (ammonia, 1), (oxygen, 2), (water, 1)); + + var saltpetre = Simple("potassium-nitrate", "Potassium Nitrate", "Saltpetre: potassium neutralised with nitric acid and crystallised.", 2.1f, 60); + Recipe(saltpetre, "processing", 240, 8, 2, + "Saltpetre is fertiliser, curing salt for ration meat, and the oxidiser in powder and primers. A Zhestokost ration tin carries it twice: once in the meat and once in the gun that guards the convoy.", + new[] { "fertiliser", "preservative" }, (potassium, 1), (nitric, 1)); + + var hexamine = Simple("hexamine", "Hexamine", "White crystalline hexamine from ammonia and methane-derived formaldehyde.", 1.3f, 50); + Recipe(hexamine, "processing", 300, 10, 2, + "Pressed into tablets, hexamine heats a ration tin in a cold corridor; nitrated, it is the explosive in every warhead. A crate of it is either somebody's winter or somebody's siege.", + new[] { "solid fuel", "preservative" }, (ammonia, 2), (methane, 3)); + + // Energetics: the munitions works. + var guncotton = Simple("nitrocellulose", "Nitrocellulose", "Guncotton: cellulose nitrated in mixed acid, washed and kept damp.", 1.2f, 90); + Recipe(guncotton, "munitions-works", 600, 20, 2, + "Guncotton comes from the same cellulose vats as paper and packaging, and it also makes the lacquer for stencils and decals: a Zhestokost hull's cream serial numbers and the charge behind its guns came out of the same nitrator.", + new[] { "lacquer" }, (pulp, 2), (nitric, 2)); + + var powder = Existing("Ballistic Powder"); + _a.Edit("Ballistic Powder", p => + { + p.Description = "Single-base propellant: nitrocellulose grains with a saltpetre flash reducer. The charge in every ballistic round and the grain in every rocket motor."; + p.Price = 160; + }); + Recipe(powder, "munitions-works", 600, 24, 3, + "A ballistic gun fires on the energy this powder holds, not on its ship's reactor, so a heavy formation's reach is set by the powder in its tenders. Watch the powder trains and you know how long a siege is planned to last.", + new string[0], (guncotton, 3), (saltpetre, 1)); + + var fill = Simple("explosive-fill", "Explosive Fill", "Cast high explosive: hexamine nitrated to RDX and melt-cast with a binder.", 1.8f, 220); + Recipe(fill, "munitions-works", 900, 30, 2, + "Nothing peaceful is worth the risk of storing cast explosive, so a shipment of it in peacetime is news in itself: someone is filling warheads.", + new string[0], (hexamine, 1), (nitric, 3)); + + var primer = Compound("primer", "Primer", "Electric percussion primers in a steel cup, packed by the hundred.", 0.2f, 30); + Recipe(primer, "munitions-works", 300, 16, 10, + "Primers are small, sensitive and made in a hall of their own; a primer-line accident is how a new munitions works learns why its halls stand apart.", + new string[0], (saltpetre, 1), (steel, 1)); + + // Metal parts: fabrication and the state foundry. + var casing = Compound("shell-casing", "Shell Casing", "Deep-drawn steel cartridge cases, lacquered against corrosion.", 0.5f, 40); + Recipe(casing, "fabrication", 240, 12, 4, + "Zhestokost draws its cases from lacquered steel, not brass: brass is scarce and the arsenal plans for volume, not for reloading. A spent case in a wreck field tells you whose guns fired.", + new string[0], (steel, 1)); + + var slug = Compound("projectile", "Projectile", "Turned steel slugs with a driving band, sized by calibre.", 0.8f, 60); + Recipe(slug, "fabrication", 240, 12, 4, + "Each slug carries the tolerance stamp of the foundry that cast its bar, so a quartermaster can trace a bad lot back to a named shift.", + new string[0], (steel, 2)); + + var ammo = Existing("Ammo"); + _a.Edit("Ammo", a => a.Description = "Crated ballistic rounds: lacquered steel case, steel slug, propellant charge and primer. The round, not the reactor, carries the energy a ballistic gun fires."); + Recipe(ammo, "munitions-works", 600, 30, 2, + "A tender's hold of crated rounds is a battle's energy budget in transit. Zhestokost heavy formations fight as long as their tenders reach them, and cutting that line is how a faster enemy makes them go quiet.", + new string[0], (casing, 2), (slug, 2), (powder, 1), (primer, 2)); + + var forging = Compound("gun-forging", "Gun Forging", "Rotary-forged barrel blanks, stamped with the pour number.", 40f, 900); + Recipe(forging, "processing", 1800, 40, 1, + "Barrel blanks come from the same state foundries that pour hull plate. A foundry shipping forgings is one not shipping plate this quarter, and the arsenal commission's quarterly split is a secret worth stealing.", + new string[0], (steel, 4)); + + var barrel = Compound("gun-barrel", "Gun Barrel", "A forged blank bored, rifled and diamond-lined.", 35f, 2400); + Recipe(barrel, "fabrication", 1200, 30, 1, + "The diamond lining decides how many rounds a barrel takes before its crew swaps it. Zhestokost barrels are built to be swapped in the field, under fire, by crews trained on one pattern for twenty years.", + new[] { "barrel" }, (forging, 1), (diamond, 1)); + + var autoloader = Compound("autoloader", "Autoloader Mechanism", "Rammer, feed tray and cycling actuators that take rounds from a magazine into the breech.", 30f, 2600); + Recipe(autoloader, "fabrication", 1200, 30, 1, + "The feed is the largest moving part of a Zhestokost gun and the first thing its maintainers learn to strip. The Nakovalnya's feed collar exists so a tender can couple straight into these mechanisms.", + new[] { "feed mechanism" }, (steel, 2), (actuator, 2)); + + var fragCase = Compound("fragmentation-case", "Fragmentation Case", "A notched steel warhead body that breaks in a set pattern.", 6f, 120); + Recipe(fragCase, "fabrication", 600, 14, 2, + "The notch pattern is a maker's signature; salvage crews read it in the debris to tell whose warhead it was.", + new string[0], (steel, 2)); + + var fuze = Compound("fuze", "Fuze", "A proximity and impact fuze: a circuit board, a safe-arm switch and a booster pellet.", 0.6f, 300); + Recipe(fuze, "munitions-works", 600, 18, 4, + "Fuzes are where munitions meet electronics. When a region runs short of boards, it shows first as warheads without fuzes stacked in a depot.", + new string[0], (board, 1), (fill, 1)); + + var warhead = Compound("he-warhead", "High-Explosive Warhead", "Explosive fill cast into a fragmentation case, fuzed.", 12f, 1800); + Recipe(warhead, "munitions-works", 900, 24, 1, + "Death Monkey Explosives and the Zhestokost arsenal fill the same warhead from the same chemistry; only the stencils differ, and a recovered warhead's stencil is evidence in a claim.", + new[] { "warhead" }, (fill, 2), (fragCase, 1), (fuze, 1)); + + var motor = Compound("rocket-motor", "Rocket Motor", "Propellant cast into a steel case with a nozzle.", 10f, 1500); + Recipe(motor, "munitions-works", 900, 20, 1, + "The same powder as a gun charge, shaped to burn for seconds instead of milliseconds: missile stocks and gun stocks compete for one powder train.", + new[] { "thruster" }, (powder, 2), (steel, 1)); + + var dispenser = Compound("mine-dispenser", "Mine Dispenser", "A rack and ejector that lays mines in a pattern.", 20f, 1600); + Recipe(dispenser, "fabrication", 900, 20, 1, + "Little more than steel and actuators, which is why every convoy navy can build one and every blockade starts with one.", + new[] { "dispenser" }, (steel, 2), (actuator, 1)); + + // The designs whose every role this chain fills. Missile racks and rocket pods also need a guidance system, which the + // electronics chain fills; their recipes wait for it. + foreach (var gun in new[] { "Light Machine Gun", "Autocannon", "Long Slug Rifle", "Charged Scattergun", "Slug Rifle", "Flak Gun", "Cluster Cannon", "Point Defense Gun" }) + Design(gun, 1800, 30, "A ballistic gun is a barrel and a feed; the round brings the energy."); + Design("Mine Launcher", 1800, 24, "A dispenser and the warheads it lays."); + } + + private CultRecordRef FactionRef(string name) + { + var faction = _a.Catalog.GetAll().Single(f => f.Name == name); + return new CultRecordRef(_a.Catalog.RefOf(faction).Key); + } + + // Sets this faction's stand-in on a kind, replacing any it had, so a rerun converges. + private void StandIn(string kindId, CultRecordRef faction, string standInKindId) + { + var key = StationKindData.KeyOf(kindId); + var kind = _a.Catalog.Get(key) ?? throw new InvalidOperationException($"The catalog holds no station kind '{kindId}'."); + kind.StandIns = kind.StandIns.Where(s => !s.Faction.Key.Equals(faction.Key)).ToList(); + kind.StandIns.Add(new StationKindStandIn { Faction = faction, Kind = new CultRecordRef(StationKindData.KeyOf(standInKindId)) }); + _a.Put(kind, key); + } + + private static CultRecordKey CommodityKey(string id) => new CultRecordKey("commodity:" + id); + + private CultRecordRef Interface(string id, string name, string description, float mass, int price, bool simple) + { + var key = CommodityKey(id); + if (_a.Catalog.Get(key) == null) + { + if (simple) _a.Put(new SimpleCommodityData { Name = name, Description = description, Mass = mass, Price = price }, key); + else _a.Put(new CompoundCommodityData { Name = name, Description = description, Mass = mass, Price = price }, key); + } + return new CultRecordRef(key); + } + + private CultRecordRef Simple(string id, string name, string description, float mass, int price) + { + var key = CommodityKey(id); + _a.Put(new SimpleCommodityData { Name = name, Description = description, Mass = mass, Price = price }, key); + return new CultRecordRef(key); + } + + private CultRecordRef Compound(string id, string name, string description, float mass, int price) + { + var key = CommodityKey(id); + _a.Put(new CompoundCommodityData { Name = name, Description = description, Mass = mass, Price = price }, key); + return new CultRecordRef(key); + } + + // An item the catalog already holds, by its unique name. + private CultRecordRef Existing(string name) + { + var named = _a.Catalog.GetAll().Where(i => i.Name == name).ToArray(); + if (named.Length != 1) throw new InvalidOperationException($"{named.Length} items are named '{name}'; the munitions batch needs exactly one."); + return new CultRecordRef(_a.Catalog.RefOf(named[0]).Key); + } + + private void Recipe(CultRecordRef output, string kind, float cycle, int workforce, int outputCount, string lore, string[] fills, + params (CultRecordRef Commodity, int Count)[] inputs) + { + _a.Put(new RecipeData + { + Output = output, + OutputCount = outputCount, + Inputs = inputs.Select(i => new CommodityCount { Commodity = i.Commodity, Count = i.Count }).ToList(), + Cycle = cycle, + Workforce = workforce, + Upkeep = new List(), + StationKind = new CultRecordRef(StationKindData.KeyOf(kind)), + LoreHook = lore, + Fills = fills.ToList() + }, RecipeData.KeyOf(output.Key)); + } + + // A role recipe: its inputs are the design's roles, so it names none. + private void Design(string name, float cycle, int workforce, string lore) => + Recipe(Existing(name), "fabrication", cycle, workforce, 1, lore, new string[0]); +} From fe7ea72c9b4a36e64943e2082125992aa5001c4a Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 23 Oct 2026 17:20:04 +0200 Subject: [PATCH 2/9] StationKinds.Choose: a kind the faction places but no maker can field leaves its pool and falls back to any maker A stand-in whose hull kind no offered station hull carries (Zhestokost's depot, whose model has not landed) used to leave the tutorial entrance with no station. The existing no-kinds fallback now covers it: one rule, no faction special case. Co-Authored-By: Claude Sonnet 5.5 --- Assets/Scripts/ServerShared/StationKinds.cs | 29 ++++++++++++------- .../Aetheria.Shared.Tests/StationKindTests.cs | 28 ++++++++++++++++++ 2 files changed, 46 insertions(+), 11 deletions(-) diff --git a/Assets/Scripts/ServerShared/StationKinds.cs b/Assets/Scripts/ServerShared/StationKinds.cs index 4d7c54ffe..d7ac014b4 100644 --- a/Assets/Scripts/ServerShared/StationKinds.cs +++ b/Assets/Scripts/ServerShared/StationKinds.cs @@ -52,22 +52,21 @@ public static class StationKinds return Ordered(kinds); } - // A station's kind: a stable pick among the faction's kinds by the station's site, which generation names by the zone's - // seed and the station's place in its orbit order (never by a key the cache mints). It draws nothing from any random - // stream, so adding the kind to generation moves no other roll. A faction with no kinds falls back to any kind some - // offered station hull carries, logged, and the hull draw then falls back to any maker. Unset when the catalog has none. + // A station's kind: a stable pick among the faction's kinds it can field, by the station's site, which generation names by the + // zone's seed and the station's place in its orbit order (never by a key the cache mints). It draws nothing from any random + // stream, so adding the kind to generation moves no other roll. A kind the faction places but cannot field (neither its own + // model nor a stand-in's hull kind is carried by any offered station hull) is not in the pool; a faction left with no kind to + // field falls back to any kind some offered station hull carries, logged, and the hull draw then falls back to any maker. + // Unset when the catalog has none. public static CultRecordRef Choose(CultCache catalog, Faction faction, string site, Action log = null) { - var pool = KindsOf(catalog, faction); + var offered = OfferedKinds(catalog); + var pool = KindsOf(catalog, faction).Where(kind => offered.Contains(HullKindFor(catalog, faction, kind).Key.Value)).ToArray(); if (pool.Length == 0) { - pool = Ordered(new HashSet( - catalog.GetAll().Where(product => LoadoutGenerator.IsOffered(catalog, product)) - .Select(product => catalog.Get(product.Design) as HullData) - .Where(hull => hull != null && hull.HullType == HullType.Station && hull.Kind.IsSet()) - .Select(hull => hull.Kind.Key.Value), StringComparer.Ordinal)); + pool = Ordered(offered); if (pool.Length == 0) return default; - log?.Invoke($"{faction?.Name ?? "This galaxy"} builds no station kind; placing a station of any kind some maker offers."); + log?.Invoke($"{faction?.Name ?? "This galaxy"} builds no station kind it can field; placing a station of any kind some maker offers."); } return pool[(int) (site.StableHash() % (uint) pool.Length)]; } @@ -130,6 +129,14 @@ public static class StationKinds } } + // The hull kinds some maker offers: the pool a station can always be drawn from. + private static HashSet OfferedKinds(CultCache catalog) => + new HashSet( + catalog.GetAll().Where(product => LoadoutGenerator.IsOffered(catalog, product)) + .Select(product => catalog.Get(product.Design) as HullData) + .Where(hull => hull != null && hull.HullType == HullType.Station && hull.Kind.IsSet()) + .Select(hull => hull.Kind.Key.Value), StringComparer.Ordinal); + private static IEnumerable OfferedStationHulls(CultCache catalog, Faction faction) => catalog.GetAll() .Where(product => LoadoutGenerator.IsOffered(catalog, product) && catalog.Get(product.Manufacturer) == faction) diff --git a/tests/Aetheria.Shared.Tests/StationKindTests.cs b/tests/Aetheria.Shared.Tests/StationKindTests.cs index 47154c1c7..23d72e4e7 100644 --- a/tests/Aetheria.Shared.Tests/StationKindTests.cs +++ b/tests/Aetheria.Shared.Tests/StationKindTests.cs @@ -273,6 +273,34 @@ public sealed class StationKindTests : IDisposable } } + // A faction that places a kind through a stand-in no maker offers cannot field it: the kind is out of its pool and it falls back + // exactly as a faction with no kinds does. Once any maker offers the stand-in's hull kind, the faction keeps its kind. + [Fact] + public void FactionWhoseStandInNoMakerOffersFallsBackToAnyMaker() + { + var world = World.Make(this, zenithOffered: false); + world.Sell(world.Au, "shipyard"); + world.StandIn("mining", world.Lucent, "depot"); + Assert.Equal(new[] { Kind("mining").Key }, StationKinds.KindsOf(world.Cache, world.Lucent).Select(kind => kind.Key)); + + var logged = new List(); + var kind = StationKinds.Choose(world.Cache, world.Lucent, "site", logged.Add); + Assert.Equal(Kind("shipyard").Key, kind.Key); + Assert.Contains(world.Lucent.Name, Assert.Single(logged)); + var pack = world.Generator(world.Lucent).GenerateStationLoadout(kind); + Assert.NotNull(pack); + Assert.Equal(Kind("shipyard").Key, world.HullOf(pack).Kind.Key); + + world.Sell(world.Au, "depot"); + var kept = new List(); + var placed = StationKinds.Choose(world.Cache, world.Lucent, "site", kept.Add); + Assert.Equal(Kind("mining").Key, placed.Key); + Assert.Empty(kept); + var depotStation = world.Generator(world.Lucent).GenerateStationLoadout(placed); + Assert.NotNull(depotStation); + Assert.Equal(Kind("depot").Key, world.HullOf(depotStation).Kind.Key); + } + [Fact] public void FactionWithoutModelsFallsBack() { From fce8c6628474544fd00ab4ecac433d3af3312809 Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 23 Oct 2026 17:23:24 +0200 Subject: [PATCH 3/9] StationKinds: FieldableKindsOf is the pool Choose draws from Co-Authored-By: Claude Sonnet 5.5 --- Assets/Scripts/ServerShared/StationKinds.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/ServerShared/StationKinds.cs b/Assets/Scripts/ServerShared/StationKinds.cs index d7ac014b4..6b1d617a6 100644 --- a/Assets/Scripts/ServerShared/StationKinds.cs +++ b/Assets/Scripts/ServerShared/StationKinds.cs @@ -52,6 +52,14 @@ public static class StationKinds return Ordered(kinds); } + // The kinds this faction places that a station can be drawn for: those whose hull kind (its own model, else its stand-in's) some + // maker offers. A stand-in whose model has not landed leaves its kind out. + public static CultRecordRef[] FieldableKindsOf(CultCache catalog, Faction faction) + { + var offered = OfferedKinds(catalog); + return KindsOf(catalog, faction).Where(kind => offered.Contains(HullKindFor(catalog, faction, kind).Key.Value)).ToArray(); + } + // A station's kind: a stable pick among the faction's kinds it can field, by the station's site, which generation names by the // zone's seed and the station's place in its orbit order (never by a key the cache mints). It draws nothing from any random // stream, so adding the kind to generation moves no other roll. A kind the faction places but cannot field (neither its own @@ -60,11 +68,10 @@ public static class StationKinds // Unset when the catalog has none. public static CultRecordRef Choose(CultCache catalog, Faction faction, string site, Action log = null) { - var offered = OfferedKinds(catalog); - var pool = KindsOf(catalog, faction).Where(kind => offered.Contains(HullKindFor(catalog, faction, kind).Key.Value)).ToArray(); + var pool = FieldableKindsOf(catalog, faction); if (pool.Length == 0) { - pool = Ordered(offered); + pool = Ordered(OfferedKinds(catalog)); if (pool.Length == 0) return default; log?.Invoke($"{faction?.Name ?? "This galaxy"} builds no station kind it can field; placing a station of any kind some maker offers."); } From b1b5031e4b9d6c15036352e2b21962cfa3f96015 Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 23 Oct 2026 17:23:26 +0200 Subject: [PATCH 4/9] Economy batch 1 (munitions): apply Munitions to the shipped catalog; re-pin what the catalog stales economy author Munitions apply: 49 added, 4 changed. The pins that name the shipped catalog's contents follow it: the kind list gains munitions-works, the simple commodity count, the retirement check counts only its own stand-in, the stand-in liveness check exempts a faction awaiting its first station model (Zhestokost), and generated stations draw from the fieldable kinds. Co-Authored-By: Claude Sonnet 5.5 --- GameData/Aetheria.cc | 4 ++-- .../CommodityRecordsTests.cs | 2 +- tests/Aetheria.Shared.Tests/StationKindTests.cs | 17 ++++++++++++++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/GameData/Aetheria.cc b/GameData/Aetheria.cc index 55da2e5e9..7a7b99f5c 100644 --- a/GameData/Aetheria.cc +++ b/GameData/Aetheria.cc @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:cf937f0b1ef1c0f732ccfd14728ecb786601b1ebf50699bcd7bc47cd81716fcc -size 195939 +oid sha256:68b37cb55c012c9d1df97bbf0de5c0a56d1804ce5f16f498738cd4de51c88e4b +size 214588 diff --git a/tests/Aetheria.Shared.Tests/CommodityRecordsTests.cs b/tests/Aetheria.Shared.Tests/CommodityRecordsTests.cs index 7f1c376c3..21e2995de 100644 --- a/tests/Aetheria.Shared.Tests/CommodityRecordsTests.cs +++ b/tests/Aetheria.Shared.Tests/CommodityRecordsTests.cs @@ -13,7 +13,7 @@ public sealed class CommodityRecordsTests public void ShippedCatalogOpensWithTheRetiredKeysGone() { using var cache = RestoredHullsTests.OpenCatalog(); - Assert.Equal(13, cache.GetAll().Count()); + Assert.Equal(22, cache.GetAll().Count()); Assert.Equal(51, cache.GetAll().Count()); Assert.Contains(cache.GetAll(), c => c.Name == "Ammo"); Assert.All(cache.GetAll(), c => Assert.False(string.IsNullOrEmpty(c.Name))); diff --git a/tests/Aetheria.Shared.Tests/StationKindTests.cs b/tests/Aetheria.Shared.Tests/StationKindTests.cs index 23d72e4e7..e8c7164eb 100644 --- a/tests/Aetheria.Shared.Tests/StationKindTests.cs +++ b/tests/Aetheria.Shared.Tests/StationKindTests.cs @@ -401,7 +401,7 @@ public sealed class StationKindTests : IDisposable Assert.True(station.Kind.IsSet(), "a placed station has a kind"); Assert.Equal(station.Kind.Key, w.HullOf(station).Kind.Key); var faction = w.Cache.Get(station.Faction); - var kinds = StationKinds.KindsOf(w.Cache, faction); + var kinds = StationKinds.FieldableKindsOf(w.Cache, faction); if (kinds.Length > 0) Assert.Contains(station.Kind.Key.Value, kinds.Select(kind => kind.Key.Value)); } } @@ -433,19 +433,30 @@ public sealed class StationKindTests : IDisposable var ids = new[] { "mining", "volatiles", "agriculture", "processing", "fabrication", "shipyard", "depot", "trade-hub", "residential", - "habitat-support", "urban", "administrative", "power", "research", "salvage", "black-market", "waystation" + "habitat-support", "urban", "administrative", "power", "research", "salvage", "black-market", "waystation", "munitions-works" }; Assert.Equal(ids.Select(id => StationKindData.KeyOf(id).Value).OrderBy(key => key, StringComparer.Ordinal), cache.GetAll().Select(kind => cache.RefOf(kind).Key.Value).OrderBy(key => key, StringComparer.Ordinal)); Assert.Equal(StationKindData.KeyOf("trade-hub").Value, cache.GetAll().Single(h => h.Name == "Zenith").Kind.Key.Value); } + // Factions whose first station model has not landed (ruling faction-station-models): their stand-ins name the kind that model + // will be and are not yet live. The generator seats such a faction by the any-maker fallback (StationKinds.Choose). Each is + // checked to still own no station hull, so the exemption ends the day a model lands. + private static readonly string[] AwaitingFirstModel = { "Zhestokost" }; + private static void AssertStandInsLive(CultCache cache) { foreach (var kind in cache.GetAll()) foreach (var standIn in kind.StandIns) { var faction = cache.Get(standIn.Faction); + if (AwaitingFirstModel.Contains(faction.Name)) + { + Assert.DoesNotContain(cache.GetAll(), p => cache.Get(p.Manufacturer) == faction && LoadoutGenerator.IsOffered(cache, p) + && cache.Get(p.Design) is HullData { HullType: HullType.Station }); + continue; + } var models = StationKinds.KindsOf(cache, faction); var own = cache.GetAll().Where(p => cache.Get(p.Manufacturer) == faction && LoadoutGenerator.IsOffered(cache, p)) .Select(p => cache.Get(p.Design) as HullData).Where(h => h != null && h.HullType == HullType.Station).Select(h => h.Kind.Key).ToArray(); @@ -470,7 +481,7 @@ public sealed class StationKindTests : IDisposable var live = World.Make(this, zenithOffered: false); live.Sell(live.Au, "mining"); live.StandIn("shipyard", live.Au, "mining"); - Assert.Single(live.Cache.GetAll().SelectMany(kind => kind.StandIns)); + Assert.Single(live.Cache.GetAll().SelectMany(kind => kind.StandIns), standIn => live.Cache.Get(standIn.Faction) == live.Au); AssertStandInsLive(live.Cache); var retired = World.Make(this, zenithOffered: false); From d5c0063b7e94283c3e3df25a407d54946ac5fa28 Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 23 Oct 2026 17:29:50 +0200 Subject: [PATCH 5/9] CommodityRecordsTests: the compound commodity count follows the batch (51 to 63) Co-Authored-By: Claude Sonnet 5.5 --- tests/Aetheria.Shared.Tests/CommodityRecordsTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Aetheria.Shared.Tests/CommodityRecordsTests.cs b/tests/Aetheria.Shared.Tests/CommodityRecordsTests.cs index 21e2995de..2b2acfaa0 100644 --- a/tests/Aetheria.Shared.Tests/CommodityRecordsTests.cs +++ b/tests/Aetheria.Shared.Tests/CommodityRecordsTests.cs @@ -14,7 +14,7 @@ public sealed class CommodityRecordsTests { using var cache = RestoredHullsTests.OpenCatalog(); Assert.Equal(22, cache.GetAll().Count()); - Assert.Equal(51, cache.GetAll().Count()); + Assert.Equal(63, cache.GetAll().Count()); Assert.Contains(cache.GetAll(), c => c.Name == "Ammo"); Assert.All(cache.GetAll(), c => Assert.False(string.IsNullOrEmpty(c.Name))); } From e403905e12e8ad347ab6a28955611f057837905c Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 23 Oct 2026 18:02:47 +0200 Subject: [PATCH 6/9] LoadoutGenerator.IsDrawable is the one definition of 'a maker offers this design'; StationKinds keeps a kind by it AvailableProducts (Price > 0, a set Manufacturer, offered) and StationKinds.OfferedKinds (offered only) disagreed, so Choose could keep a kind whose hull draw returns null. Both now ask IsDrawable; OfferedKinds and OfferedStationHulls read the same drawable station products. Co-Authored-By: Claude Sonnet 5.5 --- Assets/Scripts/ServerShared/LoadoutGenerator.cs | 11 +++++++---- Assets/Scripts/ServerShared/StationKinds.cs | 16 ++++++++-------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Assets/Scripts/ServerShared/LoadoutGenerator.cs b/Assets/Scripts/ServerShared/LoadoutGenerator.cs index ce8569965..9f4829eee 100644 --- a/Assets/Scripts/ServerShared/LoadoutGenerator.cs +++ b/Assets/Scripts/ServerShared/LoadoutGenerator.cs @@ -200,11 +200,8 @@ public class LoadoutGenerator var candidates = ItemManager.ItemData.GetAll() .Select(product => (product, design: ItemManager.ItemData.Get(product.Design) as T)) .Where(entry => - entry.design != null && - entry.design.Price > 0 && - entry.product.Manufacturer.IsSet() && // A not-offered product is never a candidate, so the any-manufacturer fallback below cannot reach it either. - IsOffered(ItemManager.ItemData, entry.product) && + IsDrawable(ItemManager.ItemData, entry.product, entry.design) && (!(entry.design is EquippableItemData equippable) || HasHome(equippable, hulls)) && (filter?.Invoke(entry.design) ?? true)) .ToArray(); @@ -246,6 +243,12 @@ public class LoadoutGenerator Galaxy == null || Faction == null || ItemManager.ItemData.Get(product.Manufacturer) == Faction || Faction.Allegiance.ContainsKey(product.Manufacturer)); + // Whether a product can be drawn for its design at all: the design resolves, has a price, the product names a maker and is + // offered. The one definition of 'a maker offers this design'; AvailableProducts selects by it and StationKinds decides which + // station kinds a hull can be drawn for by it, so a kind is kept exactly when a hull of it can be drawn. + public static bool IsDrawable(CultCache items, FactionProductData product, CraftedItemData design) => + design != null && design.Price > 0 && product.Manufacturer.IsSet() && IsOffered(items, product); + // Whether a product is on the market at all (ruling off-market-is-unoffered-product). The one reader of NotOffered. A bin is // offered only if both it and its line are (ruling bin-inherits-line-offered); the catalog read guarantees a bin's line exists. public static bool IsOffered(CultCache items, FactionProductData product) => diff --git a/Assets/Scripts/ServerShared/StationKinds.cs b/Assets/Scripts/ServerShared/StationKinds.cs index 6b1d617a6..d40beeb56 100644 --- a/Assets/Scripts/ServerShared/StationKinds.cs +++ b/Assets/Scripts/ServerShared/StationKinds.cs @@ -138,17 +138,17 @@ public static class StationKinds // The hull kinds some maker offers: the pool a station can always be drawn from. private static HashSet OfferedKinds(CultCache catalog) => - new HashSet( - catalog.GetAll().Where(product => LoadoutGenerator.IsOffered(catalog, product)) - .Select(product => catalog.Get(product.Design) as HullData) - .Where(hull => hull != null && hull.HullType == HullType.Station && hull.Kind.IsSet()) - .Select(hull => hull.Kind.Key.Value), StringComparer.Ordinal); + new HashSet(DrawableStationProducts(catalog).Select(entry => entry.hull.Kind.Key.Value), StringComparer.Ordinal); private static IEnumerable OfferedStationHulls(CultCache catalog, Faction faction) => + DrawableStationProducts(catalog).Where(entry => catalog.Get(entry.product.Manufacturer) == faction).Select(entry => entry.hull); + + // The station hulls a hull draw can reach (LoadoutGenerator.IsDrawable, the one definition), with the product that sells each. + private static IEnumerable<(FactionProductData product, HullData hull)> DrawableStationProducts(CultCache catalog) => catalog.GetAll() - .Where(product => LoadoutGenerator.IsOffered(catalog, product) && catalog.Get(product.Manufacturer) == faction) - .Select(product => catalog.Get(product.Design) as HullData) - .Where(hull => hull != null && hull.HullType == HullType.Station && hull.Kind.IsSet()); + .Select(product => (product, hull: catalog.Get(product.Design) as HullData)) + .Where(entry => entry.hull != null && entry.hull.HullType == HullType.Station && entry.hull.Kind.IsSet() && + LoadoutGenerator.IsDrawable(catalog, entry.product, entry.hull)); private static CultRecordRef[] Ordered(IEnumerable keys) => keys.OrderBy(key => key, StringComparer.Ordinal).Select(key => new CultRecordRef(new CultRecordKey(key))).ToArray(); From e3824360aa17fed7381762c5df24a70906948c99 Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 23 Oct 2026 18:02:48 +0200 Subject: [PATCH 7/9] StationKindTests: stand-ins judged from the catalog, zones test against an oracle, the partial and fallback-spread cases pinned Deletes the name-keyed AwaitingFirstModel exemption: AssertStandInsLive derives liveness from the sold hulls (live exactly when some maker sells the target kind; otherwise the kind leaves the pool and the any-maker fallback is observed in the log). GeneratedZonesPlaceStationsByKind checks against a records-level oracle and asserts the fallback case. New: a kind is kept exactly when a hull of it can be drawn (Price 0, no maker), a faction with one fieldable and one unfieldable kind places only the first, the fallback spreads over every offered kind. Co-Authored-By: Claude Sonnet 5.5 --- .../Aetheria.Shared.Tests/StationKindTests.cs | 164 +++++++++++++++--- 1 file changed, 139 insertions(+), 25 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/StationKindTests.cs b/tests/Aetheria.Shared.Tests/StationKindTests.cs index e8c7164eb..d568f2d1e 100644 --- a/tests/Aetheria.Shared.Tests/StationKindTests.cs +++ b/tests/Aetheria.Shared.Tests/StationKindTests.cs @@ -86,6 +86,14 @@ public sealed class StationKindTests : IDisposable return hull; } + // Takes a sold hull's price to zero, or its product's maker away: the hull is still on a product but no hull draw can reach it. + public void Unsellable(HullData hull, bool unsetMaker) + { + var product = Cache.GetAll().Single(p => Cache.Get(p.Design) == hull); + if (unsetMaker) { product.Manufacturer = default; Cache.Upsert(product); } + else { hull.Price = 0; Cache.Upsert(hull); } + } + public void StandIn(string kindId, Faction faction, string asKindId) { var kind = Cache.Get(Kind(kindId)); @@ -386,11 +394,14 @@ public sealed class StationKindTests : IDisposable var w = World.Make(this, zenithOffered: true); w.Sell(w.Au, "mining"); w.Sell(w.Au, "shipyard"); + w.StandIn("depot", w.Lucent, "power"); + w.StandIn("depot", w.Zh, "power"); var authored = AuthoredSettings.Load(RunStartTests.FindRepoRoot()); var galaxy = new Galaxy(authored.Read("TutorialGenerationSettings"), authored.Read("TutorialBackgroundSettings"), w.Cache, new PlayerSettings(), Directory.CreateDirectory(Path.Combine(_root, "zones", "Narrative")), _ => { }, null, 5); var stations = 0; + var fallbacks = 0; foreach (var galaxyZone in galaxy.Zones.Take(8)) { var pack = ZoneGenerator.GenerateZone(w.Items, authored.Read("ZoneSettings"), @@ -401,13 +412,100 @@ public sealed class StationKindTests : IDisposable Assert.True(station.Kind.IsSet(), "a placed station has a kind"); Assert.Equal(station.Kind.Key, w.HullOf(station).Kind.Key); var faction = w.Cache.Get(station.Faction); - var kinds = StationKinds.FieldableKindsOf(w.Cache, faction); - if (kinds.Length > 0) Assert.Contains(station.Kind.Key.Value, kinds.Select(kind => kind.Key.Value)); + var fieldable = OracleFieldableKinds(w.Cache, faction); + if (fieldable.Count > 0) Assert.Contains(station.Kind.Key.Value, fieldable); + else + { + fallbacks++; + Assert.Contains(station.Kind.Key.Value, OracleOfferedKinds(w.Cache)); + } } } + Assert.True(fallbacks > 0, "the sample seated a faction that could field none of its kinds, by the fallback"); Assert.True(stations > 0, "the sample generated stations"); } + // An oracle for what a hull draw can reach, read straight off the records and independent of StationKinds and LoadoutGenerator: + // a station hull with a kind and a price, sold by an unbinned product that names a maker and is not off the market. + private static IEnumerable<(CultRecordKey maker, string kind)> OracleSoldStationKinds(CultCache cache) => + cache.GetAll() + .Where(p => !p.NotOffered && p.Bin == null && p.Manufacturer.IsSet()) + .Select(p => (p, hull: cache.Get(p.Design) as HullData)) + .Where(e => e.hull != null && e.hull.HullType == HullType.Station && e.hull.Kind.IsSet() && e.hull.Price > 0) + .Select(e => (e.p.Manufacturer.Key, e.hull.Kind.Key.Value)); + + private static HashSet OracleOfferedKinds(CultCache cache) => OracleSoldStationKinds(cache).Select(e => e.kind).ToHashSet(); + + // The kinds a faction can field: those it has its own model of, and those it stands in on whose stand-in kind some maker sells. + private static HashSet OracleFieldableKinds(CultCache cache, Faction faction) + { + var offered = OracleOfferedKinds(cache); + var own = OracleSoldStationKinds(cache).Where(e => e.maker.Equals(cache.RefOf(faction).Key)).Select(e => e.kind).ToHashSet(); + foreach (var kind in cache.GetAll()) + foreach (var standIn in kind.StandIns.Where(entry => cache.Get(entry.Faction) == faction)) + if (offered.Contains(standIn.Kind.Key.Value)) own.Add(cache.RefOf(kind).Key.Value); + return own; + } + + // Choose keeps a kind exactly when GenerateStationLoadout can draw a hull of it: a hull sold at Price 0, or by a product with no + // maker, is no hull a draw reaches, so a faction standing in on its kind is not seated on it. The tutorial entrance still gets a station. + [Theory] + [InlineData(false)] + [InlineData(true)] + public void AKindIsKeptExactlyWhenAHullOfItCanBeDrawn(bool unsetMaker) + { + var world = World.Make(this, zenithOffered: false); + world.Sell(world.Au, "mining"); + world.Unsellable(world.Sell(world.Au, "shipyard"), unsetMaker); + world.StandIn("mining", world.Lucent, "shipyard"); + world.StandIn("mining", world.Zh, "shipyard"); + + foreach (var faction in new[] { world.Au, world.Lucent, world.Zh }) + for (var site = 0; site < 12; site++) + { + var kind = StationKinds.Choose(world.Cache, faction, "site-" + site); + Assert.Equal(Kind("mining").Key, kind.Key); + Assert.NotNull(world.Generator(faction).GenerateStationLoadout(kind)); + } + + var authored = AuthoredSettings.Load(RunStartTests.FindRepoRoot()); + var galaxy = new Galaxy(authored.Read("TutorialGenerationSettings"), + authored.Read("TutorialBackgroundSettings"), world.Cache, new PlayerSettings(), + Directory.CreateDirectory(Path.Combine(_root, "galaxy" + _worlds++, "Narrative")), _ => { }, null, 5); + var entrance = ZoneGenerator.GenerateZone(world.Items, authored.Read("ZoneSettings"), + authored.Read("PlanetSettings"), galaxy, galaxy.Entrance, galaxy.IsPrelude, true); + Assert.Contains(entrance.Entities.OfType(), e => world.HullOf(e).HullType == HullType.Station); + } + + // A faction with one kind it can field and one it cannot places only the one it can, and never takes the fallback. + [Fact] + public void AFactionWithSomeKindsFieldablePlacesOnlyThose() + { + var world = World.Make(this, zenithOffered: false); + world.Sell(world.Au, "shipyard"); + world.StandIn("mining", world.Lucent, "shipyard"); + world.StandIn("depot", world.Lucent, "power"); + Assert.Equal(2, StationKinds.KindsOf(world.Cache, world.Lucent).Length); + + var logged = new List(); + for (var site = 0; site < 40; site++) + Assert.Equal(Kind("mining").Key, StationKinds.Choose(world.Cache, world.Lucent, "site-" + site, logged.Add).Key); + Assert.Empty(logged); + } + + // The fallback pool is every kind some maker offers, spread over sites, not the first of them. + [Fact] + public void TheFallbackSpreadsSitesOverEveryOfferedKind() + { + var world = World.Make(this, zenithOffered: false); + world.Sell(world.Au, "mining"); + world.Sell(world.Au, "shipyard"); + world.Sell(world.Au, "depot"); + var chosen = Enumerable.Range(0, 40).Select(site => StationKinds.Choose(world.Cache, world.Lucent, "site-" + site).Key.Value).ToHashSet(); + Assert.Equal(new[] { Kind("depot"), Kind("mining"), Kind("shipyard") }.Select(kind => kind.Key.Value).OrderBy(k => k, StringComparer.Ordinal), + chosen.OrderBy(k => k, StringComparer.Ordinal)); + } + [Fact] public void KindSurvivesSave() { @@ -440,30 +538,34 @@ public sealed class StationKindTests : IDisposable Assert.Equal(StationKindData.KeyOf("trade-hub").Value, cache.GetAll().Single(h => h.Name == "Zenith").Kind.Key.Value); } - // Factions whose first station model has not landed (ruling faction-station-models): their stand-ins name the kind that model - // will be and are not yet live. The generator seats such a faction by the any-maker fallback (StationKinds.Choose). Each is - // checked to still own no station hull, so the exemption ends the day a model lands. - private static readonly string[] AwaitingFirstModel = { "Zhestokost" }; - - private static void AssertStandInsLive(CultCache cache) + // Every stand-in is judged from the catalog: its target is a real kind; the faction owns no model of the kind it stands in for; and + // the stand-in is live (the faction can field the kind) exactly when some maker sells a hull of the target kind. A stand-in + // no maker can field is not a defect: the generator drops the kind from the faction's pool and seats it by the any-maker + // fallback, logged (StationKinds.Choose). Returns how many stand-ins were live, so a caller can see the catalog's state. + private static int AssertStandInsLive(CultCache cache) { + var live = 0; foreach (var kind in cache.GetAll()) foreach (var standIn in kind.StandIns) { var faction = cache.Get(standIn.Faction); - if (AwaitingFirstModel.Contains(faction.Name)) + var owning = cache.RefOf(kind).Key.Value; + Assert.NotNull(cache.Get(standIn.Kind)); + Assert.DoesNotContain(owning, OracleSoldStationKinds(cache).Where(e => e.maker.Equals(cache.RefOf(faction).Key)).Select(e => e.kind)); + var carried = OracleOfferedKinds(cache).Contains(standIn.Kind.Key.Value); + var fieldable = StationKinds.FieldableKindsOf(cache, faction).Select(k => k.Key.Value).Contains(owning); + Assert.Equal(carried, fieldable); + if (carried) { live++; continue; } + if (StationKinds.FieldableKindsOf(cache, faction).Length > 0) continue; + var logged = new List(); + var seated = StationKinds.Choose(cache, faction, "site", logged.Add); + if (OracleOfferedKinds(cache).Count > 0) { - Assert.DoesNotContain(cache.GetAll(), p => cache.Get(p.Manufacturer) == faction && LoadoutGenerator.IsOffered(cache, p) - && cache.Get(p.Design) is HullData { HullType: HullType.Station }); - continue; + Assert.Single(logged); + Assert.Contains(seated.Key.Value, OracleOfferedKinds(cache)); } - var models = StationKinds.KindsOf(cache, faction); - var own = cache.GetAll().Where(p => cache.Get(p.Manufacturer) == faction && LoadoutGenerator.IsOffered(cache, p)) - .Select(p => cache.Get(p.Design) as HullData).Where(h => h != null && h.HullType == HullType.Station).Select(h => h.Kind.Key).ToArray(); - Assert.DoesNotContain(cache.RefOf(kind).Key, own); - Assert.Contains(standIn.Kind.Key, own); - Assert.NotEmpty(models); } + return live; } [Fact] @@ -473,16 +575,17 @@ public sealed class StationKindTests : IDisposable AssertStandInsLive(cache); } - // The retirement check is not vacuous: given a stand-in it passes when the faction offers the kind it stands in with and - // not the owning kind, and fails when the faction has gained its own model of the owning kind or has no model to use. + // The stand-in check is not vacuous: a stand-in passes live when the faction can field the kind it stands in with and has no model + // of the owning kind; fails when the faction has gained its own model of the owning kind; is dead, with the fallback observed, + // when no maker sells the target kind (a retarget to a kind no hull carries included); and is caught if its target is no kind. [Fact] - public void StandInRetirementCheckCanFail() + public void StandInCheckCanFail() { var live = World.Make(this, zenithOffered: false); live.Sell(live.Au, "mining"); live.StandIn("shipyard", live.Au, "mining"); Assert.Single(live.Cache.GetAll().SelectMany(kind => kind.StandIns), standIn => live.Cache.Get(standIn.Faction) == live.Au); - AssertStandInsLive(live.Cache); + Assert.Equal(1, AssertStandInsLive(live.Cache)); var retired = World.Make(this, zenithOffered: false); retired.Sell(retired.Au, "mining"); @@ -490,8 +593,19 @@ public sealed class StationKindTests : IDisposable retired.StandIn("shipyard", retired.Au, "mining"); Assert.ThrowsAny(() => AssertStandInsLive(retired.Cache)); - var hollow = World.Make(this, zenithOffered: false); - hollow.StandIn("shipyard", hollow.Au, "mining"); - Assert.ThrowsAny(() => AssertStandInsLive(hollow.Cache)); + var nowhere = World.Make(this, zenithOffered: false); + nowhere.Sell(nowhere.Au, "mining"); + nowhere.StandIn("shipyard", nowhere.Lucent, "power"); + Assert.Equal(0, AssertStandInsLive(nowhere.Cache)); + var logged = new List(); + Assert.Equal(Kind("mining").Key, StationKinds.Choose(nowhere.Cache, nowhere.Lucent, "site", logged.Add).Key); + Assert.Single(logged); + + var missing = World.Make(this, zenithOffered: false); + missing.Sell(missing.Au, "mining"); + missing.StandIn("shipyard", missing.Lucent, "mining"); + var kind = missing.Cache.Get(Kind("shipyard")); + kind.StandIns[0].Kind = Kind("no-such-kind"); + Assert.ThrowsAny(() => AssertStandInsLive(missing.Cache)); } } From b481363b9bfc7ffbac060656ddf63582bde9a95b Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 23 Oct 2026 18:04:24 +0200 Subject: [PATCH 8/9] StationKinds.HullKindFor takes a stand-in's kind only when some maker offers it The any-maker fallback in Choose could seat a faction on a kind it has a dead stand-in for; the hull draw then looked for the dead stand-in's kind and returned null. A stand-in no maker offers is no longer followed, so a kind Choose places is a kind the hull draw can fill. FieldableKindsOf reads the same two helpers. Co-Authored-By: Claude Sonnet 5.5 --- Assets/Scripts/ServerShared/StationKinds.cs | 26 +++++++++++++-------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/Assets/Scripts/ServerShared/StationKinds.cs b/Assets/Scripts/ServerShared/StationKinds.cs index d40beeb56..dad1ce2aa 100644 --- a/Assets/Scripts/ServerShared/StationKinds.cs +++ b/Assets/Scripts/ServerShared/StationKinds.cs @@ -54,11 +54,8 @@ public static class StationKinds // The kinds this faction places that a station can be drawn for: those whose hull kind (its own model, else its stand-in's) some // maker offers. A stand-in whose model has not landed leaves its kind out. - public static CultRecordRef[] FieldableKindsOf(CultCache catalog, Faction faction) - { - var offered = OfferedKinds(catalog); - return KindsOf(catalog, faction).Where(kind => offered.Contains(HullKindFor(catalog, faction, kind).Key.Value)).ToArray(); - } + public static CultRecordRef[] FieldableKindsOf(CultCache catalog, Faction faction) => + KindsOf(catalog, faction).Where(kind => HasModel(catalog, faction, kind) || LiveStandIn(catalog, faction, kind).IsSet()).ToArray(); // A station's kind: a stable pick among the faction's kinds it can field, by the station's site, which generation names by the // zone's seed and the station's place in its orbit order (never by a key the cache mints). It draws nothing from any random @@ -79,14 +76,23 @@ public static class StationKinds } // The kind of hull a faction builds for a station kind: the kind itself when the faction offers a model of it (a model - // wins over a stale stand-in), else the kind its stand-in names, else the kind itself (the hull draw then falls back to - // any maker). + // wins over a stale stand-in), else the kind its stand-in names when some maker offers that, else the kind itself (the hull + // draw then falls back to any maker). public static CultRecordRef HullKindFor(CultCache catalog, Faction faction, CultRecordRef kind) { - if (!kind.IsSet()) return kind; - if (OfferedStationHulls(catalog, faction).Any(hull => hull.Kind.Key.Equals(kind.Key))) return kind; + if (!kind.IsSet() || HasModel(catalog, faction, kind)) return kind; + var standIn = LiveStandIn(catalog, faction, kind); + return standIn.IsSet() ? standIn : kind; + } + + private static bool HasModel(CultCache catalog, Faction faction, CultRecordRef kind) => + OfferedStationHulls(catalog, faction).Any(hull => hull.Kind.Key.Equals(kind.Key)); + + // The kind the faction's stand-in names for this kind, when some maker offers a hull of it; else unset. + private static CultRecordRef LiveStandIn(CultCache catalog, Faction faction, CultRecordRef kind) + { var standIn = catalog.Get(kind)?.StandIns.FirstOrDefault(entry => catalog.Get(entry.Faction) == faction); - return standIn != null && standIn.Kind.IsSet() ? standIn.Kind : kind; + return standIn != null && standIn.Kind.IsSet() && OfferedKinds(catalog).Contains(standIn.Kind.Key.Value) ? standIn.Kind : default; } // What is wrong with a hull's kind, or null: a Station hull names a kind the catalog holds, and no other hull names one. From dd1031ce6ac0dac7a5957f51daa4ec1e1eb1aa8b Mon Sep 17 00:00:00 2001 From: soul Date: Fri, 23 Oct 2026 18:16:48 +0200 Subject: [PATCH 9/9] StationKindTests: a maker-less or Price 0 station hull is unreachable by the draw; the stand-in check is exercised on Zhestokost Co-Authored-By: Claude Sonnet 5.5 --- tests/Aetheria.Shared.Tests/StationKindTests.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/StationKindTests.cs b/tests/Aetheria.Shared.Tests/StationKindTests.cs index d568f2d1e..2082a3719 100644 --- a/tests/Aetheria.Shared.Tests/StationKindTests.cs +++ b/tests/Aetheria.Shared.Tests/StationKindTests.cs @@ -456,7 +456,11 @@ public sealed class StationKindTests : IDisposable { var world = World.Make(this, zenithOffered: false); world.Sell(world.Au, "mining"); - world.Unsellable(world.Sell(world.Au, "shipyard"), unsetMaker); + var unsold = world.Sell(world.Au, "shipyard"); + world.Unsellable(unsold, unsetMaker); + // No hull draw reaches it: a station of its kind cannot be generated for anyone. + Assert.Null(world.Generator(world.Au).GenerateStationLoadout(Kind("shipyard"))); + Assert.Null(world.Generator(world.Lucent).GenerateStationLoadout(Kind("shipyard"))); world.StandIn("mining", world.Lucent, "shipyard"); world.StandIn("mining", world.Zh, "shipyard"); @@ -603,7 +607,7 @@ public sealed class StationKindTests : IDisposable var missing = World.Make(this, zenithOffered: false); missing.Sell(missing.Au, "mining"); - missing.StandIn("shipyard", missing.Lucent, "mining"); + missing.StandIn("shipyard", missing.Zh, "mining"); var kind = missing.Cache.Get(Kind("shipyard")); kind.StandIns[0].Kind = Kind("no-such-kind"); Assert.ThrowsAny(() => AssertStandInsLive(missing.Cache));