refactor(spellbook): emit AOS attributes via AosAttributes.GetProperties

This commit is contained in:
Kamron Batman 2026-06-22 08:52:40 -07:00
parent d85812386d
commit 12cbf7eea9
2 changed files with 43 additions and 121 deletions

View file

@ -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();
}
}
}

View file

@ -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
}