using AcDream.Plugin.Abstractions; using OpenAC.MosswartMassacre.Inventory; namespace OpenAC.MosswartMassacre.Tests.Inventory; /// /// Items exactly as the original recorded them from a live game (the dumps in /// the Mag-Plugins repository), rebuilt from the header words the host now /// reports: the key tables must come out the same, value for value. /// public sealed class RecordedItemTests { [Fact] public void A_recorded_pyreal_mote_rebuilds_key_for_key() { // Barris.json, the first item: a Pyreal Mote in a side pack, never // appraised. Its IntValues and DoubleValues as recorded: var expectedInts = new Dictionary { [218103847] = 137345, [218103830] = 33556406, [218103832] = 271151128, [19] = 10, [218103808] = 6353, [218103809] = 7208, [218103834] = 128, [218103843] = 524296, [218103835] = 18, [218103826] = 128, [218103831] = 17, [218103814] = 1, [218103815] = 1, [5] = 1, [218103810] = 1342431769, [218103822] = 0, [218103828] = 2, }; var expectedDoubles = new Dictionary { [167772170] = 0.0 }; var item = new PluginInventoryItem( unchecked((uint)-2126483018), 6353u, "Pyreal Mote", 128u, 1342431769u, 0u, 0u, 0u, 524296u, 128u, 18u, 1, 0, 0, 0u, 0, 0, 0u, false, 0d, 0, 0, 0, 0d, 0, 0, 0) { ObjectClass = PluginObjectClass.Misc, IconId = 0x06000000u + 7208u, MaximumStackSize = 1, Burden = 1, Value = 10, Header = new PluginObjectHeader( WeenieHeaderFlags: 271151128u, WeenieHeaderFlags2: null, PhysicsDescriptionFlags: 137345u, PhysicsState: null, ObjectDescriptionFlags: 18u, SetupId: 33556406u, Scale: 1.0f, HookType: 2u, ParentObjectId: null, ParentLocation: null, UseRadius: null), }; MyWorldObject record = DecalItemBuilder.Create(new ItemSource( item, null, false, 0, HostItemHeaderSource.Instance.Read(item))); Assert.Equal(expectedInts.OrderBy(p => p.Key), record.IntValues.OrderBy(p => p.Key)); Assert.Equal(expectedDoubles.OrderBy(p => p.Key), record.DoubleValues.OrderBy(p => p.Key)); Assert.Equal("Pyreal Mote", record.StringValues[1]); } [Theory] // Values of key 218103831 recorded for items, with their header words. [InlineData(0x1000u, 0u, 0u, 0u, 0x01u)] // a stack [InlineData(0u, 0x8000u, 0u, 0u, 0x02u)] // on the ground [InlineData(0u, 0u, 0x20000u, 0u, 0x04u)] // lockable [InlineData(0u, 0u, 0u, 0x2u, 0x10u)] // inscribable [InlineData(0x800u, 0u, 0u, 0u, 0x20u)] // uses [InlineData(0x2u, 0u, 0u, 0x12u, 0x90u)] // a pack public void The_frameworks_summary_word(uint weenie, uint physics, uint itemType, uint description, uint expected) => Assert.Equal(expected, HostItemHeaderSource.FrameworkFlags(weenie, physics, itemType, description)); }