Shields are on sale: shield roles, shield-catalog, and the census pinned at zero

A Light (1x1) and a Heavy (2x2) Shield Projector, each sold by two makers, authored through shield-catalog apply
(ShieldRoles lets CB-R1 cover them). Every hardpoint the game boots now takes a sold design; the Wren exception
assertion is gone. The heavy projector's Zhestokost product is 'Redoubt' (Rampart and Bulwark are taken).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-27 17:21:03 +01:00
commit d4d5ca40d2
7 changed files with 243 additions and 5 deletions

5
.changeset/shields.md Normal file
View file

@ -0,0 +1,5 @@
---
default: patch
---
Shields are on sale: a light 1x1 and a heavy 2x2 projector fit the Djinni's and the Nakovalnya's shield mounts and every starter ship's, and the Zenith's fourth radiator mount takes radiators again.

BIN
GameData/Aetheria.cc (Stored with Git LFS)

Binary file not shown.

View file

@ -6,6 +6,14 @@ using Xunit;
// design some product sells. Program.UnfillableHardpoints is the one census, over HardpointData.Takes, the one fit rule.
public sealed class HardpointFitTests
{
// Every hardpoint on every hull the game boots (shipped catalog plus GameData/Mods) takes a design some product sells.
[Fact]
public void EveryHardpointTheGameBootsTakesASoldDesign()
{
using var cache = RestoredHullsTests.OpenCatalog();
Assert.Empty(Program.UnfillableHardpoints(cache));
}
// The census is over the catalog the game boots, packages included: a package hull's mount is as fillable as a shipped one.
[Fact]
public void TheCensusReadsThePackagesTheGameBoots()

View file

@ -0,0 +1,51 @@
using System.Linq;
using GameCult.Caching;
using Xunit;
// The shields the catalog sells (campaign aetheria-release, cut hardpoint-fit-1; rulings hardpoint-sizes-are-footprint-palette,
// catalog-grows-generic-designs-branded-products): a light 1x1 and a heavy 2x2 projector, each with a product a maker offers, and
// the fit they give the mounts the game boots. Prices and stats are starting knobs, so none is pinned here.
public sealed class ShieldCatalogTests
{
private static GearData Design(CultCache cache, string name) => Assert.Single(cache.GetAll<GearData>(), g => g.Name == name);
private static FactionProductData[] Offered(CultCache cache, GearData design) =>
cache.GetAll<FactionProductData>().Where(p => p.Design.Key.Equals(cache.RefOf(design).Key) && !p.NotOffered).ToArray();
[Theory]
[InlineData(ShieldCatalog.Light, 1)]
[InlineData(ShieldCatalog.Heavy, 2)]
public void EachProjectorIsAShieldOfItsFootprintWithAnOfferedProduct(string name, int size)
{
using var cache = RestoredHullsTests.OpenCatalog();
var design = Design(cache, name);
Assert.Equal(HardpointType.Shield, design.Hardpoint);
Assert.Equal((size, size), (design.Shape.Width, design.Shape.Height));
Assert.Equal(size * size, design.Shape.Coordinates.Length);
var shield = Assert.Single(design.Behaviors.OfType<ShieldData>());
Assert.True(shield.Capacity.Min > 0f && shield.Capacity.Max > 0f, "a shield with no capacity breaks on its first hit");
Assert.NotEmpty(Offered(cache, design));
}
[Fact]
public void MegiddoSellsTheHeavyProjector()
{
using var cache = RestoredHullsTests.OpenCatalog();
Assert.Contains(Offered(cache, Design(cache, ShieldCatalog.Heavy)), p => cache.Get(p.Manufacturer).ShortName == "Megiddo");
}
// Loose fit: the light projector serves a 1x1 shield mount, the heavy one fills every 2x2 shield mount of the booted hulls.
[Fact]
public void TheProjectorsFitTheMountsTheGameBoots()
{
using var cache = RestoredHullsTests.OpenCatalogWithFixtures();
var light = Design(cache, ShieldCatalog.Light);
var heavy = Design(cache, ShieldCatalog.Heavy);
var mounts = cache.GetAll<HullData>().SelectMany(h => h.Hardpoints).Where(m => m.Type == HardpointType.Shield).ToArray();
Assert.Contains(mounts, m => m.Shape.Coordinates.Length == 1);
Assert.Contains(mounts, m => m.Shape.Coordinates.Length == 4);
Assert.All(mounts, m => Assert.True(m.Takes(light) || m.Takes(heavy)));
Assert.All(mounts.Where(m => m.Shape.Coordinates.Length == 1), m => Assert.True(m.Takes(light) && !m.Takes(heavy)));
Assert.All(mounts.Where(m => m.Shape.Coordinates.Length == 4), m => Assert.True(m.IsFilledBy(heavy) && m.Takes(light)));
}
}

View file

@ -50,8 +50,7 @@ public sealed class WrenPackageTests
using var cache = RestoredHullsTests.OpenCatalogWithFixtures();
var designs = cache.GetAll<EquippableItemData>().ToArray();
var bare = Wren(cache).Hardpoints.Where(hardpoint => !designs.Any(hardpoint.Takes)).Select(hardpoint => $"{hardpoint.Transform} ({hardpoint.Type})").ToArray();
// No shield design fits a 1x1 yet (hardpoint-fit lists Djinni's 4-cell shield with none either); every other mount does.
Assert.Equal(new[] { "internal.shield (Shield)" }, bare);
Assert.Empty(bare);
}
[Fact]

