-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement skill learning and packet handling for skill learn error
- Loading branch information
1 parent
e29ec80
commit fbe9366
Showing
10 changed files
with
308 additions
and
239 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,21 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Interact.Skill; | ||
using EOLib.IO; | ||
|
||
namespace EOLib.Domain.Interact | ||
{ | ||
public interface INPCInteractionNotifier | ||
{ | ||
void NotifyInteractionFromNPC(NPCType npcType); | ||
|
||
void NotifySkillLearnFail(SkillmasterReply skillmasterReply, short classId); | ||
} | ||
|
||
[AutoMappedType] | ||
public class NoOpNPCInteractionNotifier : INPCInteractionNotifier | ||
{ | ||
public void NotifyInteractionFromNPC(NPCType npcType) { } | ||
|
||
public void NotifySkillLearnFail(SkillmasterReply skillmasterReply, short classId) { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Net; | ||
using EOLib.Net.Communication; | ||
|
||
namespace EOLib.Domain.Interact.Skill | ||
{ | ||
[AutoMappedType] | ||
public class SkillmasterActions : ISkillmasterActions | ||
{ | ||
private readonly IPacketSendService _packetSendService; | ||
private readonly ISkillDataProvider _skillDataProvider; | ||
|
||
public SkillmasterActions(IPacketSendService packetSendService, | ||
ISkillDataProvider skillDataProvider) | ||
{ | ||
_packetSendService = packetSendService; | ||
_skillDataProvider = skillDataProvider; | ||
} | ||
|
||
public void LearnSkill(short spellId) | ||
{ | ||
var packet = new PacketBuilder(PacketFamily.StatSkill, PacketAction.Take) | ||
.AddInt(_skillDataProvider.ID) | ||
.AddShort(spellId) | ||
.Build(); | ||
|
||
_packetSendService.SendPacket(packet); | ||
} | ||
} | ||
|
||
public interface ISkillmasterActions | ||
{ | ||
void LearnSkill(short spellId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Interact; | ||
using EOLib.Domain.Interact.Skill; | ||
using EOLib.Domain.Login; | ||
using EOLib.Net; | ||
using EOLib.Net.Handlers; | ||
using System.Collections.Generic; | ||
|
||
namespace EOLib.PacketHandlers.Skill | ||
{ | ||
/// <summary> | ||
/// Sent when failing to learn a skill from skillmaster | ||
/// </summary> | ||
[AutoMappedType] | ||
public class StatskillReplyHandler : InGameOnlyPacketHandler | ||
{ | ||
private readonly IEnumerable<INPCInteractionNotifier> _npcInteractionNotifiers; | ||
|
||
public override PacketFamily Family => PacketFamily.StatSkill; | ||
|
||
public override PacketAction Action => PacketAction.Reply; | ||
|
||
public StatskillReplyHandler(IPlayerInfoProvider playerInfoProvider, | ||
IEnumerable<INPCInteractionNotifier> npcInteractionNotifiers) | ||
: base(playerInfoProvider) | ||
{ | ||
_npcInteractionNotifiers = npcInteractionNotifiers; | ||
} | ||
|
||
public override bool HandlePacket(IPacket packet) | ||
{ | ||
var skillmasterReply = (SkillmasterReply)packet.ReadShort(); | ||
var classId = packet.ReadShort(); | ||
|
||
foreach (var notifier in _npcInteractionNotifiers) | ||
notifier.NotifySkillLearnFail(skillmasterReply, classId); | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using AutomaticTypeMapper; | ||
using EndlessClient.Dialogs.Factories; | ||
using EOLib.Domain.Interact; | ||
using EOLib.Domain.Interact.Skill; | ||
using EOLib.IO; | ||
using EOLib.IO.Repositories; | ||
using EOLib.Localization; | ||
|
||
namespace EndlessClient.Dialogs.Actions | ||
{ | ||
[AutoMappedType] | ||
public class NPCInteractionActions : INPCInteractionNotifier | ||
{ | ||
private readonly IInGameDialogActions _inGameDialogActions; | ||
private readonly IEOMessageBoxFactory _messageBoxFactory; | ||
private readonly IECFFileProvider _ecfFileProvider; | ||
|
||
public NPCInteractionActions(IInGameDialogActions inGameDialogActions, | ||
IEOMessageBoxFactory messageBoxFactory, | ||
IECFFileProvider ecfFileProvider) | ||
{ | ||
_inGameDialogActions = inGameDialogActions; | ||
_messageBoxFactory = messageBoxFactory; | ||
_ecfFileProvider = ecfFileProvider; | ||
} | ||
|
||
public void NotifyInteractionFromNPC(NPCType npcType) | ||
{ | ||
// originally, these methods were called directly from NPCInteractionController | ||
// however, this resulted in empty responses (e.g. no shop or quest) showing an empty dialog | ||
// instead, wait for the response packet to notify this class and then show the dialog | ||
// once data has been received from the server | ||
switch (npcType) | ||
{ | ||
case NPCType.Shop: _inGameDialogActions.ShowShopDialog(); break; | ||
case NPCType.Quest: _inGameDialogActions.ShowQuestDialog(); break; | ||
case NPCType.Skills: _inGameDialogActions.ShowSkillmasterDialog(); break; | ||
} | ||
} | ||
|
||
public void NotifySkillLearnFail(SkillmasterReply skillmasterReply, short classId) | ||
{ | ||
switch (skillmasterReply) | ||
{ | ||
//not sure if this will ever actually be sent because client validates data before trying to learn a skill | ||
case SkillmasterReply.ErrorWrongClass: | ||
{ | ||
var dlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.SKILL_LEARN_WRONG_CLASS, $" {_ecfFileProvider.ECFFile[classId].Name}!"); | ||
dlg.ShowDialog(); | ||
} | ||
break; | ||
case SkillmasterReply.ErrorRemoveItems: | ||
{ | ||
var dlg = _messageBoxFactory.CreateMessageBox(DialogResourceID.SKILL_RESET_CHARACTER_CLEAR_PAPERDOLL); | ||
dlg.ShowDialog(); | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.