From 12cbf7eea90ee1a88c9af7e26aa083de05da05dd Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Mon, 22 Jun 2026 08:52:40 -0700 Subject: [PATCH] refactor(spellbook): emit AOS attributes via AosAttributes.GetProperties --- .../PropertyList/SpellbookPropertiesTests.cs | 42 ++++++ .../Items/Skill Items/Magical/Spellbook.cs | 122 +----------------- 2 files changed, 43 insertions(+), 121 deletions(-) create mode 100644 Projects/UOContent.Tests/Tests/PropertyList/SpellbookPropertiesTests.cs diff --git a/Projects/UOContent.Tests/Tests/PropertyList/SpellbookPropertiesTests.cs b/Projects/UOContent.Tests/Tests/PropertyList/SpellbookPropertiesTests.cs new file mode 100644 index 000000000..4f14d1f71 --- /dev/null +++ b/Projects/UOContent.Tests/Tests/PropertyList/SpellbookPropertiesTests.cs @@ -0,0 +1,42 @@ +using Server.Items; +using Xunit; + +namespace UOContent.Tests; + +[Collection("Sequential UOContent Tests")] +public class SpellbookPropertiesTests +{ + [Fact] + public void GetProperties_EmitsAosAttributeLines() + { + var item = new Spellbook(); + try + { + item.Attributes.CastRecovery = 3; + item.Attributes.LowerManaCost = 8; + item.Attributes.Luck = 75; + item.Attributes.NightSight = 1; + item.Attributes.SpellChanneling = 1; + item.Attributes.IncreasedKarmaLoss = 2; + + var lines = ItemOplTestHelper.DecodeAttributeLines(item); + + Assert.True(lines.ContainsKey(1060412)); // CastRecovery + Assert.Equal("3", lines[1060412]); + Assert.True(lines.ContainsKey(1060433)); // LowerManaCost + Assert.Equal("8", lines[1060433]); + Assert.True(lines.ContainsKey(1060436)); // Luck + Assert.Equal("75", lines[1060436]); + Assert.True(lines.ContainsKey(1060441)); // NightSight + Assert.Equal("", lines[1060441]); + Assert.True(lines.ContainsKey(1060482)); // SpellChanneling + Assert.Equal("", lines[1060482]); + Assert.True(lines.ContainsKey(1075210)); // IncreasedKarmaLoss + Assert.Equal("2", lines[1075210]); + } + finally + { + item.Delete(); + } + } +} diff --git a/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs b/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs index c94a362ab..f1ced7308 100644 --- a/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs +++ b/Projects/UOContent/Items/Skill Items/Magical/Spellbook.cs @@ -677,127 +677,7 @@ public partial class Spellbook : Item, ICraftable, ISlayer, IAosItem } } - int prop; - - 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); list.Add(1042886, _spellCount); // ~1_NUMBERS_OF_SPELLS~ Spells }