From 6b602dd34a964ae7f139d668c0870b5b2676d78d Mon Sep 17 00:00:00 2001
From: Meta Vens
Date: Sun, 18 Oct 2026 17:54:52 +0200
Subject: [PATCH] ship-authoring boss on|off sets HullData.Boss on a package
hull
Judged before the file is touched, touches no product; inspect prints
", boss" when set. Tests: the command, and the package path through compose.
Co-Authored-By: Claude Sonnet 5.5
---
.../Aetheria.Shared.Tests/ShipProductTests.cs | 50 +++++++++++++++++++
tools/AetherDb/ShipAuthoringCommands.cs | 19 ++++++-
2 files changed, 67 insertions(+), 2 deletions(-)
diff --git a/tests/Aetheria.Shared.Tests/ShipProductTests.cs b/tests/Aetheria.Shared.Tests/ShipProductTests.cs
index f6f3bad10..a88a2541d 100644
--- a/tests/Aetheria.Shared.Tests/ShipProductTests.cs
+++ b/tests/Aetheria.Shared.Tests/ShipProductTests.cs
@@ -99,6 +99,25 @@ public sealed class ShipProductTests : IDisposable
}
}
+ // The package path of the derivation: the flag survives compose on the hull, and the maker is the package's product's.
+ [Fact]
+ public void ABossPackageIsItsMakersBossAfterCompose()
+ {
+ Environment.CurrentDirectory = _root.Path;
+ var path = Package("mod.boss", "Bosshull", 100, Product("Acme Boss", _acme, "mod.boss"));
+ Assert.Equal(0, Run("boss", path, "on").Code);
+ var composition = ShipModCatalog.Compose(Shipped, Derived, Mods);
+ Assert.Equal(new[] { "mod.boss" }, composition.Included);
+
+ using var cache = AetheriaStores.Open(Derived);
+ var hull = Assert.IsType(cache.Get(new CultRecordRef(ShipModCatalog.HullKey("mod.boss"))));
+ Assert.True(hull.Boss);
+ var acme = cache.Get(_acme);
+ var rival = cache.Get(_rival);
+ Assert.Same(hull, Assert.Single(LoadoutGenerator.BossHullsOf(cache, acme)).hull);
+ Assert.Empty(LoadoutGenerator.BossHullsOf(cache, rival));
+ }
+
[Fact]
public void APackageWithAnUnknownMakerIsExcluded()
{
@@ -299,6 +318,37 @@ public sealed class ShipProductTests : IDisposable
RefusedAndUntouched("product", path, "ACM", "--remove");
}
+ [Fact]
+ public void BossCommand()
+ {
+ Environment.CurrentDirectory = _root.Path;
+ var path = Package("mod.skiff", "Skiffhull", 100, Product("Acme Skiff", _acme, "mod.skiff"));
+ void RefusedAndUntouched(params string[] args)
+ {
+ var before = File.ReadAllBytes(path);
+ Assert.Equal(1, Run(args).Code);
+ Assert.Equal(before, File.ReadAllBytes(path));
+ }
+ var options = CultDocumentMessagePackSerialization.OptionsFor(typeof(FactionProductData).Assembly);
+ byte[] ProductBytes() => MessagePack.MessagePackSerializer.Serialize(ShipAuthoringStore.Load(path).Products.Single(), options);
+
+ var productBefore = ProductBytes();
+ Assert.False(ShipAuthoringStore.Read(path).Hull.Boss);
+ RefusedAndUntouched("boss", path, "yes");
+ RefusedAndUntouched("boss", path, "ON");
+ RefusedAndUntouched("boss", path);
+
+ Assert.Equal(0, Run("boss", path, "on").Code);
+ Assert.True(ShipAuthoringStore.Read(path).Hull.Boss);
+ Assert.Equal(productBefore, ProductBytes());
+ Assert.Contains(", boss", Run("inspect", path).Output);
+
+ Assert.Equal(0, Run("boss", path, "off").Code);
+ Assert.False(ShipAuthoringStore.Read(path).Hull.Boss);
+ Assert.Equal(productBefore, ProductBytes());
+ Assert.DoesNotContain(", boss", Run("inspect", path).Output);
+ }
+
[Fact]
public void ValidateJudgesProductsOnADraftAndInspectListsThem()
{
diff --git a/tools/AetherDb/ShipAuthoringCommands.cs b/tools/AetherDb/ShipAuthoringCommands.cs
index 9fd7e690a..769db37dc 100644
--- a/tools/AetherDb/ShipAuthoringCommands.cs
+++ b/tools/AetherDb/ShipAuthoringCommands.cs
@@ -8,7 +8,7 @@ using System.Linq;
// Uses the existing database executable; mod authoring does not earn another binary target.
public static class ShipAuthoringCommands
{
- private const string Usage = "ship-authoring create [--like ] | inspect | centre | validate | product (--name [--description ] | --remove) | price | compose ";
+ private const string Usage = "ship-authoring create [--like ] | inspect | centre | validate | product (--name [--description ] | --remove) | price | boss on|off | compose ";
public static int Run(string[] args)
{
@@ -29,7 +29,7 @@ public static class ShipAuthoringCommands
if (args[0] == "inspect" && args.Length == 2)
{
var (hull, ship, products) = ShipAuthoringStore.Load(args[1]);
- Console.WriteLine($"{ship.Id}: {hull.Name}, {hull.Hardpoints?.Count ?? 0} hardpoints, {ship.SchematicLines?.Count ?? 0} lines, {ship.SchematicLines?.Sum(line => line.Points?.Length / 3 ?? 0) ?? 0} points");
+ Console.WriteLine($"{ship.Id}: {hull.Name}, {hull.Hardpoints?.Count ?? 0} hardpoints, {ship.SchematicLines?.Count ?? 0} lines, {ship.SchematicLines?.Sum(line => line.Points?.Length / 3 ?? 0) ?? 0} points{(hull.Boss ? ", boss" : "")}");
foreach (var product in products) Console.WriteLine($"product {product.Manufacturer.Key.Value}: {product.Name}");
return 0;
}
@@ -91,6 +91,21 @@ public static class ShipAuthoringCommands
Console.WriteLine($"{ship.Id}: price {price}.");
return 0;
}
+ if (args[0] == "boss" && args.Length == 3)
+ {
+ // Judged before the file is touched: a refusal leaves it byte-identical. Sets the hull's flag and no product.
+ if (args[2] != "on" && args[2] != "off")
+ throw new InvalidOperationException("boss must be on or off.");
+ var (hull, ship, _) = ShipAuthoringStore.Load(args[1]);
+ hull.Boss = args[2] == "on";
+ using (var cache = ShipAuthoringStore.Open(args[1], writable: true))
+ {
+ ShipAuthoringStore.Write(cache, hull, ship);
+ cache.FlushAsync().Wait();
+ }
+ Console.WriteLine($"{ship.Id}: boss {args[2]}.");
+ return 0;
+ }
if (args[0] == "product" && args.Length >= 4)
{
var remove = args.Length == 4 && args[3] == "--remove";