Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Packet handling for training a spell
- Loading branch information
1 parent
d951cb9
commit 40bcd01
Showing
6 changed files
with
72 additions
and
46 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Character; | ||
using EOLib.Domain.Login; | ||
using EOLib.Net; | ||
using EOLib.Net.Handlers; | ||
|
||
namespace EOLib.PacketHandlers | ||
{ | ||
[AutoMappedType] | ||
public class SpellTrainingHandler : InGameOnlyPacketHandler | ||
{ | ||
private readonly ICharacterRepository _characterRepository; | ||
private readonly ICharacterInventoryRepository _characterInventoryRepository; | ||
|
||
public override PacketFamily Family => PacketFamily.StatSkill; | ||
|
||
public override PacketAction Action => PacketAction.Accept; | ||
|
||
public SpellTrainingHandler(IPlayerInfoProvider playerInfoProvider, | ||
ICharacterRepository characterRepository, | ||
ICharacterInventoryRepository characterInventoryRepository) | ||
: base(playerInfoProvider) | ||
{ | ||
_characterRepository = characterRepository; | ||
_characterInventoryRepository = characterInventoryRepository; | ||
} | ||
|
||
public override bool HandlePacket(IPacket packet) | ||
{ | ||
var skillPoints = packet.ReadShort(); | ||
var spellId = packet.ReadShort(); | ||
var spellLevel = packet.ReadShort(); | ||
|
||
_characterInventoryRepository.SpellInventory.RemoveWhere(x => x.ID == spellId); | ||
_characterInventoryRepository.SpellInventory.Add(new InventorySpell(spellId, spellLevel)); | ||
|
||
var stats = _characterRepository.MainCharacter.Stats.WithNewStat(CharacterStat.SkillPoints, skillPoints); | ||
_characterRepository.MainCharacter = _characterRepository.MainCharacter.WithStats(stats); | ||
|
||
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
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