From 27d00ba63a1ee1c48d65a39149bbabf842bd8bab Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Mon, 22 Jun 2026 10:01:40 -0700 Subject: [PATCH] refactor(armor): fold lower-requirements into AosArmorAttributes.GetProperties LowerStatReq (1060435) now emitted inside AosArmorAttributes.GetProperties in cliloc order (ahead of MageArmor/SelfRepair), via a passed-in value: armor passes the computed GetLowerStatReq() (raw + resource ArmorLowerRequirements), clothing passes its raw ClothingAttributes.LowerStatReq. Removes the inline line from both item bases. --- .../AosArmorAttributesPropertiesTests.cs | 23 +++++++++++++++---- Projects/UOContent/Items/Armor/BaseArmor.cs | 7 +----- .../UOContent/Items/Clothing/BaseClothing.cs | 7 +----- Projects/UOContent/Misc/AOS.cs | 10 +++++++- 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/Projects/UOContent.Tests/Tests/PropertyList/AosArmorAttributesPropertiesTests.cs b/Projects/UOContent.Tests/Tests/PropertyList/AosArmorAttributesPropertiesTests.cs index a4438b3c2..0cb1c931f 100644 --- a/Projects/UOContent.Tests/Tests/PropertyList/AosArmorAttributesPropertiesTests.cs +++ b/Projects/UOContent.Tests/Tests/PropertyList/AosArmorAttributesPropertiesTests.cs @@ -36,23 +36,36 @@ public class AosArmorAttributesPropertiesTests } [Fact] - public void EmitsMageArmorAndSelfRepairOnly() + public void EmitsMageArmorAndSelfRepair_DoesNotReadLowerStatReqOrDurabilityFromContainer() { var attrs = new AosArmorAttributes(null) { MageArmor = 1, SelfRepair = 4, - LowerStatReq = 50, // must NOT be emitted here - DurabilityBonus = 10 // must NOT be emitted here + LowerStatReq = 50, // container value must NOT be auto-emitted (it's passed in by the consumer) + DurabilityBonus = 10 // never emitted by this method }; var opl = new ObjectPropertyList(null); - attrs.GetProperties(opl); + attrs.GetProperties(opl); // no lowerStatReq arg 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(1060435)); // LowerStatReq NOT read from container Assert.False(map.ContainsKey(1060410)); // DurabilityBonus excluded } + + [Fact] + public void EmitsLowerStatReqWhenPassed() + { + var attrs = new AosArmorAttributes(null) { MageArmor = 1, LowerStatReq = 50 }; + + var opl = new ObjectPropertyList(null); + attrs.GetProperties(opl, lowerStatReq: 77); // computed value passed by the consumer, not the raw 50 + var map = Decode(opl); + + Assert.Equal("77", map[1060435]); // emitted from the param, not the container's 50 + Assert.Equal("", map[1060437]); // MageArmor still emitted + } } diff --git a/Projects/UOContent/Items/Armor/BaseArmor.cs b/Projects/UOContent/Items/Armor/BaseArmor.cs index 50a976c91..8e08895ba 100644 --- a/Projects/UOContent/Items/Armor/BaseArmor.cs +++ b/Projects/UOContent/Items/Armor/BaseArmor.cs @@ -1323,12 +1323,7 @@ namespace Server.Items list.Add(1061078, prop); // artifact rarity ~1_val~ } - ArmorAttributes.GetProperties(list); - - if ((prop = GetLowerStatReq()) != 0) - { - list.Add(1060435, prop); // lower requirements ~1_val~% - } + ArmorAttributes.GetProperties(list, lowerStatReq: GetLowerStatReq()); Attributes.GetProperties(list, luckBonus: GetLuckBonus()); diff --git a/Projects/UOContent/Items/Clothing/BaseClothing.cs b/Projects/UOContent/Items/Clothing/BaseClothing.cs index 263148f11..e28363aa9 100644 --- a/Projects/UOContent/Items/Clothing/BaseClothing.cs +++ b/Projects/UOContent/Items/Clothing/BaseClothing.cs @@ -754,12 +754,7 @@ namespace Server.Items list.Add(1061078, prop); // artifact rarity ~1_val~ } - ClothingAttributes.GetProperties(list); - - if ((prop = ClothingAttributes.LowerStatReq) != 0) - { - list.Add(1060435, prop); // lower requirements ~1_val~% - } + ClothingAttributes.GetProperties(list, lowerStatReq: ClothingAttributes.LowerStatReq); Attributes.GetProperties(list); diff --git a/Projects/UOContent/Misc/AOS.cs b/Projects/UOContent/Misc/AOS.cs index 6a9ec278c..dae70ac94 100644 --- a/Projects/UOContent/Misc/AOS.cs +++ b/Projects/UOContent/Misc/AOS.cs @@ -1198,10 +1198,18 @@ namespace Server return value; } - public void GetProperties(IPropertyList list) + // lowerStatReq is passed in because consumers compute it differently: armor folds in the + // resource's ArmorLowerRequirements via GetLowerStatReq(), clothing reads it raw. Emitted in + // cliloc order (1060435) ahead of MageArmor/SelfRepair. + public void GetProperties(IPropertyList list, int lowerStatReq = 0) { int prop; + if (lowerStatReq != 0) + { + list.Add(1060435, lowerStatReq); // lower requirements ~1_val~% + } + if (MageArmor != 0) { list.Add(1060437); // mage armor