View file

@ -25,6 +25,14 @@ public static class Program
case "census": return Census();
case "station-fit": return StationFit();
case "hardpoint-fit": return HardpointFit();
case "shield-catalog":
{
var apply = args.Contains("apply");
using var db = AetherDb.Open(catalogWritable: apply);
var code = ShieldCatalog.Run(db.Cache, apply, Console.Out);
if (apply) db.Cache.FlushAsync().GetAwaiter().GetResult();
return code;
}
case "hardpoint-rotation": return HardpointRotationCommand.Run(args.Skip(1).ToArray());
case "loadout": return Loadout(args.Skip(1).ToArray());
case "loadout-commit": return LoadoutCommitCommand.Run(args.Skip(1).ToArray());
@ -82,7 +90,7 @@ public static class Program
case "auto-guns": return AutoGunsCatalog.Run(AetherDb.Open(catalogWritable: args.Contains("apply")).Cache, args.Contains("apply"), Console.Out);
case "doctrine-catalog": return DoctrineCatalog.Run(AetherDb.Open(catalogWritable: args.Contains("apply")).Cache, args.Contains("apply"), Console.Out);
default:
Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, hardpoint-rotation \"<hull>\" <x>,<y> <rotation> [apply], loadout [seed], loadout-commit <name> <hull product> [<x>,<y>,<rotation>,<design>[@<product>]]... [--group <i>,<j>...]... [--replace] [--boss-of <faction>], save, settings, settings-dump, dangling [clear <Type.Member>]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], range-falloff [apply] [--effective <fraction>] [--end <multiplier>], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, mine-launcher [apply], smoke-hull [apply], smoke-rounds [apply], roles-backfill [apply], pd-gear [apply], consumables-first-set [apply], launch-suppressor [apply], pirates-faction [apply], verse-grammar [apply], generic-designs [apply], sensor-stat-set [apply], inspection-scanner [apply], minor-power-factions [apply], place-names [apply], product-lines weapons|minor-powers|gear|tiers [apply], doctrine-catalog [apply], auto-guns [apply], assembly-from-maker [apply], station-kinds [hull \"<name>\" <kind>] [apply], economy report|prices|author <batch>... [apply]|balance");
Console.WriteLine("commands: census, factions, station-fit, hardpoint-fit, hardpoint-rotation \"<hull>\" <x>,<y> <rotation> [apply], loadout [seed], loadout-commit <name> <hull product> [<x>,<y>,<rotation>,<design>[@<product>]]... [--group <i>,<j>...]... [--replace] [--boss-of <faction>], save, settings, settings-dump, dangling [clear <Type.Member>]... [apply], shield-migrate [apply], brownout-migrate [apply], roles-migrate [apply], firing-arc-migrate [apply], range-falloff [apply] [--effective <fraction>] [--end <multiplier>], targeting-catalog [apply], targeting-catalog-6c [apply], targeting-catalog-6d [apply], ship-authoring create|inspect|validate|compose, mine-launcher [apply], smoke-hull [apply], smoke-rounds [apply], roles-backfill [apply], pd-gear [apply], consumables-first-set [apply], launch-suppressor [apply], pirates-faction [apply], verse-grammar [apply], generic-designs [apply], sensor-stat-set [apply], inspection-scanner [apply], minor-power-factions [apply], place-names [apply], product-lines weapons|minor-powers|gear|tiers [apply], doctrine-catalog [apply], auto-guns [apply], assembly-from-maker [apply], shield-catalog [apply], station-kinds [hull \"<name>\" <kind>] [apply], economy report|prices|author <batch>... [apply]|balance");
return 1;
}
}
@ -256,6 +264,15 @@ public static class Program
["Heat"] = "injector", ["EnergyUsage"] = "injector",
};
// A shield's emitter sets how much of a hit it turns, the reservoir how much it can take, the regulator how it spends
// and recovers energy.
private static readonly Dictionary<string, string> ShieldRoles = new Dictionary<string, string>
{
["Efficiency"] = "emitter",
["Capacity"] = "reservoir",
["EnergyUsage"] = "regulator", ["RefillDuration"] = "regulator", ["RestoreDuration"] = "regulator",
};
private static readonly Dictionary<string, string> HullShipRoles = new Dictionary<string, string>
{
["CrossSection"] = "plating",
@ -315,6 +332,7 @@ public static class Program
"Radiator" => RadiatorRoles,
"Reactor" => ReactorRoles,
"Sensors" => SensorRoles,
"Shield" => ShieldRoles,
"Thruster" => ThrusterRoles,
_ when kind == "Hull/Ship" => HullShipRoles,
"Tool" => ToolRolesByDesign.TryGetValue(item.Name, out var byName) ? byName : null,

View file

@ -0,0 +1,157 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using GameCult.Caching;
// Puts shields on sale (campaign aetheria-release, cut hardpoint-fit-1; rulings catalog-grows-generic-designs-branded-products,
// designs-are-tech-nodes, hardpoint-sizes-are-footprint-palette, gear-ladder-wide-by-rare-inputs): two generic Shield designs,
// a Light Shield Projector (1x1) and a Heavy Shield Projector (2x2), each sold by two makers. Loose fit lets the light one
// serve the starter's 1x1 mount and the heavy one fill the Djinni's and the Nakovalnya's 2x2 mounts. Every stat is one linear
// Quality term on its ShieldRoles role (Min at quality 0, Max at quality 1); prices and stats are starting knobs, sim-tuned later.
// Recipes wait on aetheria-living-world:follow_up:design-bills-of-materials. Every record is keyed by its name, so the same
// apply replays byte-identically at a merge. Dry run unless apply; a catalog that is neither untouched nor fully authored is refused.
public static class ShieldCatalog
{
public const string Light = "Light Shield Projector";
public const string Heavy = "Heavy Shield Projector";
private const string Emitter = "emitter", Reservoir = "reservoir", Regulator = "regulator";
private sealed record Design(string Name, string Description, int Size, float Mass, float Durability, int Price,
(float Min, float Max) Efficiency, (float Min, float Max) EnergyUsage, (float Min, float Max) Capacity,
(float Min, float Max) RefillDuration, (float Min, float Max) RestoreDuration);
private static readonly Design[] Designs =
{
new(Light, "A compact emitter and reservoir that wraps a hull in a field it spends energy to hold. Small enough for any mount.",
1, 120f, 100f, 3000, (.05f, .15f), (8f, 4f), (60f, 180f), (8f, 4f), (24f, 12f)),
new(Heavy, "A broad-aperture projector with a deep reservoir: it soaks heavy fire, and takes its time coming back when overwhelmed.",
2, 420f, 250f, 34000, (.05f, .2f), (8f, 3f), (180f, 520f), (12f, 5f), (34f, 16f)),
};
private static readonly (string Name, string Design, string Maker, string Description)[] Products =
{
("Umbrella", Light, "AU", "Shade for one hull: a small field, held steadily, and no one aboard has to think about it."),
("Awning", Light, "Aya", "Draws out over the bow like cloth on a pole. It will not stop a siege and was never meant to."),
("Migdal", Heavy, "Megiddo", "The tower the fleet stands behind. Megiddo sells it as a promise and builds it to keep one."),
("Redoubt", Heavy, "Zhestokost", "A wall of field, thrown up crudely and sold cheaply to those who expect to be shot at."),
};
// A record's key is derived from its name: the same table lands the same records every time it is applied.
private static CultRecordKey KeyOf(string name) =>
new(new Guid(SHA256.HashData(Encoding.UTF8.GetBytes("shield-catalog:" + name)).AsSpan(0, 16)).ToString("N"));
private static PerformanceStat Rolled((float Min, float Max) range, string role) => new PerformanceStat
{
Min = range.Min,
Max = range.Max,
Terms = new List<StatTerm> { new StatTerm { Source = StatSource.Quality, Exponent = 1f, Role = role } },
};
private static GearData Build(Design row)
{
var design = new GearData
{
Name = row.Name,
Description = row.Description,
Hardpoint = HardpointType.Shield,
Mass = row.Mass,
Price = row.Price,
Durability = row.Durability,
Shape = new Shape(row.Size, row.Size),
// Thermal fields from content-batch-one 4a.
SpecificHeat = 2f,
Conductivity = 4f,
ThermalResilience = 8f,
MinimumTemperature = 173.15f,
MaximumTemperature = 573.15f,
OptimalTemperature = 258.15f,
PlateauWidth = 84f,
Roles = new[] { Emitter, Reservoir, Regulator }.Select(r => new ItemRole { Name = r }).ToList(),
Behaviors = new List<BehaviorData>
{
new ShieldData
{
Efficiency = Rolled(row.Efficiency, Emitter),
EnergyUsage = Rolled(row.EnergyUsage, Regulator),
Capacity = Rolled(row.Capacity, Reservoir),
RefillDuration = Rolled(row.RefillDuration, Regulator),
RestoreDuration = Rolled(row.RestoreDuration, Regulator),
},
},
};
for (var x = 0; x < row.Size; x++)
for (var y = 0; y < row.Size; y++)
design.Shape.Cells[x, y] = true;
return design;
}
public static int Run(CultCache cache, bool apply, TextWriter output)
{
Faction Maker(string shortName) =>
cache.GetAll<Faction>().FirstOrDefault(f => f.ShortName == shortName) ?? throw new InvalidOperationException($"No faction with short name \"{shortName}\".");
foreach (var product in Products) Maker(product.Maker);
// Authored when every design and product is present under its key; untouched when none is; anything between needs a human.
var keys = Designs.Select(d => KeyOf(d.Name)).Concat(Products.Select(p => KeyOf(p.Name))).ToArray();
var held = cache.GetAll<EquippableItemData>().Select(d => cache.RefOf(d).Key)
.Concat(cache.GetAll<FactionProductData>().Select(p => cache.RefOf(p).Key)).ToHashSet();
var present = keys.Count(held.Contains);
var names = Designs.Select(d => d.Name).Concat(Products.Select(p => p.Name)).ToHashSet();
var strangers = cache.GetAll<EquippableItemData>().Select(d => d.Name).Concat(cache.GetAll<FactionProductData>().Select(p => p.Name))
.Count(names.Contains);
if (present == keys.Length)
{
output.WriteLine("The shield designs are already authored; nothing to do.");
return 0;
}
if (present != 0 || strangers != 0)
throw new InvalidOperationException("The shield designs are partly authored, or their names belong to other items; the catalog needs a human.");
var designs = Designs.Select(d => (Row: d, Gear: Build(d))).ToArray();
output.WriteLine("New designs:");
foreach (var (_, gear) in designs)
{
var data = gear.Behaviors.OfType<ShieldData>().Single();
output.WriteLine($" {gear.Name} {gear.Shape.Width}x{gear.Shape.Height} {gear.Hardpoint} mass {gear.Mass:0.##} price {gear.Price} durability {gear.Durability:0.##} roles [{string.Join(", ", gear.Roles.Select(r => r.Name))}]");
foreach (var (label, stat) in new[] { ("Efficiency", data.Efficiency), ("EnergyUsage", data.EnergyUsage), ("Capacity", data.Capacity), ("RefillDuration", data.RefillDuration), ("RestoreDuration", data.RestoreDuration) })
output.WriteLine($" {label} {stat.Min:0.##}-{stat.Max:0.##} ({stat.Terms.Single().Role})");
}
output.WriteLine("\nNew products:");
foreach (var (name, design, maker, description) in Products)
{
var (mean, dev) = Program.MakerProfiles[maker];
output.WriteLine($" {design} -> \"{name}\" by {maker}, mean {mean:0.##} dev {dev:0.##}: {description}");
}
if (!apply)
{
output.WriteLine($"\nDry run. Pass \"apply\" to author {Designs.Length} designs and {Products.Length} products.");
return 0;
}
foreach (var (_, gear) in designs) CultRecordRefs.Validate(gear);
// The batch lands onto the file as it is, expecting every key it authors to be absent (ProductLinesCommand's contract).
if (!cache.Commit(batch =>
{
foreach (var key in keys) batch.Expect(key, null);
foreach (var (row, gear) in designs) batch.Upsert(typeof(GearData), gear, KeyOf(row.Name));
foreach (var (name, design, maker, description) in Products)
{
var (mean, dev) = Program.MakerProfiles[maker];
batch.Upsert(typeof(FactionProductData), new FactionProductData
{
Name = name,
Description = description,
Design = new CultRecordRef<CraftedItemData>(KeyOf(design)),
Manufacturer = cache.RefOf(Maker(maker)),
Roles = new[] { Emitter, Reservoir, Regulator }.Select(r => new ProductRole { Role = r, Mean = mean, StandardDeviation = dev }).ToList(),
}, KeyOf(name));
}
}))
throw new InvalidOperationException("The catalog changed while the shields were being authored; nothing was written. Run it again.");
output.WriteLine($"\nAuthored {Designs.Length} designs and {Products.Length} products in Aetheria.cc");
return 0;
}
}