-
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.
Packet handling and domain changes for forgetting skill and resetting…
… stats
- Loading branch information
1 parent
3a6ff4c
commit ea276ef
Showing
8 changed files
with
155 additions
and
148 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
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
This file was deleted.
Oops, something went wrong.
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,67 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Character; | ||
using EOLib.Domain.Interact; | ||
using EOLib.Domain.Login; | ||
using EOLib.Net; | ||
using EOLib.Net.Handlers; | ||
using System.Collections.Generic; | ||
|
||
namespace EOLib.PacketHandlers.Skill | ||
{ | ||
/// <summary> | ||
/// Sent when resetting a character's stats/skills | ||
/// </summary> | ||
[AutoMappedType] | ||
public class StatskillJunkHandler : InGameOnlyPacketHandler | ||
{ | ||
private readonly ICharacterInventoryRepository _characterInventoryRepository; | ||
private readonly ICharacterRepository _characterRepository; | ||
private readonly IEnumerable<INPCInteractionNotifier> _npcInteractionNotifiers; | ||
|
||
public override PacketFamily Family => PacketFamily.StatSkill; | ||
|
||
public override PacketAction Action => PacketAction.Junk; | ||
|
||
public StatskillJunkHandler(IPlayerInfoProvider playerInfoProvider, | ||
ICharacterInventoryRepository characterInventoryRepository, | ||
ICharacterRepository characterRepository, | ||
IEnumerable<INPCInteractionNotifier> npcInteractionNotifiers) | ||
: base(playerInfoProvider) | ||
{ | ||
_characterInventoryRepository = characterInventoryRepository; | ||
_characterRepository = characterRepository; | ||
_npcInteractionNotifiers = npcInteractionNotifiers; | ||
} | ||
|
||
public override bool HandlePacket(IPacket packet) | ||
{ | ||
var stats = _characterRepository.MainCharacter.Stats | ||
.WithNewStat(CharacterStat.StatPoints, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.SkillPoints, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.HP, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.MaxHP, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.TP, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.MaxTP, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.MaxSP, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.Strength, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.Intelligence, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.Wisdom, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.Agility, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.Constituion, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.Charisma, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.MinDam, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.MaxDam, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.Accuracy, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.Evade, packet.ReadShort()) | ||
.WithNewStat(CharacterStat.Armor, packet.ReadShort()); | ||
_characterRepository.MainCharacter = _characterRepository.MainCharacter.WithStats(stats); | ||
|
||
_characterInventoryRepository.SpellInventory.Clear(); | ||
|
||
foreach (var notifier in _npcInteractionNotifiers) | ||
notifier.NotifyStatReset(); | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Character; | ||
using EOLib.Domain.Interact; | ||
using EOLib.Domain.Login; | ||
using EOLib.Net; | ||
using EOLib.Net.Handlers; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace EOLib.PacketHandlers.Skill | ||
{ | ||
/// <summary> | ||
/// Sent when forgetting a skill | ||
/// </summary> | ||
[AutoMappedType] | ||
public class StatskillRemoveHandler : InGameOnlyPacketHandler | ||
{ | ||
private readonly ICharacterInventoryRepository _characterInventoryRepository; | ||
private readonly IEnumerable<INPCInteractionNotifier> _npcInteractionNotifiers; | ||
|
||
public override PacketFamily Family => PacketFamily.StatSkill; | ||
|
||
public override PacketAction Action => PacketAction.Remove; | ||
|
||
public StatskillRemoveHandler(IPlayerInfoProvider playerInfoProvider, | ||
ICharacterInventoryRepository characterInventoryRepository, | ||
IEnumerable<INPCInteractionNotifier> npcInteractionNotifiers) | ||
: base(playerInfoProvider) | ||
{ | ||
_characterInventoryRepository = characterInventoryRepository; | ||
_npcInteractionNotifiers = npcInteractionNotifiers; | ||
} | ||
|
||
public override bool HandlePacket(IPacket packet) | ||
{ | ||
var spellId = packet.ReadShort(); | ||
_characterInventoryRepository.SpellInventory.RemoveWhere(x => x.ID == spellId); | ||
|
||
foreach (var notifier in _npcInteractionNotifiers) | ||
notifier.NotifySkillForget(); | ||
|
||
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