feat(net): InventoryActions — stack merge/split + give + shortcut + poi recall
Outbound GameActions for the inventory/drag-drop UI and quickbar: - StackableMerge (0x0054): u32 mergeFrom, u32 mergeTo, u32 amount. Combine two same-type stacks. - StackableSplitToContainer (0x0055): u32 stack, u32 container, u32 placement, u32 amount. Drag a portion of a stack into a pack slot. - StackableSplitTo3D (0x0056): u32 stack, u32 amount. Drop N items to the ground. - StackableSplitToWield (0x019B): u32 stack, u32 equipLoc, u32 amount. Split off and immediately equip (e.g. split an arrow stack to missile-ammo slot). - GiveObjectRequest (0x00CD): u32 target, u32 item, u32 amount. Give to NPC / other player. - AddShortcut (0x019C): u32 slot, u32 objectType, u32 targetId. Pin an item / spell to a quickbar. - RemoveShortcut (0x019D): u32 slot. Unpin. - TeleToPoi (0x00B1): u32 poiId. Quest-driven recall. Tests (8 new): byte-exact encoding of each action, including size assertions so breaking changes surface immediately. Build green, 190 Core.Net tests pass (up from 182). Ref: r08 §3 inventory / shortcut rows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fa266aaa03
commit
d8c68c6648
2 changed files with 242 additions and 0 deletions
109
tests/AcDream.Core.Net.Tests/Messages/InventoryActionsTests.cs
Normal file
109
tests/AcDream.Core.Net.Tests/Messages/InventoryActionsTests.cs
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using AcDream.Core.Net.Messages;
|
||||
using Xunit;
|
||||
|
||||
namespace AcDream.Core.Net.Tests.Messages;
|
||||
|
||||
public sealed class InventoryActionsTests
|
||||
{
|
||||
[Fact]
|
||||
public void BuildStackableMerge_CarriesBothGuidsAndAmount()
|
||||
{
|
||||
byte[] body = InventoryActions.BuildStackableMerge(
|
||||
seq: 1, mergeFromGuid: 0xAA, mergeToGuid: 0xBB, amount: 5);
|
||||
|
||||
Assert.Equal(24, body.Length);
|
||||
Assert.Equal(InventoryActions.StackableMergeOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
Assert.Equal(0xAAu,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(12)));
|
||||
Assert.Equal(0xBBu,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(16)));
|
||||
Assert.Equal(5u,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(20)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildStackableSplitToContainer_FourFields()
|
||||
{
|
||||
byte[] body = InventoryActions.BuildStackableSplitToContainer(
|
||||
seq: 1, stackGuid: 0xAA, containerGuid: 0xBB, placement: 3, amount: 10);
|
||||
|
||||
Assert.Equal(28, body.Length);
|
||||
Assert.Equal(InventoryActions.StackableSplitToContainerOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
Assert.Equal(3u,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(20)));
|
||||
Assert.Equal(10u,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(24)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildStackableSplitTo3D_TwoFields()
|
||||
{
|
||||
byte[] body = InventoryActions.BuildStackableSplitTo3D(
|
||||
seq: 1, stackGuid: 0xAA, amount: 3);
|
||||
Assert.Equal(20, body.Length);
|
||||
Assert.Equal(InventoryActions.StackableSplitTo3DOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildStackableSplitToWield_HasEquipLocation()
|
||||
{
|
||||
byte[] body = InventoryActions.BuildStackableSplitToWield(
|
||||
seq: 1, stackGuid: 0xAA, equipLocation: 0x00400000, amount: 1);
|
||||
Assert.Equal(0x00400000u,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(16)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildGiveObjectRequest_TargetItemAmount()
|
||||
{
|
||||
byte[] body = InventoryActions.BuildGiveObjectRequest(
|
||||
seq: 1, targetGuid: 0xAA, itemGuid: 0xBB, amount: 2);
|
||||
Assert.Equal(InventoryActions.GiveObjectRequestOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
Assert.Equal(0xAAu,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(12)));
|
||||
Assert.Equal(0xBBu,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(16)));
|
||||
Assert.Equal(2u,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(20)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildAddShortcut_ThreeFields()
|
||||
{
|
||||
byte[] body = InventoryActions.BuildAddShortcut(
|
||||
seq: 1, slotIndex: 0, objectType: 1, targetId: 0x3E1);
|
||||
Assert.Equal(InventoryActions.AddShortcutOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
Assert.Equal(0u,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(12)));
|
||||
Assert.Equal(1u,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(16)));
|
||||
Assert.Equal(0x3E1u,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(20)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildRemoveShortcut_HasSlotOnly()
|
||||
{
|
||||
byte[] body = InventoryActions.BuildRemoveShortcut(seq: 1, slotIndex: 5);
|
||||
Assert.Equal(16, body.Length);
|
||||
Assert.Equal(5u,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(12)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildTeleToPoi_SimpleIdPayload()
|
||||
{
|
||||
byte[] body = InventoryActions.BuildTeleToPoi(seq: 1, poiId: 42);
|
||||
Assert.Equal(InventoryActions.TeleToPoiOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
Assert.Equal(42u,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(12)));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue