From 8c5825ed9497c4cfc8c79d2bc52c9949d69b240b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 11 Oct 2026 14:09:32 +0200 Subject: [PATCH] PaintModeTests: concurrent sweeps credit once per crossing; factionless ships are not allies Co-Authored-By: Claude Opus 5.5 --- tests/Aetheria.Shared.Tests/PaintModeTests.cs | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/tests/Aetheria.Shared.Tests/PaintModeTests.cs b/tests/Aetheria.Shared.Tests/PaintModeTests.cs index 2b2fab6b1..ec5019de7 100644 --- a/tests/Aetheria.Shared.Tests/PaintModeTests.cs +++ b/tests/Aetheria.Shared.Tests/PaintModeTests.cs @@ -94,11 +94,11 @@ public sealed class PaintModeTests : IDisposable private int _nextLot = 2; // A ship at `position`; a ship without a `sensor` is a bare hull. Every ship is lit at a constant visibility of 5. - private Ship NewShip(float3 position, string sensor = null, Faction faction = null) + private Ship NewShip(float3 position, string sensor = null, Faction faction = null, bool factionless = false) { var hullRef = _items.ItemData.RefOf(_items.ItemData.GetByName("Skiff")); var ship = new Ship(_items, _zone, new EquippableItem { Data = hullRef, Durability = 1000, Lot = 1 }, new EntitySettings()) - { Faction = faction ?? new Faction { Name = "F" + Guid.NewGuid().ToString("N") } }; + { Faction = factionless ? null : faction ?? new Faction { Name = "F" + Guid.NewGuid().ToString("N") } }; if (sensor != null) { var gearRef = _items.ItemData.RefOf(_items.ItemData.GetByName(sensor)); @@ -254,6 +254,39 @@ public sealed class PaintModeTests : IDisposable Assert.Equal(0f, Track(e, t)); } + // Two sweeps crossing one subject on one tick are two observations: C's own ping and A's ping heard as an ally. + // A and C stand 100 from T, so both wavefronts pass it on the same tick. + [Fact] + public void ConcurrentSweepsCreditOncePerCrossing() + { + var a = NewShip(float3(0, 0, 0), "Omni"); + var t = NewShip(float3(0, 0, 100)); + var c = NewShip(float3(100, 0, 100), "Ear", a.Faction); + Settle(); + + SensorOf(a).Ping(); + SensorOf(c).Ping(); + for (var tick = 0; tick < 24; tick++) Tick(.1f); + + Assert.Equal(2 * .3f, Track(c, t), 4); // 5 x 3 x .0002 x 100, its own ping and A's + Assert.Equal(2 * .1f, Track(a, t), 4); // 5 x 2 x .0001 x 100, its own ping and C's + } + + // Allegiance needs a faction: two factionless ships are not allies, so one hears nothing of the other's ping. + [Fact] + public void FactionlessShipsAreNotAllies() + { + var a = NewShip(float3(0, 0, 0), "Omni", factionless: true); + var t = NewShip(float3(0, 0, 100)); + var drifter = NewShip(float3(30, 0, 140), "Ear", factionless: true); + Settle(); + + SweepAndWatch(a, .1f); + + Assert.Equal(.1f, Track(a, t), 4); + Assert.Equal(0f, Track(drifter, t)); + } + [Theory] [InlineData(false)] [InlineData(true)]