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

This commit is contained in:
Kamron Batman 2026-06-22 08:13:20 -07:00
parent fc756406ba
commit b47dc7d391
3 changed files with 81 additions and 119 deletions

View file

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

View file

@ -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<int, string> DecodeAttributeLines(Item item)
{
var opl = new ObjectPropertyList(item);
item.GetProperties(opl);
opl.Terminate();
var buffer = opl.Buffer;
var map = new Dictionary<int, string>();
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;
}
}

View file

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