From 8b2eef7b5184a9ba2cea2b8d1fe9546ec5e52724 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 13 Oct 2026 18:18:23 +0200 Subject: [PATCH] Loot 3 group B: PickupTests two-bay fixture and TheBeamTakesFromWhicheverBayCanStore Spawn takes bays (default 1) and equips that many crates before Zone.Admit. The new test fills the first bay and expects the beam to claim and land the ore in the second, pinning ruling beam-skips-unstorable-items over bays (Select's Any over bays). Builds; test not yet run on Yggdrasil. Co-Authored-By: Claude Opus 5.5 --- tests/Aetheria.Shared.Tests/PickupTests.cs | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/PickupTests.cs b/tests/Aetheria.Shared.Tests/PickupTests.cs index 61f590c51..35bc63563 100644 --- a/tests/Aetheria.Shared.Tests/PickupTests.cs +++ b/tests/Aetheria.Shared.Tests/PickupTests.cs @@ -107,14 +107,13 @@ public sealed class PickupTests : IDisposable return new Lab { Items = items, Zone = zone }; } - // A ship with a cargo bay, aimed along +x and (unless told otherwise) carrying the tractor beam. - private static Ship Spawn(Lab lab, float3 at, bool beam = true) + // A ship with `bays` cargo bays (bays are equipped before the zone admits the ship), aimed along +x and + // (unless told otherwise) carrying the tractor beam. + private static Ship Spawn(Lab lab, float3 at, bool beam = true, int bays = 1) { var hull = lab.Items.ItemData.RefOf(lab.Items.ItemData.GetByName("Skiff")); var ship = new Ship(lab.Items, lab.Zone, new EquippableItem { Data = hull, Durability = 1000000, Lot = lab.Lot++ }, new EntitySettings()); - var crate = lab.Make("Crate"); - Assert.True(ship.TryFindSpace(crate, out var cratePos)); - Assert.True(ship.TryEquip(crate, cratePos)); + for (var i = 0; i < bays; i++) Equip(ship, lab.Make("Crate")); if (beam) Equip(ship, lab.Make("Tractor")); lab.Zone.Admit(ship, piloted: false); ship.Position = at; @@ -404,6 +403,26 @@ public sealed class PickupTests : IDisposable Assert.True(block.Holder == null, "block is held"); } + [Fact] + public void TheBeamTakesFromWhicheverBayCanStore() + { + using var bag = new CompositeDisposable(); + var lab = Build(Beam()); + var ship = Spawn(lab, float3(0, 0, 0), bays: 2); + Assert.Equal(2, ship.CargoBays.Count); + // The first bay is full; only the second can take the ore. + for (var i = 0; i < 16; i++) Assert.True(ship.CargoBays[0].TryStore(lab.Make("Spare"))); + var ore = Drift(lab, 40, 0); + var events = Watch(ship, bag); + ship.TractorCommand = 1; + Tick(lab, 300, 1 / 60f); + Assert.Contains(events, e => e.Phase == GrabPhase.Started && e.Target == ore.Id); + Assert.Contains(events, e => e.Phase == GrabPhase.Completed); + Assert.False(lab.Zone.FloatingItems.Contains(ore), "ore is still in the zone"); + Assert.Equal(16, ship.CargoBays[0].Cargo.Count); + Assert.Single(ship.CargoBays[1].Cargo); + } + [Fact] public void AnItemInTheBeamsFarCornerIsCollected() {