Aetheria/tests/Aetheria.Shared.Tests/SmokeHullScenarioTests.cs
Meta Vens 043a73eb0a Smoke Test Hull: 2x2 side mounts on a two-cell margin; test classes read sold hulls only
The 1x1 Ballistic side mount tripped IsFilledByAgreesWithACellOracle (Shape.FitsWithin never places a
design whose only cell is not its origin, so Takes and the oracle disagree on a 1x1 hardpoint); the
side mounts are 2x2 now, which needs two columns of margin on each side, so every Longinus cell and
hardpoint moves right by two. The two catalog-wide tests that listed every hull now list sold hulls.
This commit does not pass the suite: GameData/Aetheria.cc still holds the previous hull until the
next commit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-11 21:32:50 +02:00

80 lines
4.4 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Xunit;
// aetheria-release, cut scenarios-smoke: what the Smoke Test Hull scenarios stage, read from the staged run and the
// shipped catalog's hull.
public sealed partial class RunStartTests
{
private static bool Bears(EquippedItem mount, Entity player, Entity target) => FireControl.InArc(mount, target.Position - player.Position);
private static List<EquippedItem> WeaponMounts(Entity ship) =>
ship.Equipment.Where(item => item.Behaviors.OfType<Weapon>().Any()).ToList();
// Weapon Feel: the player flies the Smoke Test Hull with ChargeBlast SG on the 2x2 Energy hardpoint, Autocannon
// on the 2x2 Ballistic hardpoint and a burst weapon; the bare hull ahead lies in every mount's arc.
[Fact]
public void WeaponFeelConditions()
{
var staged = Stage(Arena(false), new WeaponFeel());
var player = staged.Player;
player.GenerateWeaponGroups();
Assert.Equal("Smoke Test Hull", _items.GetData(player.EquippedHull.EquippableItem).Name);
EquippedItem Mount(string design) => Assert.Single(WeaponMounts(player), item => _items.GetData(item.EquippableItem).Name == design);
var charge = Mount("ChargeBlast SG");
var autocannon = Mount("Autocannon");
Assert.Equal((HardpointType.Energy, 2, 2), (charge.Hardpoint.Type, charge.Hardpoint.Shape.Width, charge.Hardpoint.Shape.Height));
Assert.Equal((HardpointType.Ballistic, 2, 2), (autocannon.Hardpoint.Type, autocannon.Hardpoint.Shape.Width, autocannon.Hardpoint.Shape.Height));
var mounts = WeaponMounts(player);
Assert.Contains(mounts, item => ((WeaponItemData)_items.GetData(item.EquippableItem)).WeaponModifiers.HasFlag(WeaponModifiers.RapidFire));
foreach (var mount in mounts)
{
Assert.Contains(player.WeaponGroups, group => group.items.Contains(mount));
Assert.True(Bears(mount, player, Assert.Single(staged.Entities)), $"{_items.GetData(mount.EquippableItem).Name} cannot bear on the hull ahead");
}
}
// Arcs' flanks: each side mount bears on its own flank's hull and on nothing else, the forward mounts bear on the
// bow and on neither flank, and the two side mounts sit in different weapon groups.
[Fact]
public void ArcsFlanks()
{
var staged = Stage(Arena(false), new Arcs());
var player = staged.Player;
player.GenerateWeaponGroups();
var (bow, stern, port, starboard) = (staged.Entities[0], staged.Entities[1], staged.Entities[3], staged.Entities[4]);
Assert.Equal((Arcs.Port, Arcs.Starboard), (port.Position.xz, starboard.Position.xz));
var mounts = WeaponMounts(player);
var forward = mounts.Where(item => item.EquippableItem.Rotation == ItemRotation.None).ToList();
var starboardMounts = mounts.Where(item => item.EquippableItem.Rotation == ItemRotation.Clockwise).ToList();
var portMounts = mounts.Where(item => item.EquippableItem.Rotation == ItemRotation.CounterClockwise).ToList();
Assert.NotEmpty(forward);
Assert.NotEmpty(starboardMounts);
Assert.NotEmpty(portMounts);
foreach (var mount in starboardMounts)
{
Assert.True(Bears(mount, player, starboard), "a starboard mount cannot bear on the starboard hull");
Assert.False(Bears(mount, player, port) || Bears(mount, player, bow) || Bears(mount, player, stern), "a starboard mount bears off its flank");
}
foreach (var mount in portMounts)
{
Assert.True(Bears(mount, player, port), "a port mount cannot bear on the port hull");
Assert.False(Bears(mount, player, starboard) || Bears(mount, player, bow) || Bears(mount, player, stern), "a port mount bears off its flank");
}
foreach (var mount in forward)
{
Assert.True(Bears(mount, player, bow), "a forward mount cannot bear on the bow hull");
Assert.False(Bears(mount, player, port) || Bears(mount, player, starboard), "a forward mount bears on a flank");
}
int GroupOf(EquippedItem mount) => Array.FindIndex(player.WeaponGroups, group => group.items.Contains(mount));
var starboardGroups = starboardMounts.Select(GroupOf).ToList();
var portGroups = portMounts.Select(GroupOf).ToList();
Assert.DoesNotContain(-1, starboardGroups.Concat(portGroups));
Assert.Empty(starboardGroups.Intersect(portGroups));
}
}