From b47dc7d391c19d8ac331f82028860fead430719a Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Mon, 22 Jun 2026 08:13:20 -0700 Subject: [PATCH] refactor(jewel): emit AOS attributes via AosAttributes.GetProperties --- .../PropertyList/BaseJewelPropertiesTests.cs | 36 ++++++ .../Tests/PropertyList/ItemOplTestHelper.cs | 44 +++++++ Projects/UOContent/Items/Jewels/BaseJewel.cs | 120 +----------------- 3 files changed, 81 insertions(+), 119 deletions(-) create mode 100644 Projects/UOContent.Tests/Tests/PropertyList/BaseJewelPropertiesTests.cs create mode 100644 Projects/UOContent.Tests/Tests/PropertyList/ItemOplTestHelper.cs diff --git a/Projects/UOContent.Tests/Tests/PropertyList/BaseJewelPropertiesTests.cs b/Projects/UOContent.Tests/Tests/PropertyList/BaseJewelPropertiesTests.cs new file mode 100644 index 000000000..30acb6cf1 --- /dev/null +++ b/Projects/UOContent.Tests/Tests/PropertyList/BaseJewelPropertiesTests.cs @@ -0,0 +1,36 @@ +using Server.Items; +using Xunit; + +namespace UOContent.Tests; + +[Collection("Sequential UOContent Tests")] +public class BaseJewelPropertiesTests +{ + [Fact] + public void Jewel_AttributeLineSet_Preserved() + { + var ring = new GoldRing(); + try + { + ring.Attributes.DefendChance = 5; + ring.Attributes.BonusStr = 10; + ring.Attributes.Luck = 100; + ring.Attributes.NightSight = 1; + ring.Attributes.SpellChanneling = 1; + ring.Attributes.IncreasedKarmaLoss = 3; + + var map = ItemOplTestHelper.DecodeAttributeLines(ring); + + Assert.Equal("5", map[1060408]); // DefendChance + Assert.Equal("10", map[1060485]); // BonusStr + Assert.Equal("100", map[1060436]); // Luck (raw; jewel has no luck bonus) + Assert.Equal("", map[1060441]); // NightSight + Assert.Equal("", map[1060482]); // SpellChanneling + Assert.Equal("3", map[1075210]); // IncreasedKarmaLoss (Core.ML EJ) + } + finally + { + ring.Delete(); + } + } +} diff --git a/Projects/UOContent.Tests/Tests/PropertyList/ItemOplTestHelper.cs b/Projects/UOContent.Tests/Tests/PropertyList/ItemOplTestHelper.cs new file mode 100644 index 000000000..1b4acf26b --- /dev/null +++ b/Projects/UOContent.Tests/Tests/PropertyList/ItemOplTestHelper.cs @@ -0,0 +1,44 @@ +using System; +using System.Buffers.Binary; +using System.Collections.Generic; +using System.Text; +using Server; + +namespace UOContent.Tests; + +public static class ItemOplTestHelper +{ + // Builds the item's OPL and returns attribute/property cliloc lines (>= 1060000), + // ignoring base-item lines (name, weight, etc.) so tests isolate the attribute surface. + public static Dictionary DecodeAttributeLines(Item item) + { + var opl = new ObjectPropertyList(item); + item.GetProperties(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; + var arg = Encoding.Unicode.GetString(buffer, pos, byteLen); + pos += byteLen; + + if (cliloc is >= 1060000 and < 1080000) + { + map[cliloc] = arg; + } + } + + return map; + } +} diff --git a/Projects/UOContent/Items/Jewels/BaseJewel.cs b/Projects/UOContent/Items/Jewels/BaseJewel.cs index 29f7d67d8..4eb01cbe0 100644 --- a/Projects/UOContent/Items/Jewels/BaseJewel.cs +++ b/Projects/UOContent/Items/Jewels/BaseJewel.cs @@ -389,125 +389,7 @@ public abstract partial class BaseJewel : Item, ICraftable, IAosItem list.Add(1061078, prop); // artifact rarity ~1_val~ } - if ((prop = Attributes.WeaponDamage) != 0) - { - list.Add(1060401, prop); // damage increase ~1_val~% - } - - if ((prop = Attributes.DefendChance) != 0) - { - list.Add(1060408, prop); // defense chance increase ~1_val~% - } - - if ((prop = Attributes.BonusDex) != 0) - { - list.Add(1060409, prop); // dexterity bonus ~1_val~ - } - - if ((prop = Attributes.EnhancePotions) != 0) - { - list.Add(1060411, prop); // enhance potions ~1_val~% - } - - if ((prop = Attributes.CastRecovery) != 0) - { - list.Add(1060412, prop); // faster cast recovery ~1_val~ - } - - if ((prop = Attributes.CastSpeed) != 0) - { - list.Add(1060413, prop); // faster casting ~1_val~ - } - - if ((prop = Attributes.AttackChance) != 0) - { - list.Add(1060415, prop); // hit chance increase ~1_val~% - } - - if ((prop = Attributes.BonusHits) != 0) - { - list.Add(1060431, prop); // hit point increase ~1_val~ - } - - if ((prop = Attributes.BonusInt) != 0) - { - list.Add(1060432, prop); // intelligence bonus ~1_val~ - } - - if ((prop = Attributes.LowerManaCost) != 0) - { - list.Add(1060433, prop); // lower mana cost ~1_val~% - } - - if ((prop = Attributes.LowerRegCost) != 0) - { - list.Add(1060434, prop); // lower reagent cost ~1_val~% - } - - if ((prop = Attributes.Luck) != 0) - { - list.Add(1060436, prop); // luck ~1_val~ - } - - if ((prop = Attributes.BonusMana) != 0) - { - list.Add(1060439, prop); // mana increase ~1_val~ - } - - if ((prop = Attributes.RegenMana) != 0) - { - list.Add(1060440, prop); // mana regeneration ~1_val~ - } - - if (Attributes.NightSight != 0) - { - list.Add(1060441); // night sight - } - - if ((prop = Attributes.ReflectPhysical) != 0) - { - list.Add(1060442, prop); // reflect physical damage ~1_val~% - } - - if ((prop = Attributes.RegenStam) != 0) - { - list.Add(1060443, prop); // stamina regeneration ~1_val~ - } - - if ((prop = Attributes.RegenHits) != 0) - { - list.Add(1060444, prop); // hit point regeneration ~1_val~ - } - - if (Attributes.SpellChanneling != 0) - { - list.Add(1060482); // spell channeling - } - - if ((prop = Attributes.SpellDamage) != 0) - { - list.Add(1060483, prop); // spell damage increase ~1_val~% - } - - if ((prop = Attributes.BonusStam) != 0) - { - list.Add(1060484, prop); // stamina increase ~1_val~ - } - - if ((prop = Attributes.BonusStr) != 0) - { - list.Add(1060485, prop); // strength bonus ~1_val~ - } - - if ((prop = Attributes.WeaponSpeed) != 0) - { - list.Add(1060486, prop); // swing speed increase ~1_val~% - } - - if (Core.ML && (prop = Attributes.IncreasedKarmaLoss) != 0) - { - list.Add(1075210, prop); // Increased Karma Loss ~1val~% - } + Attributes.GetProperties(list); AddResistanceProperties(list);