From fc756406ba6392409699e8a4ae23f76814bf152e Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Mon, 22 Jun 2026 08:07:34 -0700 Subject: [PATCH] feat(aos): add AosArmorAttributes.GetProperties(IPropertyList) --- .../AosArmorAttributesPropertiesTests.cs | 58 +++++++++++++++++++ Projects/UOContent/Misc/AOS.cs | 15 +++++ 2 files changed, 73 insertions(+) create mode 100644 Projects/UOContent.Tests/Tests/PropertyList/AosArmorAttributesPropertiesTests.cs diff --git a/Projects/UOContent.Tests/Tests/PropertyList/AosArmorAttributesPropertiesTests.cs b/Projects/UOContent.Tests/Tests/PropertyList/AosArmorAttributesPropertiesTests.cs new file mode 100644 index 000000000..a4438b3c2 --- /dev/null +++ b/Projects/UOContent.Tests/Tests/PropertyList/AosArmorAttributesPropertiesTests.cs @@ -0,0 +1,58 @@ +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using Server; +using Server.Items; +using Xunit; + +namespace UOContent.Tests; + +[Collection("Sequential UOContent Tests")] +public class AosArmorAttributesPropertiesTests +{ + private static Dictionary Decode(ObjectPropertyList opl) + { + opl.Terminate(); + var buffer = opl.Buffer; + var map = new Dictionary(); + var pos = 15; + while (true) + { + var cliloc = BinaryPrimitives.ReadInt32BigEndian(buffer.AsSpan(pos)); + pos += 4; + if (cliloc == 0) + { + break; + } + + var byteLen = BinaryPrimitives.ReadUInt16BigEndian(buffer.AsSpan(pos)); + pos += 2; + map[cliloc] = Encoding.Unicode.GetString(buffer, pos, byteLen); + pos += byteLen; + } + + return map; + } + + [Fact] + public void EmitsMageArmorAndSelfRepairOnly() + { + var attrs = new AosArmorAttributes(null) + { + MageArmor = 1, + SelfRepair = 4, + LowerStatReq = 50, // must NOT be emitted here + DurabilityBonus = 10 // must NOT be emitted here + }; + + var opl = new ObjectPropertyList(null); + attrs.GetProperties(opl); + var map = Decode(opl); + + Assert.Equal("", map[1060437]); // MageArmor (no-arg) + Assert.Equal("4", map[1060450]); // SelfRepair + Assert.False(map.ContainsKey(1060435)); // LowerStatReq excluded + Assert.False(map.ContainsKey(1060410)); // DurabilityBonus excluded + } +} diff --git a/Projects/UOContent/Misc/AOS.cs b/Projects/UOContent/Misc/AOS.cs index 62b714dc3..6a9ec278c 100644 --- a/Projects/UOContent/Misc/AOS.cs +++ b/Projects/UOContent/Misc/AOS.cs @@ -1198,6 +1198,21 @@ namespace Server return value; } + public void GetProperties(IPropertyList list) + { + int prop; + + if (MageArmor != 0) + { + list.Add(1060437); // mage armor + } + + if ((prop = SelfRepair) != 0) + { + list.Add(1060450, prop); // self repair ~1_val~ + } + } + public override string ToString() => "..."; }