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>
34 lines
1.7 KiB
C#
34 lines
1.7 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using MessagePack;
|
|
using Xunit;
|
|
|
|
// Commodity records carry no stored classification and no demand weights (aetheria-living-world, cut
|
|
// catalog-subtraction): stage, component-ness and consumer-ness are derived later from recipes, roles and needs.
|
|
public sealed class CommodityRecordsTests
|
|
{
|
|
// The shipped bytes still hold values at the retired keys; MessagePack skips them and every record loads by name.
|
|
[Fact]
|
|
public void ShippedCatalogOpensWithTheRetiredKeysGone()
|
|
{
|
|
using var cache = RestoredHullsTests.OpenCatalog();
|
|
Assert.Equal(23, cache.GetAll<SimpleCommodityData>().Count());
|
|
Assert.Equal(63, cache.GetAll<CompoundCommodityData>().Count());
|
|
Assert.Contains(cache.GetAll<SimpleCommodityData>(), c => c.Name == "Ammo");
|
|
Assert.All(cache.GetAll<CompoundCommodityData>(), c => Assert.False(string.IsNullOrEmpty(c.Name)));
|
|
}
|
|
|
|
// Keys 10 and 11 are retired: no commodity member may reuse them for a different meaning.
|
|
[Fact]
|
|
public void RetiredKeysStayRetired()
|
|
{
|
|
int[] KeysOf(Type type) => type.GetFields(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
|
|
.Select(f => f.GetCustomAttribute<KeyAttribute>()?.IntKey).Where(k => k.HasValue).Select(k => k.Value).ToArray();
|
|
Assert.Equal(new[] { 9 }, KeysOf(typeof(SimpleCommodityData)));
|
|
Assert.Empty(KeysOf(typeof(CompoundCommodityData)));
|
|
Assert.Null(typeof(SimpleCommodityData).GetField("Category"));
|
|
Assert.Null(typeof(CompoundCommodityData).GetField("Category"));
|
|
Assert.Null(typeof(CompoundCommodityData).GetField("DemandProfile"));
|
|
}
|
|
}
|