feat(net): AppraiseInfoParser — ArmorProfile/CreatureProfile/WeaponProfile + enchantment bitfields
Completes the deferred-in-previous-commit profile blob deserializers. The AppraiseInfo wire format has 10 flags; previous commit handled the 6 property tables + SpellBook; this adds the 7 remaining structured blobs: - ArmorProfile: 8× f32 per-damage-type protection values (Slashing / Piercing / Bludgeoning / Cold / Fire / Acid / Nether / Lightning). - ArmorLevel: 9× i32 per-body-part AL (Head / Chest / Abdomen / UpperArm / LowerArm / Hand / UpperLeg / LowerLeg / Foot). - WeaponProfile: 10 mixed fields — u32 DamageType / WeaponTime / WeaponSkill / Damage, f64 DamageVariance / DamageMod / WeaponLength / MaxVelocity / WeaponOffense, u32 MaxVelocityEstimated. - CreatureProfile: flag-gated — always u32 Flags + Health + HealthMax, optional 10× u32 attributes + vitals (flag 0x08 = ShowAttributes), optional 2× u16 highlight/color (flag 0x01 = HasBuffsDebuffs). - Enchantment bitfields (ArmorEnchantmentBitfield / WeaponEnchantmentBitfield / ResistEnchantmentBitfield): each 2× u16 (highlight, color). HookProfile (flag 0x200) still deferred — needs its own structure port. Parsed record expanded to carry all these; callers that previously consumed PropertyBundle + SpellBook keep working, new fields are nullable record-struct payloads. Tests (+6): ArmorProfile round-trip, ArmorLevels, WeaponProfile with mixed primitives, CreatureProfile with + without attributes flag, ArmorEnchantment bitfield. Build green, 172 Core.Net tests pass (up from 166). Ref: ACE AppraiseInfo.cs:735-778 (writer), ArmorProfile.cs / ArmorLevel.cs / WeaponProfile.cs / CreatureProfile.cs (structure writers). Ref: r08 §4 opcode 0x00C9. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
63b6922fc2
commit
a9f366718d
2 changed files with 321 additions and 5 deletions
|
|
@ -182,4 +182,144 @@ public sealed class AppraiseInfoParserTests
|
|||
{
|
||||
Assert.Null(AppraiseInfoParser.TryParse(new byte[4]));
|
||||
}
|
||||
|
||||
// ── Profile blobs ────────────────────────────────────────────────────────
|
||||
|
||||
[Fact]
|
||||
public void TryParse_ArmorProfile_ParsesEightF32()
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
using var bw = new BinaryWriter(ms);
|
||||
bw.Write(0u); // guid
|
||||
bw.Write((uint)AppraiseInfoParser.IdentifyResponseFlags.ArmorProfile);
|
||||
bw.Write(1u); // success
|
||||
// 8 float protections
|
||||
bw.Write(0.1f); bw.Write(0.2f); bw.Write(0.3f); bw.Write(0.4f);
|
||||
bw.Write(0.5f); bw.Write(0.6f); bw.Write(0.7f); bw.Write(0.8f);
|
||||
|
||||
var parsed = AppraiseInfoParser.TryParse(ms.ToArray());
|
||||
Assert.NotNull(parsed);
|
||||
Assert.NotNull(parsed!.Value.ArmorProfile);
|
||||
var armor = parsed.Value.ArmorProfile!.Value;
|
||||
Assert.Equal(0.1f, armor.SlashingProtection, 4);
|
||||
Assert.Equal(0.8f, armor.LightningProtection, 4);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryParse_ArmorLevels_NinePerBodyPart()
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
using var bw = new BinaryWriter(ms);
|
||||
bw.Write(0u);
|
||||
bw.Write((uint)AppraiseInfoParser.IdentifyResponseFlags.ArmorLevels);
|
||||
bw.Write(1u);
|
||||
bw.Write(100); // Head
|
||||
bw.Write(200); // Chest
|
||||
bw.Write(150); // Abdomen
|
||||
bw.Write(125); bw.Write(110); bw.Write(90);
|
||||
bw.Write(140); bw.Write(130); bw.Write(80);
|
||||
|
||||
var parsed = AppraiseInfoParser.TryParse(ms.ToArray());
|
||||
Assert.NotNull(parsed!.Value.ArmorLevels);
|
||||
Assert.Equal(100, parsed.Value.ArmorLevels!.Value.Head);
|
||||
Assert.Equal(200, parsed.Value.ArmorLevels.Value.Chest);
|
||||
Assert.Equal(80, parsed.Value.ArmorLevels.Value.Foot);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryParse_WeaponProfile_TenFieldsMixedPrimitives()
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
using var bw = new BinaryWriter(ms);
|
||||
bw.Write(0u);
|
||||
bw.Write((uint)AppraiseInfoParser.IdentifyResponseFlags.WeaponProfile);
|
||||
bw.Write(1u);
|
||||
bw.Write(4u); // DamageType (Fire?)
|
||||
bw.Write(30u); // WeaponTime
|
||||
bw.Write(44u); // WeaponSkill
|
||||
bw.Write(25u); // Damage
|
||||
bw.Write(0.25); // DamageVariance (f64)
|
||||
bw.Write(1.5); // DamageMod
|
||||
bw.Write(1.0); // WeaponLength
|
||||
bw.Write(2.0); // MaxVelocity
|
||||
bw.Write(1.1); // WeaponOffense
|
||||
bw.Write(5u); // MaxVelocityEstimated
|
||||
|
||||
var parsed = AppraiseInfoParser.TryParse(ms.ToArray());
|
||||
Assert.NotNull(parsed!.Value.WeaponProfile);
|
||||
var w = parsed.Value.WeaponProfile!.Value;
|
||||
Assert.Equal(4u, w.DamageType);
|
||||
Assert.Equal(25u, w.Damage);
|
||||
Assert.Equal(1.5, w.DamageMod, 4);
|
||||
Assert.Equal(5u, w.MaxVelocityEstimated);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryParse_CreatureProfile_AttributesPresent_WhenShowAttributesFlag()
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
using var bw = new BinaryWriter(ms);
|
||||
bw.Write(0u);
|
||||
bw.Write((uint)AppraiseInfoParser.IdentifyResponseFlags.CreatureProfile);
|
||||
bw.Write(1u);
|
||||
bw.Write(0x08u); // flags: ShowAttributes only
|
||||
bw.Write(500u); // Health
|
||||
bw.Write(600u); // HealthMax
|
||||
bw.Write(80u); // Str
|
||||
bw.Write(70u); // End
|
||||
bw.Write(65u); // Quic
|
||||
bw.Write(60u); // Coord
|
||||
bw.Write(100u); // Focus
|
||||
bw.Write(100u); // Self
|
||||
bw.Write(200u); // Stamina
|
||||
bw.Write(150u); // Mana
|
||||
bw.Write(250u); // StaminaMax
|
||||
bw.Write(200u); // ManaMax
|
||||
|
||||
var parsed = AppraiseInfoParser.TryParse(ms.ToArray());
|
||||
Assert.NotNull(parsed!.Value.CreatureProfile);
|
||||
var c = parsed.Value.CreatureProfile!.Value;
|
||||
Assert.Equal(0x08u, c.Flags);
|
||||
Assert.Equal(500u, c.Health);
|
||||
Assert.Equal(600u, c.HealthMax);
|
||||
Assert.Equal((uint?)80u, c.Strength);
|
||||
Assert.Equal((uint?)150u, c.Mana);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryParse_CreatureProfile_NoAttributesFlag_OnlyHealth()
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
using var bw = new BinaryWriter(ms);
|
||||
bw.Write(0u);
|
||||
bw.Write((uint)AppraiseInfoParser.IdentifyResponseFlags.CreatureProfile);
|
||||
bw.Write(1u);
|
||||
bw.Write(0u); // flags = 0
|
||||
bw.Write(300u); // Health
|
||||
bw.Write(400u); // HealthMax
|
||||
|
||||
var parsed = AppraiseInfoParser.TryParse(ms.ToArray());
|
||||
Assert.NotNull(parsed!.Value.CreatureProfile);
|
||||
var c = parsed.Value.CreatureProfile!.Value;
|
||||
Assert.Null(c.Strength);
|
||||
Assert.Null(c.AttributeHighlights);
|
||||
Assert.Equal(300u, c.Health);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TryParse_ArmorEnchantmentBitfield_HighlightAndColor()
|
||||
{
|
||||
using var ms = new MemoryStream();
|
||||
using var bw = new BinaryWriter(ms);
|
||||
bw.Write(0u);
|
||||
bw.Write((uint)AppraiseInfoParser.IdentifyResponseFlags.ArmorEnchantmentBitfield);
|
||||
bw.Write(1u);
|
||||
bw.Write((ushort)0x00FF);
|
||||
bw.Write((ushort)0x0042);
|
||||
|
||||
var parsed = AppraiseInfoParser.TryParse(ms.ToArray());
|
||||
Assert.NotNull(parsed!.Value.ArmorEnchantments);
|
||||
Assert.Equal((ushort)0x00FF, parsed.Value.ArmorEnchantments!.Value.Highlight);
|
||||
Assert.Equal((ushort)0x0042, parsed.Value.ArmorEnchantments.Value.Color);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue