Skip to content

Commit

Permalink
Modify guild description (#366)
Browse files Browse the repository at this point in the history
* Add InGuild ReadOnly property to ICharacterProvider

* Add GuildEventNotifer and Subscriber

* Add GuildReply handler

* Add GuildTake handler

* Add Dialog and Resource IDs

* Provider MessageBoxFactory and GuildSessionProvider to dialog

* Add Get/Set GuildDescription to GuildActions

* Add GuildDescription to GuildSessionRepository

* Add Modify guild state
Looks up guild description
Added modify description box that updates description

* Make link underlined and remove `*` from start of line

* cleanup

* remove InGuild

* Fix back action

* formatting

* Refactor from PR

* Change list style to `Small` for modify state

* Fix code formatting violations

* Modify state transition mechanism to use well-named static instances of State class with more explicit default values

---------

Co-authored-by: Ethan Moffat <ethan@moffat.io>
  • Loading branch information
sorokya and ethanmoffat authored Oct 18, 2024
1 parent 32b10d8 commit 3e09fb0
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 178 deletions.
3 changes: 2 additions & 1 deletion EOLib.Localization/DialogResourceID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public enum DialogResourceID
GUILD_MEMBER_HAS_BEEN_ACCEPTED = 174,
GUILD_DOES_NOT_EXIST = 176,
GUILD_YOU_HAVE_BEEN_ACCEPTED = 178,
GUILD_DETAILS_HAVE_BEEN_UPDATED = 180,
GUILD_ACCEPTED = 180,
GUILD_DETAILS_HAVE_BEEN_UPDATED = 181,
GUILD_PROMPT_DISBAND_GUILD = 182,
GUILD_REMOVE_MEMBER_WHO = 184,
GUILD_REMOVE_PLAYER_NOT_MEMBER = 186,
Expand Down
3 changes: 3 additions & 0 deletions EOLib.Localization/EOResourceID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,13 @@ public enum EOResourceID
GUILD_REMOVE_A_MEMBER_FROM_GUILD = 203,
GUILD_JOINING_A_GUILD_IS_FREE = 205,
GUILD_PLEASE_CONSIDER_CAREFULLY = 207,
GUILD_DESCRIPTION = 219,
GUILD_DO_YOU_ACCEPT = 223,
GUILD_YOUR_ACCOUNT_WILL_BE_CHARGED = 225,
GUILD_PLEASE_CONSIDER_CAREFULLY_RECRUIT = 226,
GUILD_ASSIGN_RANK_TO_MEMBER = 233,
GUILD_CURRENT_DESCRIPTION = 234,
GUILD_CLICK_HERE_TO_CHANGE_THE_DESCRIPTION = 235,

SETTING_KEYBOARD_ENGLISH = 253,
SETTING_KEYBOARD_DUTCH = 254,
Expand Down
27 changes: 27 additions & 0 deletions EOLib/Domain/Interact/Guild/GuildActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,39 @@ public void ViewMembers(string identity)
{
_packetSendService.SendPacket(new GuildTellClientPacket { SessionId = _guildSessionProvider.SessionID, GuildIdentity = identity });
}

public void GetGuildDescription(string guildTag)
{
_packetSendService.SendPacket(new GuildTakeClientPacket
{
SessionId = _guildSessionProvider.SessionID,
InfoType = GuildInfoType.Description,
GuildTag = guildTag
});
}

public void SetGuildDescription(string description)
{
_packetSendService.SendPacket(new GuildAgreeClientPacket()
{
SessionId = _guildSessionProvider.SessionID,
InfoType = GuildInfoType.Description,
InfoTypeData = new GuildAgreeClientPacket.InfoTypeDataDescription()
{
Description = description
}
});
}
}

public interface IGuildActions
{
void Lookup(string identity);

void ViewMembers(string identity);

void GetGuildDescription(string guildTag);

void SetGuildDescription(string description);
}
}
6 changes: 6 additions & 0 deletions EOLib/Domain/Interact/Guild/GuildSessionRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,27 @@ namespace EOLib.Domain.Interact.Guild
public interface IGuildSessionProvider
{
int SessionID { get; }

string GuildDescription { get; }
}

public interface IGuildSessionRepository
{
int SessionID { get; set; }

string GuildDescription { get; set; }
}

[AutoMappedType(IsSingleton = true)]
public class GuildSessionRepository : IGuildSessionRepository, IGuildSessionProvider
{
public int SessionID { get; set; }
public string GuildDescription { get; set; }

public GuildSessionRepository()
{
SessionID = 0;
GuildDescription = "";
}
}
}
2 changes: 2 additions & 0 deletions EOLib/Domain/Notifiers/IGuildNotifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ public interface IGuildNotifier
{
void NotifyGuildCreationRequest(int creatorPlayerID, string guildIdentity);
void NotifyRequestToJoinGuild(int playerId, string name);
void NotifyGuildDetailsUpdated();
}

