From 439c7d1b4f29352934980cdb7a9fc9af5ab6ad68 Mon Sep 17 00:00:00 2001 From: soul Date: Thu, 19 Nov 2026 23:15:08 +0100 Subject: [PATCH] Test ZoneStage.Summon: joins a running zone, refusals admit nothing, fed ships carry crates Co-Authored-By: Claude Sonnet 5.5 --- .../AmmunitionStockingTests.cs | 21 ++++++ tests/Aetheria.Shared.Tests/ScenarioTests.cs | 70 +++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/tests/Aetheria.Shared.Tests/AmmunitionStockingTests.cs b/tests/Aetheria.Shared.Tests/AmmunitionStockingTests.cs index dfdb9d040..02cd19c73 100644 --- a/tests/Aetheria.Shared.Tests/AmmunitionStockingTests.cs +++ b/tests/Aetheria.Shared.Tests/AmmunitionStockingTests.cs @@ -104,6 +104,27 @@ public sealed partial class RunStartTests Assert.Equal(LoadoutGenerator.AmmunitionCrates, weapon.Reserve); } + // A ship summoned into a running zone is stocked like one a run start stages: a fed fit carries the crates its weapon draws, + // and one whose scenario authored its cargo keeps exactly that. Kills: Summon skipping StockUnauthoredAmmunition. + [Fact] + public void ASummonedFedShipCarriesItsCrates() + { + var (hull, slots) = FedFit(bay: true); + var (_, arena, staged, failures) = Launch(new Scripted(false, stage => stage.Player(stage.Bare("Djinni"), float2(0, 0))), Inputs(() => GalaxySeed)); + Assert.True(failures.Count == 0, string.Join("; ", failures)); + + var summoned = ZoneStage.Summon(_items, arena, staged.Player, stage => + { + stage.Place(stage.Fit(hull, slots), float2(300, 0)); + var authored = stage.Place(stage.Fit(hull, slots), float2(-300, 0)); + stage.Cargo(authored); + }, failures); + + Assert.True(failures.Count == 0, string.Join("; ", failures)); + Assert.Equal(LoadoutGenerator.AmmunitionCrates, Assert.Single(summoned[0].Weapons).Reserve); + Assert.Equal(0, Assert.Single(summoned[1].Weapons).Reserve); + } + // The Loadout path with the DEFAULT stocking argument (what the boss in ZoneGenerator and the console `fly` call): a ship built from a // Loadout holds the crates its fed weapon draws, and one whose only weapon draws nothing holds none. Kills: Materialize // dropping its default StockAmmunition (every Loadout-built armed ship fires one magazine). diff --git a/tests/Aetheria.Shared.Tests/ScenarioTests.cs b/tests/Aetheria.Shared.Tests/ScenarioTests.cs index 03dcb9f9a..69135d879 100644 --- a/tests/Aetheria.Shared.Tests/ScenarioTests.cs +++ b/tests/Aetheria.Shared.Tests/ScenarioTests.cs @@ -399,6 +399,76 @@ public sealed partial class RunStartTests Assert.Equal(0, AgentsOf(zone, neutral)); } + // A summon places into a running zone through the stage's admission (ruling ifl-ships-in-demo-as-tactical-view): after a run + // has started and stepped, a hostile piloted generated ship that approaches the player is a member with one agent, hostile + // both ways, and its pilot knows the player by the sensors' own path. Kills: a summon that skips the stance, the pilot or + // the knowledge seed. + [Fact] + public void ASummonJoinsARunningZone() + { + var zone = Arena(true); + var player = Stage(zone, new Scripted(true, stage => stage.Player(stage.Bare("Djinni"), float2(0, 0)))).Player; + for (var tick = 0; tick < 20; tick++) zone.Update(.1f); + + var failures = new List(); + var summoned = ZoneStage.Summon(_items, zone, player, stage => + { + var placed = stage.Place(stage.Generated("Longinus"), float2(400, 0), stance: ScenarioStance.Hostile, piloted: true); + stage.Approach(placed, player); + }, failures); + + Assert.True(failures.Count == 0, string.Join("; ", failures)); + var raider = Assert.Single(summoned); + SafeAssert.In(zone, raider, "the summoned ship is admitted"); + Assert.Equal(1, AgentsOf(zone, raider)); + Assert.True(player.IsHostileTo(raider) && raider.IsHostileTo(player), "hostile both ways"); + Assert.Equal((_items.GameplaySettings.TargetDetectionInfoThreshold + 1f) / 2f, raider.EntityInfoGathered[player]); + for (var tick = 0; tick < 20; tick++) zone.Update(.1f); + Assert.True(player.EntityHostility[raider] && raider.EntityHostility[player], "the live hostility agrees"); + Assert.Equal(1, AgentsOf(zone, raider)); + } + + // A summon naming a design the catalog lacks admits nothing, and names it. Kills: admitting before the failure check. + [Fact] + public void ARefusedSummonAdmitsNothing() + { + var zone = Arena(true); + var player = Stage(zone, new Scripted(true, stage => stage.Player(stage.Bare("Djinni"), float2(0, 0)))).Player; + var entities = zone.Entities.ToList(); + var agents = zone.Agents.ToList(); + var failures = new List(); + + var summoned = ZoneStage.Summon(_items, zone, player, stage => + { + stage.Place(stage.Generated("Longinus"), float2(400, 0), stance: ScenarioStance.Hostile, piloted: true); + stage.Place(stage.Bare("No Such Hull"), float2(-400, 0)); + }, failures); + + Assert.Null(summoned); + Assert.Contains(failures, failure => failure.Contains("No Such Hull")); + SafeAssert.Unchanged(zone, entities, agents); + } + + // A summon needs the player to be in the zone it summons into: with the player docked it refuses, names why and admits nothing. + // Kills: dropping the membership check, which would write stance onto a non-member. + [Fact] + public void ASummonNeedsThePlayerInTheZone() + { + var zone = Arena(true); + var player = Stage(zone, new Scripted(true, stage => stage.Player(stage.Bare("Djinni"), float2(0, 0)))).Player; + Assert.True(zone.Remove(player)); + var entities = zone.Entities.ToList(); + var agents = zone.Agents.ToList(); + var failures = new List(); + + var summoned = ZoneStage.Summon(_items, zone, player, stage => + stage.Place(stage.Bare("Longinus"), float2(400, 0), stance: ScenarioStance.Hostile), failures); + + Assert.Null(summoned); + Assert.Equal(new[] { "summon: the player is not in this zone" }, failures); + SafeAssert.Unchanged(zone, entities, agents); + } + // A stance lasts the sitting: the player docking and undocking leaves it standing both ways. It goes with an entity // gone for good: once an entity is destroyed, the player holds no stance toward it. [Fact]