diff --git a/EOLib/Domain/Character/CharacterActions.cs b/EOLib/Domain/Character/CharacterActions.cs index 5f292bf27..f73b4d00c 100644 --- a/EOLib/Domain/Character/CharacterActions.cs +++ b/EOLib/Domain/Character/CharacterActions.cs @@ -126,7 +126,6 @@ public void CastSpell(int spellId, ISpellTargetable target) if (data.Target == IO.SpellTarget.Group) { - // todo: implement packet handling for group target spells builder = builder .AddShort((short)spellId) .AddThree(DateTime.Now.ToEOTimeStamp()); diff --git a/EOLib/Domain/Chat/ChatActions.cs b/EOLib/Domain/Chat/ChatActions.cs index aea3e1ab6..145aff7d4 100644 --- a/EOLib/Domain/Chat/ChatActions.cs +++ b/EOLib/Domain/Chat/ChatActions.cs @@ -1,5 +1,6 @@ using AutomaticTypeMapper; using EOLib.Domain.Character; +using EOLib.Domain.Party; using EOLib.Net; using EOLib.Net.Builders; using EOLib.Net.Communication; @@ -15,6 +16,7 @@ public enum ChatResult HideSpeechBubble, Command, AdminAnnounce, + HideAll, } [AutoMappedType] @@ -22,6 +24,7 @@ public class ChatActions : IChatActions { private readonly IChatRepository _chatRepository; private readonly ICharacterProvider _characterProvider; + private readonly IPartyDataProvider _partyDataProvider; private readonly IChatTypeCalculator _chatTypeCalculator; private readonly IChatPacketBuilder _chatPacketBuilder; private readonly IPacketSendService _packetSendService; @@ -30,6 +33,7 @@ public class ChatActions : IChatActions public ChatActions(IChatRepository chatRepository, ICharacterProvider characterProvider, + IPartyDataProvider partyDataProvider, IChatTypeCalculator chatTypeCalculator, IChatPacketBuilder chatPacketBuilder, IPacketSendService packetSendService, @@ -38,6 +42,7 @@ public ChatActions(IChatRepository chatRepository, { _chatRepository = chatRepository; _characterProvider = characterProvider; + _partyDataProvider = partyDataProvider; _chatTypeCalculator = chatTypeCalculator; _chatPacketBuilder = chatPacketBuilder; _packetSendService = packetSendService; @@ -47,8 +52,6 @@ public ChatActions(IChatRepository chatRepository, public (ChatResult, string) SendChatToServer(string chat, string targetCharacter) { - // todo: if not in a group, don't do group chat - var chatType = _chatTypeCalculator.CalculateChatType(chat); if (chatType == ChatType.Command) @@ -66,6 +69,10 @@ public ChatActions(IChatRepository chatRepository, else if (string.IsNullOrEmpty(_chatRepository.PMTarget2)) _chatRepository.PMTarget2 = targetCharacter; } + else if (chatType == ChatType.Party && !_partyDataProvider.Members.Any()) + { + return (ChatResult.HideAll, String.Empty); + } chat = _chatProcessor.RemoveFirstCharacterIfNeeded(chat, chatType, targetCharacter); var (ok, filtered) = _chatProcessor.FilterCurses(chat); diff --git a/EndlessClient/Controllers/ChatController.cs b/EndlessClient/Controllers/ChatController.cs index 1c4573033..915ad320d 100644 --- a/EndlessClient/Controllers/ChatController.cs +++ b/EndlessClient/Controllers/ChatController.cs @@ -69,6 +69,7 @@ public void SendChatAndClearTextBox() break; case ChatResult.AdminAnnounce: _sfxPlayer.PlaySfx(SoundEffectID.AdminAnnounceReceived); break; case ChatResult.HideSpeechBubble: break; // no-op + case ChatResult.HideAll: break; // no-op } } diff --git a/EndlessClient/HUD/Chat/ChatBubbleActions.cs b/EndlessClient/HUD/Chat/ChatBubbleActions.cs index bb543e54c..c446f1c20 100644 --- a/EndlessClient/HUD/Chat/ChatBubbleActions.cs +++ b/EndlessClient/HUD/Chat/ChatBubbleActions.cs @@ -3,7 +3,9 @@ using EndlessClient.Rendering.Chat; using EndlessClient.Rendering.NPC; using EOLib.Domain.Chat; +using EOLib.Domain.Party; using Optional; +using System.Linq; namespace EndlessClient.HUD.Chat { @@ -14,30 +16,35 @@ public class ChatBubbleActions : IChatBubbleActions private readonly IChatTypeCalculator _chatTypeCalculator; private readonly ICharacterRendererProvider _characterRendererProvider; private readonly INPCRendererProvider _npcRendererProvider; + private readonly IPartyDataProvider _partyDataProvider; private readonly IChatBubbleFactory _chatBubbleFactory; public ChatBubbleActions(IChatProcessor chatProcessor, IChatTypeCalculator chatTypeCalculator, ICharacterRendererProvider characterRendererProvider, INPCRendererProvider npcRendererProvider, + IPartyDataProvider partyDataProvider, IChatBubbleFactory chatBubbleFactory) { _chatProcessor = chatProcessor; _chatTypeCalculator = chatTypeCalculator; _characterRendererProvider = characterRendererProvider; _npcRendererProvider = npcRendererProvider; + _partyDataProvider = partyDataProvider; _chatBubbleFactory = chatBubbleFactory; } public void ShowChatBubbleForMainCharacter(string input) { - //todo: don't show chat bubble if group chat and character is not in a group (party) _characterRendererProvider.MainCharacterRenderer.MatchSome(r => { _chatTypeCalculator.CalculateChatType(input) .SomeWhen(x => x == ChatType.Local || x == ChatType.Party || x == ChatType.Announce) .MatchSome(chatType => { + if (!_partyDataProvider.Members.Any() && chatType == ChatType.Party) + return; + var text = _chatProcessor.RemoveFirstCharacterIfNeeded(input, chatType, string.Empty); r.ShowChatBubble(text, chatType == ChatType.Party); });