Aetheria/tests/Aetheria.Shared.Tests/LauncherAmmunitionCatalogTests.cs
Nibu 8f77000844 Launchers draw real rounds: Missiles commodity and recipe, a reload that pays its crate, a reserve readout
Rulings ballistics-real-ammo and ballistics-cycle-power, follow-up launcher-ammunition. The Munitions batch adds the Missiles
commodity (a high-explosive warhead and a rocket motor at the munitions works; guidance waits on the electronics chain) and sets
AmmoType=Missiles on the five launcher designs; reactor energy per shot stays as authored.

InstantWeapon: the reload used to refill the magazine on its timer and never reach the cargo branch in UseAmmo, so no ammunition-fed
weapon ever paid a round. The refill now takes one unit of AmmoType from cargo (TakeReloadRound) and, with none, the magazine stays
empty; UseAmmo only starts a reload when a unit is there. Weapon.Reserve exposes the cargo count and the HUD shows rounds/reserve for
magazine weapons.

Tests: shipped launchers all name Missiles and Missiles has a recipe; a fed weapon fires its magazine and no more without crates,
reloads once per crate; Reserve equals the cargo count and falls per reload. The commodity count pin goes 22 to 23.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-11 01:58:59 +00:00

28 lines
1.5 KiB
C#

using System.Linq;
using GameCult.Caching;
using Xunit;
// Ruling ballistics-real-ammo, follow-up launcher-ammunition: a launcher is not a free gun. Read from the shipped catalog through
// AetherDb's own open, so what is checked is what ships.
public sealed class LauncherAmmunitionCatalogTests
{
private static bool IsLauncher(WeaponData data) => data is LauncherData || data is GuidedWeaponData || data is LockWeaponData;
// Every launcher design reloads from the Missiles commodity, and Missiles can be made. Kills: a launcher authored (or a new one
// added) with AmmoType unset, which reloads for free forever; Missiles without a recipe, which no station would ever supply.
[Fact]
public void EveryShippedLauncherReloadsFromMissilesAndMissilesCanBeMade()
{
using var db = AetherDb.Open();
var missiles = db.Cache.GetAll<SimpleCommodityData>().Single(c => c.Name == "Missiles");
var key = db.Cache.RefOf(missiles).Key;
var launchers = db.Cache.GetAll<WeaponItemData>().SelectMany(i => i.Behaviors.OfType<WeaponData>().Where(IsLauncher).Select(d => (i.Name, d))).ToArray();
Assert.True(launchers.Length >= 5, $"fixture: the catalog holds its launchers ({launchers.Length})");
foreach (var (name, data) in launchers)
{
Assert.True(data.AmmoType.IsSet(), $"{name} draws no ammunition");
Assert.Equal(key, data.AmmoType.Key);
}
Assert.Contains(db.Cache.GetAll<RecipeData>(), r => r.Output.Key.Equals(key) && r.Inputs.Count > 0);
}
}