feat(aos): add AosWeaponAttributes.GetProperties(IPropertyList)

This commit is contained in:
Kamron Batman 2026-06-22 08:03:51 -07:00
parent ea92545b0d
commit 862d14cdff
2 changed files with 155 additions and 0 deletions

View file

@ -0,0 +1,60 @@
using System;
using System.Buffers.Binary;
using System.Collections.Generic;
using System.Text;
using Server;
using Server.Items;
using Xunit;
namespace UOContent.Tests;
[Collection("Sequential UOContent Tests")]
public class AosWeaponAttributesPropertiesTests
{
private static Dictionary<int, string> Decode(ObjectPropertyList 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;
map[cliloc] = Encoding.Unicode.GetString(buffer, pos, byteLen);
pos += byteLen;
}
return map;
}
[Fact]
public void EmitsHitEffectsUseBestSkillMageWeaponSelfRepair()
{
var attrs = new AosWeaponAttributes(null)
{
UseBestSkill = 1,
HitFireball = 12,
HitLeechHits = 20,
MageWeapon = 25,
SelfRepair = 3
};
var opl = new ObjectPropertyList(null);
attrs.GetProperties(opl);
var map = Decode(opl);
Assert.Equal("", map[1060400]); // UseBestSkill (no-arg)
Assert.Equal("12", map[1060420]); // HitFireball
Assert.Equal("20", map[1060422]); // HitLeechHits
Assert.Equal("5", map[1060438]); // MageWeapon => 30 - 25
Assert.Equal("3", map[1060450]); // SelfRepair
}
}

View file

@ -1010,6 +1010,101 @@ namespace Server
return value;
}
public void GetProperties(IPropertyList list)
{
int prop;
if (UseBestSkill != 0)
{
list.Add(1060400); // use best weapon skill
}
if ((prop = HitColdArea) != 0)
{
list.Add(1060416, prop); // hit cold area ~1_val~%
}
if ((prop = HitDispel) != 0)
{
list.Add(1060417, prop); // hit dispel ~1_val~%
}
if ((prop = HitEnergyArea) != 0)
{
list.Add(1060418, prop); // hit energy area ~1_val~%
}
if ((prop = HitFireArea) != 0)
{
list.Add(1060419, prop); // hit fire area ~1_val~%
}
if ((prop = HitFireball) != 0)
{
list.Add(1060420, prop); // hit fireball ~1_val~%
}
if ((prop = HitHarm) != 0)
{
list.Add(1060421, prop); // hit harm ~1_val~%
}
if ((prop = HitLeechHits) != 0)
{
list.Add(1060422, prop); // hit life leech ~1_val~%
}
if ((prop = HitLightning) != 0)
{
list.Add(1060423, prop); // hit lightning ~1_val~%
}
if ((prop = HitLowerAttack) != 0)
{
list.Add(1060424, prop); // hit lower attack ~1_val~%
}
if ((prop = HitLowerDefend) != 0)
{
list.Add(1060425, prop); // hit lower defense ~1_val~%
}
if ((prop = HitMagicArrow) != 0)
{
list.Add(1060426, prop); // hit magic arrow ~1_val~%
}
if ((prop = HitLeechMana) != 0)
{
list.Add(1060427, prop); // hit mana leech ~1_val~%
}
if ((prop = HitPhysicalArea) != 0)
{
list.Add(1060428, prop); // hit physical area ~1_val~%
}
if ((prop = HitPoisonArea) != 0)
{
list.Add(1060429, prop); // hit poison area ~1_val~%
}
if ((prop = HitLeechStam) != 0)
{
list.Add(1060430, prop); // hit stamina leech ~1_val~%
}
if ((prop = MageWeapon) != 0)
{
list.Add(1060438, 30 - prop); // mage weapon -~1_val~ skill
}
if ((prop = SelfRepair) != 0)
{
list.Add(1060450, prop); // self repair ~1_val~
}
}
public override string ToString() => "...";
}