feat(runtime): share chat commands and run login sequence
This commit is contained in:
parent
5535d0adac
commit
41b15efd4d
57 changed files with 1739 additions and 345 deletions
|
|
@ -0,0 +1,59 @@
|
|||
using AcDream.Core.Chat;
|
||||
using AcDream.Runtime.Chat;
|
||||
using AcDream.Runtime.Gameplay;
|
||||
|
||||
namespace AcDream.Runtime.Tests.Chat;
|
||||
|
||||
public sealed class LiveChatCommandRouteTests
|
||||
{
|
||||
[Fact]
|
||||
public void FourRegistrationsPreserveOrderedWireRoutesAndCanonicalEcho()
|
||||
{
|
||||
using var communication = new RuntimeCommunicationState();
|
||||
using var character = new RuntimeCharacterState();
|
||||
var sent = new List<string>();
|
||||
var route = new LiveChatCommandRoute(new LiveChatCommandBindings(
|
||||
command => sent.Add($"client:{command.Command}"),
|
||||
communication,
|
||||
communication.Chat,
|
||||
communication.TurbineChat,
|
||||
character,
|
||||
() => 0x50000001u,
|
||||
text => sent.Add($"talk:{text}"),
|
||||
(target, text) => sent.Add($"tell:{target}:{text}"),
|
||||
(channel, text) => sent.Add($"channel:{channel:X8}:{text}"),
|
||||
(_, _, _, _, text, _) => sent.Add($"turbine:{text}")));
|
||||
|
||||
route.Activate();
|
||||
route.Publish(new SendServerCommandCmd("@server"));
|
||||
route.Publish(new SendChatCmd(ChatChannelKind.Say, null, "say"));
|
||||
route.Publish(new SendChatCmd(ChatChannelKind.Tell, "Bob", "secret"));
|
||||
route.Publish(new SendChatCmd(
|
||||
ChatChannelKind.Fellowship,
|
||||
null,
|
||||
"group"));
|
||||
route.Publish(new SendRawChannelCmd(0x00000002u, "admin"));
|
||||
route.Publish(new ExecuteClientCommandCmd(
|
||||
ClientCommandId.QueryAge,
|
||||
string.Empty));
|
||||
|
||||
Assert.Equal(
|
||||
[
|
||||
"talk:@server",
|
||||
"talk:say",
|
||||
"tell:Bob:secret",
|
||||
"channel:00000800:group",
|
||||
"channel:00000002:admin",
|
||||
"client:QueryAge",
|
||||
],
|
||||
sent);
|
||||
ChatEntry echo = Assert.Single(communication.Chat.Snapshot());
|
||||
Assert.Equal(ChatKind.Tell, echo.Kind);
|
||||
Assert.Equal("Bob", echo.Sender);
|
||||
Assert.Equal("secret", echo.Text);
|
||||
|
||||
route.Dispose();
|
||||
route.Publish(new SendServerCommandCmd("@stale"));
|
||||
Assert.Equal(6, sent.Count);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue