diff --git a/tests/Aetheria.Shared.Tests/ShipProductTests.cs b/tests/Aetheria.Shared.Tests/ShipProductTests.cs index bb358c4df..343f35082 100644 --- a/tests/Aetheria.Shared.Tests/ShipProductTests.cs +++ b/tests/Aetheria.Shared.Tests/ShipProductTests.cs @@ -353,8 +353,6 @@ public sealed class ShipProductTests : IDisposable RefusedAndUntouched(path, "--mass", "5", "--mass", "6"); // A valid flag beside a bad one writes nothing. RefusedAndUntouched(path, "--mass", "5", "--durability", "-2"); - RefusedAndUntouched(bare, "--top-speed", "50"); - RefusedAndUntouched(bare, "--mass", "5", "--top-speed", "50"); // Two VelocityLimits leave no one top speed to set. RefusedAndUntouched(twin, "--top-speed", "50"); @@ -385,6 +383,15 @@ public sealed class ShipProductTests : IDisposable Assert.Equal((1f, 0f, 8000f), (ShipAuthoringStore.Load(path).Hull.Mass, ShipAuthoringStore.Load(path).Hull.Drag, ShipAuthoringStore.Load(path).Hull.Durability)); Assert.Equal(0, Run("stats", bare, "--armor", "12").Code); Assert.Equal(12f, ShipAuthoringStore.Load(bare).Hull.Armor); + + // A hull with no VelocityLimit gets exactly one from --top-speed, the only way a hull made without --like can + // satisfy validate; a second run edits that one rather than adding another. + Assert.Empty(ShipAuthoringStore.Load(bare).Hull.Behaviors.OfType()); + Assert.Equal(0, Run("stats", bare, "--mass", "5", "--top-speed", "50").Code); + Assert.Equal(0, Run("stats", bare, "--top-speed", "60").Code); + var added = Assert.Single(ShipAuthoringStore.Load(bare).Hull.Behaviors.OfType()).TopSpeed; + Assert.Equal((60f, 60f), (added.Min, added.Max)); + Assert.Equal(5f, ShipAuthoringStore.Load(bare).Hull.Mass); } [Fact] diff --git a/tools/AetherDb/ShipAuthoringCommands.cs b/tools/AetherDb/ShipAuthoringCommands.cs index bce7eda08..841da957e 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 ] [--not-offered] | --remove) | price | stats [--mass m] [--durability d] [--armor a] [--drag x] [--top-speed v] | compose "; + private const string Usage = "ship-authoring create [--like ] | starter --like | inspect | centre | validate | product (--name [--description ] [--not-offered] | --remove) | price | stats [--mass m] [--durability d] [--armor a] [--drag x] [--top-speed v] | compose "; private static readonly string[] StatFlags = { "--mass", "--durability", "--armor", "--drag", "--top-speed" }; @@ -78,6 +78,12 @@ public static class ShipAuthoringCommands Console.WriteLine($"Created draft {path}; fill its model bindings and schematic in Blender."); return 0; } + if (args[0] == "starter" && args.Length == 6 && args[4] == "--like") + { + var path = ShipStarterCommand.Write(args[1], args[2], args[3], ShippedShipHull(args[5])); + Console.WriteLine($"Wrote a flyable starter package {path}; replace its stand-in model through Blender and Package, then set price and product."); + return 0; + } if (args[0] == "price" && args.Length == 3) { // Judged before the file is touched: a refusal leaves it byte-identical. @@ -111,7 +117,13 @@ public static class ShipAuthoringCommands if (stats.TryGetValue("--top-speed", out var topSpeed)) { var limits = (hull.Behaviors ?? new List()).OfType().ToArray(); - if (limits.Length != 1) throw new InvalidOperationException($"{ship.Id}: --top-speed needs exactly one VelocityLimit on the hull; it has {limits.Length}."); + if (limits.Length > 1) throw new InvalidOperationException($"{ship.Id}: --top-speed needs at most one VelocityLimit on the hull; it has {limits.Length}."); + // A hull made without --like has none, and this is its only way to get one: validate refuses a ship without a top speed. + if (limits.Length == 0) + { + limits = new[] { new VelocityLimitData() }; + (hull.Behaviors ??= new List()).Add(limits[0]); + } // A fixed top speed, as every shipped hull authors one (Min equal to Max); its terms are kept. limits[0].TopSpeed.Min = limits[0].TopSpeed.Max = topSpeed; }