feat(chat): route retail lifestone commands

Separate retail client actions, ACE server commands, and ordinary chat at the shared router. Port lifestone/lif/ls from the named retail registry through a typed App controller to game action 0x0063, keep unknown verbs on ACE Talk, and cover both UI backends plus exact outbound bytes.

Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
Erik 2026-07-13 11:43:19 +02:00
parent 5090aa7217
commit 5a45a7ac7f
19 changed files with 604 additions and 78 deletions

View file

@ -9,11 +9,10 @@ public class ChatCommandRouterTests
{
private sealed class CaptureBus : ICommandBus
{
public SendChatCmd? Last;
public List<object> Published { get; } = new();
public void Publish<T>(T command) where T : notnull
{
if (command is SendChatCmd c) Last = c;
}
=> Published.Add(command);
}
private static (ChatVM vm, ChatLog log, CaptureBus bus) Fixture()
@ -28,10 +27,11 @@ public class ChatCommandRouterTests
{
var (vm, _, bus) = Fixture();
var outcome = ChatCommandRouter.Submit("hello there", vm, bus, ChatChannelKind.Say);
Assert.Equal(SubmitOutcome.Sent, outcome);
Assert.NotNull(bus.Last);
Assert.Equal(ChatChannelKind.Say, bus.Last!.Channel);
Assert.Equal("hello there", bus.Last.Text);
var command = Assert.IsType<SendChatCmd>(Assert.Single(bus.Published));
Assert.Equal(ChatChannelKind.Say, command.Channel);
Assert.Equal("hello there", command.Text);
}
[Fact]
@ -39,7 +39,9 @@ public class ChatCommandRouterTests
{
var (vm, _, bus) = Fixture();
ChatCommandRouter.Submit("hi", vm, bus, ChatChannelKind.Fellowship);
Assert.Equal(ChatChannelKind.Fellowship, bus.Last!.Channel);
var command = Assert.IsType<SendChatCmd>(Assert.Single(bus.Published));
Assert.Equal(ChatChannelKind.Fellowship, command.Channel);
}
[Fact]
@ -47,48 +49,80 @@ public class ChatCommandRouterTests
{
var (vm, log, bus) = Fixture();
log.OnSystemMessage("x", chatType: 0);
var outcome = ChatCommandRouter.Submit("/clear", vm, bus, ChatChannelKind.Say);
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
Assert.Null(bus.Last);
Assert.Empty(bus.Published);
Assert.Empty(log.Snapshot());
}
[Fact]
public void UnknownSlashVerb_RoutesToServerInAtForm()
[Theory]
[InlineData("/lifestone")]
[InlineData("/lif")]
[InlineData("/ls")]
[InlineData("@LS")]
public void LifestoneAliases_PublishTypedClientCommand(string input)
{
var (vm, _, bus) = Fixture();
var outcome = ChatCommandRouter.Submit(input, vm, bus, ChatChannelKind.Fellowship);
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
var command = Assert.IsType<ExecuteClientCommandCmd>(Assert.Single(bus.Published));
Assert.Equal(ClientCommandId.LifestoneRecall, command.Command);
}
[Fact]
public void LifestoneWithArguments_ShowsUsageAndPublishesNothing()
{
// Retail / ≡ @: unknown verbs are the server's to judge. The
// parser rewrites /-form to @-form (ACE's GameActionTalk only
// intercepts @ on the wire); ACE answers "Unknown command: x"
// for verbs it doesn't know — no local guess.
var (vm, log, bus) = Fixture();
var outcome = ChatCommandRouter.Submit("/notacommand", vm, bus, ChatChannelKind.Say);
var outcome = ChatCommandRouter.Submit("/ls now", vm, bus, ChatChannelKind.Say);
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
Assert.Empty(bus.Published);
Assert.Contains(log.Snapshot(), entry => entry.Text == "Usage: /lifestone");
}
[Fact]
public void UnknownSlashVerb_RoutesThroughExplicitServerCommand()
{
var (vm, log, bus) = Fixture();
var outcome = ChatCommandRouter.Submit(
"/notacommand", vm, bus, ChatChannelKind.Say);
Assert.Equal(SubmitOutcome.Sent, outcome);
Assert.NotNull(bus.Last);
Assert.Equal("@notacommand", bus.Last!.Text);
Assert.DoesNotContain(log.Snapshot(), e => e.Text.Contains("Unknown command"));
var command = Assert.IsType<SendServerCommandCmd>(Assert.Single(bus.Published));
Assert.Equal("@notacommand", command.Text);
Assert.DoesNotContain(log.Snapshot(), entry => entry.Text.Contains("Unknown command"));
}
[Theory]
[InlineData("/ci 629 5")]
[InlineData("@ci 629 5")]
public void ServerCommandWithArgs_PublishesCanonicalAtFormAsSay_EvenOnChannelDefault(string command)
public void ServerCommandWithArgs_PublishesCanonicalAtForm_EvenOnChannelDefault(
string input)
{
// Commands resolve before channel routing (retail behavior):
// even with Fellowship as the active input channel, a command
// goes out as Say/Talk — the only wire action ACE parses @ on.
var (vm, _, bus) = Fixture();
var outcome = ChatCommandRouter.Submit(command, vm, bus, ChatChannelKind.Fellowship);
var outcome = ChatCommandRouter.Submit(
input, vm, bus, ChatChannelKind.Fellowship);
Assert.Equal(SubmitOutcome.Sent, outcome);
Assert.Equal(ChatChannelKind.Say, bus.Last!.Channel);
Assert.Equal("@ci 629 5", bus.Last.Text);
var command = Assert.IsType<SendServerCommandCmd>(Assert.Single(bus.Published));
Assert.Equal("@ci 629 5", command.Text);
}
[Fact]
public void EmptyInput_DoesNothing()
{
var (vm, _, bus) = Fixture();
var outcome = ChatCommandRouter.Submit(" ", vm, bus, ChatChannelKind.Say);
Assert.Equal(SubmitOutcome.Empty, outcome);
Assert.Null(bus.Last);
Assert.Empty(bus.Published);
}
}