[AutoMappedType]
public class NoOpGuildNotifier : IGuildNotifier
{
public void NotifyGuildCreationRequest(int creatorPlayerID, string guildIdentity) { }
public void NotifyRequestToJoinGuild(int playerId, string name) { }
public void NotifyGuildDetailsUpdated() { }
}
}
11 changes: 7 additions & 4 deletions EOLib/PacketHandlers/Guild/GuildReplyHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
namespace EOLib.PacketHandlers.Guild
{
[AutoMappedType]

public class GuildReplyHandler : InGameOnlyPacketHandler<GuildReplyServerPacket>
{
private readonly IEnumerable<IGuildNotifier> _guildNotifiers;
Expand All @@ -19,7 +18,7 @@ public class GuildReplyHandler : InGameOnlyPacketHandler<GuildReplyServerPacket>
public override PacketAction Action => PacketAction.Reply;

public GuildReplyHandler(IPlayerInfoProvider playerInfoProvider,
IEnumerable<IGuildNotifier> guildNotifiers)
IEnumerable<IGuildNotifier> guildNotifiers)
: base(playerInfoProvider)
{
_guildNotifiers = guildNotifiers;
Expand All @@ -30,9 +29,13 @@ public override bool HandlePacket(GuildReplyServerPacket packet)
switch (packet.ReplyCode)
{
case GuildReply.JoinRequest:
var data = (GuildReplyServerPacket.ReplyCodeDataJoinRequest)(packet.ReplyCodeData);
var joinRequestData = (GuildReplyServerPacket.ReplyCodeDataJoinRequest)(packet.ReplyCodeData);
foreach (var notifier in _guildNotifiers)
notifier.NotifyRequestToJoinGuild(joinRequestData.PlayerId, joinRequestData.Name);
break;
case GuildReply.Updated:
foreach (var notifier in _guildNotifiers)
notifier.NotifyRequestToJoinGuild(data.PlayerId, data.Name);
notifier.NotifyGuildDetailsUpdated();
break;
}

Expand Down
38 changes: 38 additions & 0 deletions EOLib/PacketHandlers/Guild/GuildTakeHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using AutomaticTypeMapper;
using EOLib.Domain.Interact;
using EOLib.Domain.Interact.Guild;
using EOLib.Domain.Login;
using EOLib.Domain.Map;
using EOLib.Net.Handlers;
using Moffat.EndlessOnline.SDK.Protocol.Net;
using Moffat.EndlessOnline.SDK.Protocol.Net.Server;
using Optional;
using System.Collections.Generic;

namespace EOLib.PacketHandlers.Guild
{
[AutoMappedType]

public class GuildTakeHandler : InGameOnlyPacketHandler<GuildTakeServerPacket>
{
private readonly IGuildSessionRepository _guildSessionRepository;

public override PacketFamily Family => PacketFamily.Guild;

public override PacketAction Action => PacketAction.Take;

public GuildTakeHandler(IPlayerInfoProvider playerInfoProvider,
IGuildSessionRepository guildSessionRepository)
: base(playerInfoProvider)
{
_guildSessionRepository = guildSessionRepository;
}

public override bool HandlePacket(GuildTakeServerPacket packet)
{
_guildSessionRepository.GuildDescription = packet.Description;

return true;
}
}
}
31 changes: 24 additions & 7 deletions EndlessClient/Dialogs/Factories/GuildDialogFactory.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using AutomaticTypeMapper;
using EndlessClient.Content;
using EndlessClient.Dialogs.Services;
using EOLib.Domain.Character;
using EOLib.Domain.Interact.Guild;
using EOLib.Graphics;
using EOLib.Localization;

Expand All @@ -15,31 +17,46 @@ public class GuildDialogFactory : IGuildDialogFactory
private readonly ILocalizedStringFinder _localizedStringFinder;
private readonly ICharacterProvider _characterProvider;
private readonly IEOMessageBoxFactory _messageBoxFactory;
private readonly IGuildSessionProvider _guildSessionProvider;
private readonly IGuildActions _guildActions;
private readonly ITextInputDialogFactory _textInputDialogFactory;
private readonly IContentProvider _contentProvider;

public GuildDialogFactory(INativeGraphicsManager nativeGraphicsManager,
IEODialogButtonService dialogButtonService,
IEODialogIconService dialogIconService,
ILocalizedStringFinder localizedStringFinder,
ICharacterProvider characterProvider,
IEOMessageBoxFactory messageBoxFactory)
IEOMessageBoxFactory messageBoxFactory,
IGuildSessionProvider guildSessionProvider,
IGuildActions guildActions,
ITextInputDialogFactory textInputDialogFactory,
IContentProvider contentProvider)
{
_nativeGraphicsManager = nativeGraphicsManager;
_dialogButtonService = dialogButtonService;
_dialogIconService = dialogIconService;
_localizedStringFinder = localizedStringFinder;
_characterProvider = characterProvider;
_messageBoxFactory = messageBoxFactory;
_guildSessionProvider = guildSessionProvider;
_guildActions = guildActions;
_textInputDialogFactory = textInputDialogFactory;
_contentProvider = contentProvider;
}

public GuildDialog Create()
{
return new GuildDialog(_nativeGraphicsManager,
_dialogButtonService,
_dialogIconService,
_localizedStringFinder,
_characterProvider,
_messageBoxFactory
);
_dialogButtonService,
_dialogIconService,
_localizedStringFinder,
_characterProvider,
_messageBoxFactory,
_guildSessionProvider,
_guildActions,
_textInputDialogFactory,
_contentProvider);
}
}

Expand Down
Loading

0 comments on commit 3e09fb0

Please sign in to comment.