Merge origin/master into sensor-catalog-r2 (code; catalog is master's)
Conflicts: EvasionTermTests keeps the branch's EvLonginusDrive split with master's generic design names; AetherDb Program.cs keeps both the sensor-stat-set and generic-designs cases and lists both in the usage line. GameData/Aetheria.cc is taken from origin/master unchanged; sensor-stat-set apply is rerun on it in the next commit. Tests that read the sensor catalog (TheCatalogCarriesSensorStats and the roles checks) do not pass at this commit: it builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
005e2fc57b
103 changed files with 5392 additions and 668 deletions
|
|
@ -95,6 +95,106 @@ public sealed class CatalogRoleTests
|
|||
Assert.True(makerless.Length == 0, "products with no maker: " + string.Join(", ", makerless));
|
||||
}
|
||||
|
||||
// A design is named like a node on a tech tree and the brand lives in the product it sells (rulings
|
||||
// catalog-grows-generic-designs-branded-products, designs-are-tech-nodes): no design's product bears the design's name.
|
||||
[Fact]
|
||||
public void EveryProductCarriesABrand()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var products = cache.GetAll<FactionProductData>().ToArray();
|
||||
var unbranded = cache.GetAll<EquippableItemData>().Where(design => design is not HullData)
|
||||
.Where(design => products.Any(p => p.Design.Key.Equals(cache.RefOf(design).Key) && p.Name == design.Name))
|
||||
.Select(design => design.Name).OrderBy(n => n, StringComparer.Ordinal).ToArray();
|
||||
Assert.True(unbranded.Length == 0, "designs sold under their own name: " + string.Join(", ", unbranded));
|
||||
}
|
||||
|
||||
// The Capacitor is the one Tool design with a role map by name; a key that falls out of step with the design's name leaves
|
||||
// roles-backfill finding no map for it.
|
||||
[Fact]
|
||||
public void TheCapacitorDesignCarriesItsRoleMap()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var capacitor = cache.GetAll<EquippableItemData>().Single(design => design.Name == "Capacitor");
|
||||
Assert.True(Program.HasRoleMap(capacitor), "roles-backfill finds no role map for the Capacitor design");
|
||||
}
|
||||
|
||||
// A design is a tech node: its text may not name a product the catalog sells (the brand lives on the product).
|
||||
[Fact]
|
||||
public void NoDesignTextNamesAProduct()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var productNames = cache.GetAll<FactionProductData>().Select(p => p.Name).Where(n => n.Length > 3).ToHashSet();
|
||||
var branded = cache.GetAll<EquippableItemData>().Where(design => design is not HullData && design.Description != null)
|
||||
.Where(design => productNames.Any(n => design.Description.Contains(n)))
|
||||
.Select(design => design.Name).OrderBy(n => n, StringComparer.Ordinal).ToArray();
|
||||
Assert.True(branded.Length == 0, "designs whose text names a product: " + string.Join(", ", branded));
|
||||
}
|
||||
|
||||
// Authoring notes are not player text, and every product of a design this cut renamed or branded speaks in its own
|
||||
// voice (Miss Terri's and the Pirates' records are other passes').
|
||||
[Fact]
|
||||
public void NoProductTextIsAnAuthoringNote()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var products = cache.GetAll<FactionProductData>().ToArray();
|
||||
string[] notes = { Program.AuthoringNote.Trim(), "[TODO]", "subsidiary plight" };
|
||||
var noted = products.Where(p => p.Description != null && notes.Any(n => p.Description.Contains(n))).Select(p => p.Name).OrderBy(n => n, StringComparer.Ordinal).ToArray();
|
||||
Assert.True(noted.Length == 0, "products whose text is an authoring note: " + string.Join(", ", noted));
|
||||
|
||||
var touched = Program.Renames.Select(r => r.Generic).Concat(Program.Brands.Select(b => b.Design)).ToHashSet();
|
||||
var designs = cache.GetAll<EquippableItemData>().Where(d => touched.Contains(d.Name)).ToArray();
|
||||
Assert.Equal(touched.Count, designs.Length);
|
||||
var silent = products
|
||||
.Where(p => designs.Any(d => p.Design.Key.Equals(cache.RefOf(d).Key)))
|
||||
.Where(p => cache.Get(p.Manufacturer)?.ShortName is not ("Miss Terri's" or "Pirates"))
|
||||
.Where(p => string.IsNullOrWhiteSpace(p.Description))
|
||||
.Select(p => p.Name).OrderBy(n => n, StringComparer.Ordinal).ToArray();
|
||||
Assert.True(silent.Length == 0, "products with no text of their own: " + string.Join(", ", silent));
|
||||
}
|
||||
|
||||
// A rename changes Name and Description and nothing else: the design and its products keep their keys and makers, and the
|
||||
// flavour that moved lives on the product.
|
||||
[Fact]
|
||||
public void RenamedDesignsKeepTheirKeysAndProducts()
|
||||
{
|
||||
using var cache = RestoredHullsTests.OpenCatalog();
|
||||
var expected = new (string DesignKey, string Generic, (string Key, string Name, string Maker)[] Products)[]
|
||||
{
|
||||
("0271bb97-4ce8-4d64-97c3-8bfd3f76b2c6", "Light Machine Gun", new[] { ("7a1f63b0-68de-4976-a338-bc779db3386a", "ClearPath", "Lightsail") }),
|
||||
("3baa2c43-b389-4438-94cb-fbb04489cd77", "Heavy Reactor", new[] { ("1edd87f7-2592-4744-a9ba-618f403f91ce", "Manhattan", "Zhestokost") }),
|
||||
("49b4c15a-c10b-49c0-9dad-31dfb9b3a9b9", "Cargo Bay", new[] { ("4ecc97af-c1fa-4563-902e-72a094ad8322", "Store-All Plus", "Lightsail"), ("ed3c70eb23814d5181d99fa84f6194d4", null, "Pirates") }),
|
||||
("88e81a2b-45fd-49de-830f-c896adae8d5b", "Racing Drive", new[] { ("9ccc095374d64fde94dd8d04bdc97c2a", "Victoire", "Alakrita") }),
|
||||
("632420a6-4419-4647-a92b-5e22ea289025", "Lightning Projector", new[] { ("f0f8389f9dd64228b02a68392fcf4007", "DragOnBreath", "Lucent") }),
|
||||
};
|
||||
foreach (var (designKey, generic, sold) in expected)
|
||||
{
|
||||
var design = Assert.Single(cache.GetAll<EquippableItemData>(), d => cache.RefOf(d).Key.Value == designKey);
|
||||
Assert.Equal(generic, design.Name);
|
||||
Assert.Equal(Program.Renames.Single(r => r.Generic == generic).Functional, design.Description);
|
||||
var products = cache.GetAll<FactionProductData>().Where(p => p.Design.Key.Equals(cache.RefOf(design).Key)).ToArray();
|
||||
Assert.Equal(sold.Select(p => p.Key).OrderBy(k => k, StringComparer.Ordinal), products.Select(p => cache.RefOf(p).Key.Value).OrderBy(k => k, StringComparer.Ordinal));
|
||||
foreach (var (key, name, maker) in sold)
|
||||
{
|
||||
var product = products.Single(p => cache.RefOf(p).Key.Value == key);
|
||||
if (name != null) Assert.Equal(name, product.Name);
|
||||
Assert.Equal(maker, cache.Get(product.Manufacturer).ShortName);
|
||||
}
|
||||
}
|
||||
|
||||
// The text that moved: Victoire carries the racing drive's old line, DragOnBreath plight's old one.
|
||||
string TextOf(string productKey) => cache.GetAll<FactionProductData>().Single(p => cache.RefOf(p).Key.Value == productKey).Description;
|
||||
Assert.Equal("The most responsive thruster on the market, for the most irresponsible of racing pilots.", TextOf("9ccc095374d64fde94dd8d04bdc97c2a"));
|
||||
Assert.StartsWith("Chain lightning has your enemies chain smoking", TextOf("f0f8389f9dd64228b02a68392fcf4007"));
|
||||
|
||||
// The mine launcher: the design takes the functional line its product used to carry; the product is the brand.
|
||||
var mine = Assert.Single(cache.GetAll<EquippableItemData>(), d => cache.RefOf(d).Key.Value == "1b4a2bb358eb432eb1cfc0ccf3317303");
|
||||
Assert.Equal("Mine Launcher", mine.Name);
|
||||
Assert.Equal("Lays a drifting proximity mine that arms after two seconds.", mine.Description);
|
||||
var brand = Assert.Single(cache.GetAll<FactionProductData>(), p => p.Design.Key.Equals(cache.RefOf(mine).Key));
|
||||
Assert.Equal("parting gift", brand.Name);
|
||||
Assert.Equal("DME", cache.Get(brand.Manufacturer).ShortName);
|
||||
}
|
||||
|
||||
// A benefit rises with quality across 0.8x to 1.2x of its authored value (Max/Min 1.5), a cost falls across 1.2x to 0.8x
|
||||
// (Max/Min 2/3). The ratio and the role are pinned, not the value, so an operator retune of a design stays green.
|
||||
private static void AssertRange(EquippableItemData design, string field, bool cost, string role)
|
||||
|
|
@ -121,13 +221,13 @@ public sealed class CatalogRoleTests
|
|||
AssertRange(autocannon, "Range", false, "barrel");
|
||||
AssertRange(autocannon, "Penetration", false, "barrel");
|
||||
|
||||
var lrm = Design("LRMM72");
|
||||
var lrm = Design("Long-Range Missile Rack");
|
||||
Assert.Equal(new[] { "guidance system", "thruster", "warhead" }, Roles(lrm));
|
||||
AssertRange(lrm, "Damage", false, "warhead");
|
||||
AssertRange(lrm, "Cooldown", true, "guidance system");
|
||||
AssertRange(lrm, "LockAngle", false, "guidance system");
|
||||
|
||||
var srm = Design("SRMM72");
|
||||
var srm = Design("Short-Range Missile Rack");
|
||||
Assert.Equal(new[] { "guidance system", "thruster", "warhead" }, Roles(srm));
|
||||
AssertRange(srm, "Damage", false, "warhead");
|
||||
AssertRange(srm, "Cooldown", true, "guidance system");
|
||||
|
|
@ -152,12 +252,12 @@ public sealed class CatalogRoleTests
|
|||
AssertRange(Design("Small Drive"), "Thrust", false, "nozzle");
|
||||
|
||||
// Designs whose non-flat stats named no role are pointed at the role their kind's map gives them.
|
||||
AssertNamed(Design("DeathCluster"), "Count", "feed mechanism");
|
||||
AssertNamed(Design("Cluster Cannon"), "Count", "feed mechanism");
|
||||
AssertNamed(Design("Flak Gun"), "Count", "feed mechanism");
|
||||
AssertNamed(Design("GT 3K"), "MinRange", "guidance system");
|
||||
AssertNamed(Design("plight"), "DamageSpread", "focusing array");
|
||||
AssertNamed(Design("MoveOnPro"), "Modifier", "core");
|
||||
AssertNamed(Design("MoveOnPro Station Reactor"), "Modifier", "core");
|
||||
AssertNamed(Design("Guided Missile Launcher"), "MinRange", "guidance system");
|
||||
AssertNamed(Design("Lightning Projector"), "DamageSpread", "focusing array");
|
||||
AssertNamed(Design("Muon Fusion Reactor"), "Modifier", "core");
|
||||
AssertNamed(Design("Muon Fusion Station Reactor"), "Modifier", "core");
|
||||
|
||||
// Each seller's means come from its maker's profile; the Pirates are middling and inconsistent.
|
||||
var profiles = new Dictionary<string, (float Mean, float Dev)>
|
||||
|
|
|
|||
Loading…
Reference in a new issue