Scenarios Cut 1: Materialize builds product-less designs unbranded; the hull picks the entity
Two rules on Loadouts.Materialize (docs/scenarios-cut.md, 2.2, Q3): - A design no product makes is outside the economy and is built unbranded, with no maker, at Loadouts.UnbrandedQuality (.95, the console give's). A design whose products are all unavailable still fails, as before. - The hull's type picks the entity: a ship hull builds a Ship, a turret hull an OrbitalEntity with no orbit; a station hull is refused. Materialize now returns Entity. Loadouts.Resolve is the one rule for how a design is built; RunStart uses it for scenario cargo. LoadoutTests.MissingDesignReports no longer uses the product-less "Orphan" as a failure (it now builds); two tests pin the Q3 rule and the unavailable-product contract it does not loosen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
fbda4c74fb
commit
5706b657e3
2 changed files with 98 additions and 38 deletions
|
|
@ -264,13 +264,13 @@ public sealed class LoadoutTests : IDisposable
|
|||
Assert.Contains("1,1", failure);
|
||||
Assert.Contains("absent-design", failure);
|
||||
|
||||
missing.Slots.Add(new LoadoutSlot { Position = new int2(2, 2), Design = cache.RefOf<EquippableItemData>(cache.GetByName<GearData>("Orphan")) });
|
||||
missing.Slots.Add(new LoadoutSlot { Position = new int2(2, 2), Design = new CultRecordRef<EquippableItemData>(new CultRecordKey("another-absent-design")) });
|
||||
failures.Clear();
|
||||
Assert.Null(Build(items, missing, failures));
|
||||
Assert.Equal(2, failures.Count);
|
||||
Assert.Contains("slot 1,1", failures[0]);
|
||||
Assert.Contains("slot 2,2", failures[1]);
|
||||
Assert.Contains("no available product of Orphan", failures[1]);
|
||||
Assert.Contains("another-absent-design", failures[1]);
|
||||
}
|
||||
|
||||
Assert.Equal(before, new[] { Catalog, Run, Player }.Select(Hash).ToArray());
|
||||
|
|
@ -321,6 +321,34 @@ public sealed class LoadoutTests : IDisposable
|
|||
Assert.Contains("slot 0,0: no available product of Lamp", Assert.Single(failures));
|
||||
}
|
||||
|
||||
// Scenarios Q3 (docs/scenarios-cut.md): a design no product makes is outside the economy, and a preset builds it
|
||||
// unbranded -- no maker -- at the one named quality. "Orphan" has no product in this catalog.
|
||||
[Fact]
|
||||
public void ADesignWithNoProductBuildsUnbranded()
|
||||
{
|
||||
using var cache = Open();
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), RunSaveTests.TestSettings(), _ => { });
|
||||
var failures = new List<string>();
|
||||
var ship = Build(items, WithDesign(HandBuilt(cache), 0, cache, "Orphan"), failures);
|
||||
Assert.Empty(failures);
|
||||
var unit = ship.Equipment.Single(item => item.EquippableItem != ship.Hull && item.Position.Equals(HardpointCell)).EquippableItem;
|
||||
Assert.Equal("Orphan", items.GetData(unit).Name);
|
||||
Assert.Null(items.Brand(unit).Maker);
|
||||
Assert.Equal(Loadouts.UnbrandedQuality, items.GetLot(unit).Quality);
|
||||
}
|
||||
|
||||
// The existing contract Q3 does not loosen: a design that has a product, none of them available, is not built,
|
||||
// unbranded or otherwise.
|
||||
[Fact]
|
||||
public void ADesignWhoseOnlyProductIsUnavailableStillFails()
|
||||
{
|
||||
using var cache = Open();
|
||||
var items = new ItemManager(cache, new ProvenanceLedger(), RunSaveTests.TestSettings(), _ => { });
|
||||
var failures = new List<string>();
|
||||
Assert.Null(Loadouts.Materialize(items, null, HandBuilt(cache), p => p.Name != "Lamp by Maker", failures));
|
||||
Assert.Equal("slot 0,0: no available product of Lamp", Assert.Single(failures));
|
||||
}
|
||||
|
||||
// Census's duplicate (maker, design) detector exists precisely because this should never happen in an
|
||||
// authored catalog; Brand()'s tie-break is what a runtime item falls back on if it ever does, so it must stay
|
||||
// deterministic rather than however the cache happens to enumerate.
|
||||
|
|
@ -895,7 +923,7 @@ public sealed class LoadoutTests : IDisposable
|
|||
}
|
||||
|
||||
// Everything available: for tests about placement and failure lists.
|
||||
private static Ship Build(ItemManager items, Loadout loadout, List<string> failures) =>
|
||||
private static Entity Build(ItemManager items, Loadout loadout, List<string> failures) =>
|
||||
Loadouts.Materialize(items, null, loadout, _ => true, failures);
|
||||
|
||||
private static (int2, ItemRotation, CultRecordKey) Describe(LoadoutSlot slot) => (slot.Position, slot.Rotation, slot.Design.Key);
|
||||
|
|
|
|||
Loading…
Reference in a new issue