From 774d2476ff5ce8eb12f8f7d495d46550d5fec85d Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 13 Oct 2026 06:12:18 +0200 Subject: [PATCH] LaunchSuppressorTests: pin the factor clamp (above 1, below 0) and the exactly-rated-temperature boundary with a step either side Tests only; production unchanged. Fixture gear SuppressorBright (Factor 3) and SuppressorNegative (Factor -1). Maps Soul findings clamp-unpinned and rated-boundary-unpinned. Builds. Co-Authored-By: Claude Opus 5.5 --- .../ContactRevealTests.cs | 2 + .../LaunchSuppressorTests.cs | 56 +++++++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/tests/Aetheria.Shared.Tests/ContactRevealTests.cs b/tests/Aetheria.Shared.Tests/ContactRevealTests.cs index 57826d4eb..a3bc68be9 100644 --- a/tests/Aetheria.Shared.Tests/ContactRevealTests.cs +++ b/tests/Aetheria.Shared.Tests/ContactRevealTests.cs @@ -72,6 +72,8 @@ public sealed partial class ContactRevealTests : IDisposable cache.Upsert(Suppressor("SuppressorOpen", factor: 1f, heatPerUnit: 2f)); cache.Upsert(Suppressor("SuppressorHalf", factor: .5f, heatPerUnit: 1f)); cache.Upsert(Suppressor("SuppressorFifth", factor: .2f, heatPerUnit: 10f)); + cache.Upsert(Suppressor("SuppressorBright", factor: 3f, heatPerUnit: 2f)); + cache.Upsert(Suppressor("SuppressorNegative", factor: -1f, heatPerUnit: 2f)); var gun = Armed(new InstantWeaponData { Count = Const(1), BurstTime = Const(0), Cooldown = Const(1) }, 5); cache.Upsert(new WeaponItemData { diff --git a/tests/Aetheria.Shared.Tests/LaunchSuppressorTests.cs b/tests/Aetheria.Shared.Tests/LaunchSuppressorTests.cs index 87ce4c8f3..eb2ed3ab8 100644 --- a/tests/Aetheria.Shared.Tests/LaunchSuppressorTests.cs +++ b/tests/Aetheria.Shared.Tests/LaunchSuppressorTests.cs @@ -136,6 +136,62 @@ public sealed partial class ContactRevealTests Assert.True(ship.Temperature[cell.x, cell.y] > 300f); } + // The rated temperature (400) belongs to the suppressor, and a suppressor running exactly at it still works: only + // "exceeds" stops it. One step either side pins which side of the line the boundary itself falls on. + [Fact] + public void ASuppressorAtExactlyItsRatedTemperatureStillSuppressesAndOneStepAboveDoesNot() + { + var ship = Add(float3(0, 0, 0), null, new[] { "Suppressor" }); + var cell = CellOf(SuppressorItem(ship, "Suppressor")); + var source = new object(); + + ship.Temperature[cell.x, cell.y] = 399.99f; // one step below + ship.SetSignature(source, SignatureChannel.LaunchFlash, 5f, null); + Assert.Equal(.5f, ship.VisibilitySources[source].Strength, 3); + + ship.Temperature[cell.x, cell.y] = 400f; // exactly rated + var atRated = Snapshot(ship); + ship.SetSignature(source, SignatureChannel.LaunchFlash, 5f, null); + Assert.Equal(.5f, ship.VisibilitySources[source].Strength, 3); + Assert.True(ship.Temperature[cell.x, cell.y] > atRated[cell.x, cell.y]); // and it paid + + ship.Temperature[cell.x, cell.y] = 400.01f; // one step above + var above = Snapshot(ship); + ship.SetSignature(source, SignatureChannel.LaunchFlash, 5f, null); + Assert.Equal(5f, ship.VisibilitySources[source].Strength, 3); + AssertOnlyCellsMoved(above, ship); + } + + // ---- The factor is clamped to 0..1 ---- + + [Fact] + public void AFactorAboveOneNeverBrightensTheFlashOrCoolsTheShip() + { + var ship = Add(float3(0, 0, 0), null, new[] { "SuppressorBright" }); // authored Factor 3 + var before = Snapshot(ship); + var source = new object(); + + ship.SetSignature(source, SignatureChannel.LaunchFlash, 5f, null); + + Assert.Equal(5f, ship.VisibilitySources[source].Strength, 3); // clamped to 1: the flash is as written + AssertOnlyCellsMoved(before, ship); // and nothing was "removed", so no heat, hot or cold + } + + [Fact] + public void AFactorBelowZeroRemovesTheWholeFlashAndNoMore() + { + var ship = Add(float3(0, 0, 0), null, new[] { "SuppressorNegative" }); // authored Factor -1 + var cell = CellOf(SuppressorItem(ship, "SuppressorNegative")); + var before = Snapshot(ship); + var source = new object(); + + ship.SetSignature(source, SignatureChannel.LaunchFlash, 5f, null); + + Assert.Equal(0f, ship.VisibilitySources[source].Strength, 3); // clamped to 0: no negative light + AssertHeat(5f * 2f, ship, cell, before[cell.x, cell.y]); // paid for exactly the 5 it removed + AssertOnlyCellsMoved(before, ship, cell); + } + // ---- OnlyTheLaunchFlashChannelIsScaled ---- [Fact]