From fa6e63f8d794761d9d864afa5635ef8520b5b4ae Mon Sep 17 00:00:00 2001 From: soul Date: Sat, 28 Nov 2026 17:33:46 +0100 Subject: [PATCH] Pursuit and Arcs: restock each shooter to its measured 600 s draw plus half again, capped at its hold A conducting hull never dies of heat, so a hold-down fires the whole window (draws 4-5x the heat-death stocks). Neither Pursuit hold nor the Arcs holds carry the draw, so they are stocked full; the test now asks stocked to the draw, or the hold takes no more of that ammunition. Co-Authored-By: Claude Sonnet 5.5 --- Assets/Scripts/ServerShared/Scenarios/Arcs.cs | 9 +++--- .../Scripts/ServerShared/Scenarios/Pursuit.cs | 11 +++---- .../ScenarioAmmunitionRunTests.cs | 30 +++++++++++++------ 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/Assets/Scripts/ServerShared/Scenarios/Arcs.cs b/Assets/Scripts/ServerShared/Scenarios/Arcs.cs index 6da63b0e2..a9fe6b493 100644 --- a/Assets/Scripts/ServerShared/Scenarios/Arcs.cs +++ b/Assets/Scripts/ServerShared/Scenarios/Arcs.cs @@ -21,10 +21,11 @@ public sealed class Arcs : Scenario public static readonly CultMath.float2 Bow = float2(0, 400), Stern = float2(0, -400), Turret = float2(600, 300), Port = float2(-400, 0), Starboard = float2(400, 0); - // Crates of ammunition each shooter's hold is stocked with: the measured draw over a run (ScenarioAmmunitionRunTests: at most ten minutes of play, and in - // practice the ~260 s a shooter holding every gun down lasts before it dies of heat; a pilot who vents heat is unmeasured) plus half again and one. The turret drew 14 Ammo with the player in its range; the player drew 27 Ammo - // holding every gun down. The guided launchers fire only on a lock, which that run cannot give them, so they carry the default three crates. - public const int TurretAmmoCrates = 22, PlayerAmmoCrates = 42, PlayerMissileCrates = 3; + // Crates of ammunition each shooter's hold is stocked with: the measured draw over the 600 s run of ScenarioAmmunitionRunTests (a hull conducts heat + // from construction, so a shooter holding every gun down no longer dies of heat at ~260 s) plus half again, capped at what the hold carries. + // Measured draws: turret 110 Ammo (its hold fills at 80 crates), player 230 Ammo (its hold fills at 75 Ammo and 3 Missiles). Neither hold carries its draw, so each is + // stocked full and runs dry. The guided launchers fire only on a lock, which that run cannot give them, so they carry the default three crates. + public const int TurretAmmoCrates = 80, PlayerAmmoCrates = 75, PlayerMissileCrates = 3; public override Galaxy Generate(GalaxyStage stage) => stage.Cast(DemoTerminus.Cast); diff --git a/Assets/Scripts/ServerShared/Scenarios/Pursuit.cs b/Assets/Scripts/ServerShared/Scenarios/Pursuit.cs index 7bde23745..54e48df74 100644 --- a/Assets/Scripts/ServerShared/Scenarios/Pursuit.cs +++ b/Assets/Scripts/ServerShared/Scenarios/Pursuit.cs @@ -8,11 +8,12 @@ public sealed class Pursuit : Scenario // cloud breaking a sensor's lock, and well outside the 40 at which AStrongCloseSensorBurnsThrough shows a close // sensor burning through. private const float Astern = 300; - // Crates each shooter's hold is stocked with: the measured draw over a run (ScenarioAmmunitionRunTests: at most ten minutes of play, and in - // practice the ~250-270 s a shooter holding every gun down lasts before it dies of heat; a pilot who vents heat is unmeasured) plus half again and one where the hold has room. The player laid four crates of Mines and drew - // 33 Ammo; its hold takes 54 crates after five consumables and Mines, so its Ammo stops at 39. The pursuer drew 31 Ammo and one Missiles. A launcher - // that drew under a reload carries the default three crates. - public const int MineCrates = 7, PlayerAmmoCrates = 39, PlayerMissileCrates = 3, PursuerAmmoCrates = 47, PursuerMissileCrates = 3; + // Crates each shooter's hold is stocked with: the measured draw over the 600 s run of ScenarioAmmunitionRunTests (a hull conducts heat from + // construction, so a shooter holding every gun down no longer dies of heat at ~250-270 s and fires the whole window) plus half again, capped at + // what the hold carries. Measured draws: pursuer 199 Ammo and 14 Missiles; player 42 Mines and 195 Ammo. Neither hold carries its draw + // (the pursuer's hold fills at 75 Ammo and 5 Missiles, the player's after five consumables at 10 Mines, 40 Ammo and 3 Missiles; crates differ in size), so each is + // stocked full and runs dry. A launcher that drew under a reload carries the default three crates. + public const int MineCrates = 10, PlayerAmmoCrates = 40, PlayerMissileCrates = 3, PursuerAmmoCrates = 75, PursuerMissileCrates = 5; public override string Name => "Pursuit"; public override string Id => "pursuit"; diff --git a/tests/Aetheria.Shared.Tests/ScenarioAmmunitionRunTests.cs b/tests/Aetheria.Shared.Tests/ScenarioAmmunitionRunTests.cs index 43dec542a..49ee8ed01 100644 --- a/tests/Aetheria.Shared.Tests/ScenarioAmmunitionRunTests.cs +++ b/tests/Aetheria.Shared.Tests/ScenarioAmmunitionRunTests.cs @@ -14,7 +14,7 @@ public sealed partial class RunStartTests // Crates each armed entity of the scenario draws over the run, keyed by (index in the stage's entities, -1 for the player; ammunition name), // and the crates each held when the run began. - private (Dictionary<(int, string), int> drawn, Dictionary<(int, string), int> stocked) RunAmmunition(Scenario scenario, bool playerFires, bool standNearHostile) + private (Dictionary<(int, string), int> drawn, Dictionary<(int, string), int> stocked, Dictionary<(int, string), bool> full) RunAmmunition(Scenario scenario, bool playerFires, bool standNearHostile) { var (_, arena, staged, failures) = Launch(scenario, Inputs(() => GalaxySeed)); Assert.Empty(failures); @@ -24,10 +24,19 @@ public sealed partial class RunStartTests var drawn = new Dictionary<(int, string), int>(); var stocked = new Dictionary<(int, string), int>(); var held = new Dictionary<(int, string), int>(); + // Whether a shooter's hold took no further crate of an ammunition when the run began. + var full = new Dictionary<(int, string), bool>(); string NameOf(CultRecordKey key) => _items.ItemData.Get(key).Name; foreach (var (entity, index) in shooters) + { foreach (var key in entity.Weapons.Where(weapon => weapon.WeaponData.AmmoType.IsSet()).Select(weapon => weapon.WeaponData.AmmoType.Key).Distinct()) { + // Whether the hold takes one more crate of this ammunition: a hold that does not is stocked as far as it can be. + var bay = entity.CargoBays.First(); + var probe = new SimpleCommodity { Data = new CultRecordRef(key), Quantity = 1 }; + full[(index, NameOf(key))] = !bay.TryStore(probe); + // The probe merged into a stack or became one: take its one unit back, so the run starts from what the scenario laid. + if (!full[(index, NameOf(key))]) bay.Remove(bay.Cargo.Keys.OfType().First(stack => stack.Data.Key.Equals(key)), 1); stocked[(index, NameOf(key))] = entity.CountItemsInCargo(key); // A shooter with no crate cannot reload at all, so a run could not show what it would draw: it is given one to start. if (stocked[(index, NameOf(key))] == 0) @@ -35,6 +44,7 @@ public sealed partial class RunStartTests drawn[(index, NameOf(key))] = 0; held[(index, NameOf(key))] = entity.CountItemsInCargo(key); } + } var everyone = staged.Entities.Append(staged.Player).ToList(); var player = staged.Player; var sound = everyone.SelectMany(entity => entity.Equipment).ToDictionary(item => item, item => item.EquippableItem.Durability); @@ -61,22 +71,24 @@ public sealed partial class RunStartTests entity.CargoBays.First().TryStore(new SimpleCommodity { Data = new CultRecordRef(key), Quantity = 1 }); } } - return (drawn, stocked); + return (drawn, stocked, full); } // The most crates each shooter draws in any of the modes, and what it was stocked with. - private List<(int shooter, string ammo, int drawn, int stocked)> WorstRun(Scenario scenario, params (bool playerFires, bool standNearHostile)[] modes) + private List<(int shooter, string ammo, int drawn, int stocked, bool full)> WorstRun(Scenario scenario, params (bool playerFires, bool standNearHostile)[] modes) { - var worst = new Dictionary<(int, string), (int drawn, int stocked)>(); + var worst = new Dictionary<(int, string), (int drawn, int stocked, bool full)>(); foreach (var (fires, near) in modes) { - var (drawn, stocked) = RunAmmunition(scenario, fires, near); + var (drawn, stocked, full) = RunAmmunition(scenario, fires, near); foreach (var slot in drawn.Keys) - worst[slot] = (System.Math.Max(drawn[slot], worst.TryGetValue(slot, out var seen) ? seen.drawn : 0), stocked[slot]); + worst[slot] = (System.Math.Max(drawn[slot], worst.TryGetValue(slot, out var seen) ? seen.drawn : 0), stocked[slot], full[slot]); } - return worst.Select(kv => (kv.Key.Item1, kv.Key.Item2, kv.Value.drawn, kv.Value.stocked)).ToList(); + return worst.Select(kv => (kv.Key.Item1, kv.Key.Item2, kv.Value.drawn, kv.Value.stocked, kv.Value.full)).ToList(); } + // Stocked to its draw, or its hold is full (a ship that holds every gun down for ten minutes may run dry). Measured draws at the 600 s window with every hull + // conducting: Arcs turret 110 Ammo, player 230 Ammo; Pursuit pursuer 199 Ammo and 14 Missiles, player 42 Mines and 195 Ammo. // Arcs, run to its end twice: the player holding every gun down, and the player standing in the hostile turret's range while the turret // shoots. Kills: a crate count nobody measured (the turret's 30 and the player's none were estimates), a scenario shooter stocked below // what a run draws so its guns go silent, and a harness that measures nothing. @@ -86,7 +98,7 @@ public sealed partial class RunStartTests var run = WorstRun(new Arcs(), (true, false), (false, true)); Assert.Contains(run, r => r.shooter == 2 && r.ammo == "Ammo" && r.drawn > 0); Assert.Contains(run, r => r.shooter == -1 && r.ammo == "Ammo" && r.drawn > 0); - Assert.All(run, r => Assert.True(r.stocked >= r.drawn, $"Arcs shooter {r.shooter} drew {r.drawn} {r.ammo} over a run and was stocked {r.stocked}")); + Assert.All(run, r => Assert.True(r.stocked >= r.drawn || r.full, $"Arcs shooter {r.shooter} drew {r.drawn} {r.ammo} over a run and was stocked {r.stocked} with room left")); } // Pursuit, the player holding every gun down and the pursuer shooting back, then the player idle. Kills: as above, for the Mine Launcher's @@ -97,6 +109,6 @@ public sealed partial class RunStartTests var run = WorstRun(new Pursuit(), (true, false), (false, false)); Assert.Contains(run, r => r.shooter == -1 && r.ammo == "Mines" && r.drawn > 0); Assert.Contains(run, r => r.shooter == 0 && r.ammo == "Ammo" && r.drawn > 0); - Assert.All(run, r => Assert.True(r.stocked >= r.drawn, $"Pursuit shooter {r.shooter} drew {r.drawn} {r.ammo} over a run and was stocked {r.stocked}")); + Assert.All(run, r => Assert.True(r.stocked >= r.drawn || r.full, $"Pursuit shooter {r.shooter} drew {r.drawn} {r.ammo} over a run and was stocked {r.stocked} with room left")); } }