using AcDream.Core.Chat; namespace AcDream.Core.Tests.Chat; /// /// Phase J: teaches the log /// to recognize ACE's HearSpeech echo of the local player's own /say /// — the server broadcasts to all in range INCLUDING the sender, so /// we'd otherwise see both our optimistic "You say" and the /// third-person "+Acdream says" from the server. Substituting the /// sender to "" routes through the formatter's IsOwnSpeaker path so /// only the singular first-person line shows. /// public sealed class ChatLogLocalGuidTests { [Fact] public void OnLocalSpeech_OwnGuidMatch_SubstitutesYou() { var log = new ChatLog(); log.SetLocalPlayerGuid(0x5000_000A); log.OnLocalSpeech("+Acdream", "hello world", senderGuid: 0x5000_000A, isRanged: false); var entry = log.Snapshot()[0]; Assert.Equal(ChatKind.LocalSpeech, entry.Kind); Assert.Equal("You", entry.Sender); Assert.Equal("hello world", entry.Text); } [Fact] public void OnLocalSpeech_DifferentGuid_KeepsSenderName() { var log = new ChatLog(); log.SetLocalPlayerGuid(0x5000_000A); log.OnLocalSpeech("Caith", "hi", senderGuid: 0x5000_0042, isRanged: false); Assert.Equal("Caith", log.Snapshot()[0].Sender); } [Fact] public void OnLocalSpeech_NoLocalGuidSet_FallsBackToEmptySubstitution() { // Pre-login (guid not yet known), the existing empty-sender // substitution still applies — server-driven ranged echoes // arrive with sender="" before the player has a guid. var log = new ChatLog(); log.OnLocalSpeech("", "anyone home?", senderGuid: 0u, isRanged: true); Assert.Equal("You", log.Snapshot()[0].Sender); Assert.Equal(ChatKind.RangedSpeech, log.Snapshot()[0].Kind); } }