feat(net): SocialActions — query / fellowship / channel / options outbound
Broad batch of GameActions for features the UI will wire to buttons + hotkeys: /hp query, ping keepalive, fellowship full lifecycle, character-options persist, chat channel subscribe/unsubscribe. Wire layer: - QueryHealth (0x01BF): u32 targetGuid — server replies UpdateHealth (0x01C0, already parsed by Phase F.1 dispatcher + routed to CombatState). - PingRequest (0x01E9): u32 clientId — server echoes PingResponse (0x01EA) with matching id. Keepalive use. - FellowshipCreate (0x00A2): string16L name + 2 u8 bools. - FellowshipQuit (0x00A3): u8 disband. - FellowshipDismiss (0x00A4) / FellowshipRecruit (0x00A5): u32 guid. - FellowshipUpdate (0x00A6): u8 open. - SetCharacterOptions (0x01A1): u32 options bitmap. - AddChannel (0x0145) / RemoveChannel (0x0146): string16L channelName. Tests (10 new): byte-exact wire encoding for each action. Build green, 182 Core.Net tests pass (up from 172). Ref: r08 §3 rows 0x01BF / 0x01E9 / 0x00A2-0x00A6 / 0x01A1 / 0x0145 / 0x0146. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a9f366718d
commit
fa266aaa03
2 changed files with 285 additions and 0 deletions
111
tests/AcDream.Core.Net.Tests/Messages/SocialActionsTests.cs
Normal file
111
tests/AcDream.Core.Net.Tests/Messages/SocialActionsTests.cs
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
using System;
|
||||
using System.Buffers.Binary;
|
||||
using System.Text;
|
||||
using AcDream.Core.Net.Messages;
|
||||
using Xunit;
|
||||
|
||||
namespace AcDream.Core.Net.Tests.Messages;
|
||||
|
||||
public sealed class SocialActionsTests
|
||||
{
|
||||
[Fact]
|
||||
public void BuildQueryHealth_HasOpcode0x01BFAndGuid()
|
||||
{
|
||||
byte[] body = SocialActions.BuildQueryHealth(seq: 3, targetGuid: 0xCAFE);
|
||||
Assert.Equal(SocialActions.QueryHealthOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
Assert.Equal(0xCAFEu,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(12)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildPingRequest_HasOpcode0x01E9()
|
||||
{
|
||||
byte[] body = SocialActions.BuildPingRequest(seq: 1, clientId: 42);
|
||||
Assert.Equal(SocialActions.PingRequestOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
Assert.Equal(42u,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(12)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildFellowshipCreate_StringThenBools()
|
||||
{
|
||||
byte[] body = SocialActions.BuildFellowshipCreate(
|
||||
seq: 1, fellowshipName: "Team", openness: true, shareXp: false);
|
||||
|
||||
Assert.Equal(SocialActions.FellowshipCreateOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
// String at offset 12: u16 length = 4
|
||||
ushort len = BinaryPrimitives.ReadUInt16LittleEndian(body.AsSpan(12));
|
||||
Assert.Equal(4, len);
|
||||
Assert.Equal("Team", Encoding.ASCII.GetString(body.AsSpan(14, 4)));
|
||||
// string16L record = 2+4=6, pad 2 → advance by 8.
|
||||
// Then 2 bools at offset 20,21.
|
||||
Assert.Equal(1, body[20]); // openness true
|
||||
Assert.Equal(0, body[21]); // shareXp false
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildFellowshipQuit_CarriesDisbandFlag()
|
||||
{
|
||||
byte[] body = SocialActions.BuildFellowshipQuit(seq: 1, disband: true);
|
||||
Assert.Equal(SocialActions.FellowshipQuitOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
Assert.Equal(1, body[12]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildFellowshipDismiss_HasGuid()
|
||||
{
|
||||
byte[] body = SocialActions.BuildFellowshipDismiss(seq: 1, targetGuid: 0xDEAD);
|
||||
Assert.Equal(SocialActions.FellowshipDismissOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
Assert.Equal(0xDEADu,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(12)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildFellowshipRecruit_HasGuid()
|
||||
{
|
||||
byte[] body = SocialActions.BuildFellowshipRecruit(seq: 1, targetGuid: 0xBEEF);
|
||||
Assert.Equal(SocialActions.FellowshipRecruitOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildFellowshipUpdate_HasOpenBool()
|
||||
{
|
||||
byte[] body = SocialActions.BuildFellowshipUpdate(seq: 1, open: true);
|
||||
Assert.Equal(SocialActions.FellowshipUpdateOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
Assert.Equal(1, body[12]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildSetCharacterOptions_HasBitmap()
|
||||
{
|
||||
byte[] body = SocialActions.BuildSetCharacterOptions(seq: 1, optionsBitmap: 0xDEADBEEFu);
|
||||
Assert.Equal(0xDEADBEEFu,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(12)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildAddChannel_ContainsName()
|
||||
{
|
||||
byte[] body = SocialActions.BuildAddChannel(seq: 1, channelName: "Trade");
|
||||
Assert.Equal(SocialActions.AddChannelOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
ushort len = BinaryPrimitives.ReadUInt16LittleEndian(body.AsSpan(12));
|
||||
Assert.Equal(5, len);
|
||||
Assert.Equal("Trade", Encoding.ASCII.GetString(body.AsSpan(14, 5)));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void BuildRemoveChannel_HasOpcode0x0146()
|
||||
{
|
||||
byte[] body = SocialActions.BuildRemoveChannel(seq: 1, channelName: "General");
|
||||
Assert.Equal(SocialActions.RemoveChannelOpcode,
|
||||
BinaryPrimitives.ReadUInt32LittleEndian(body.AsSpan(8)));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue