-
Notifications
You must be signed in to change notification settings - Fork 16
/
StatskillTakeHandler.cs
45 lines (37 loc) · 1.51 KB
/
StatskillTakeHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using AutomaticTypeMapper;
using EOLib.Domain.Character;
using EOLib.Domain.Login;
using EOLib.Net;
using EOLib.Net.Handlers;
using System.Linq;
namespace EOLib.PacketHandlers.Skill
{
/// <summary>
/// Sent when learning a skill, either via $learn command or from skillmaster
/// </summary>
[AutoMappedType]
public class StatskillTakeHandler : InGameOnlyPacketHandler
{
private readonly ICharacterInventoryRepository _characterInventoryRepository;
public override PacketFamily Family => PacketFamily.StatSkill;
public override PacketAction Action => PacketAction.Take;
public StatskillTakeHandler(IPlayerInfoProvider playerInfoProvider,
ICharacterInventoryRepository characterInventoryRepository)
: base(playerInfoProvider)
{
_characterInventoryRepository = characterInventoryRepository;
}
public override bool HandlePacket(IPacket packet)
{
var spellId = packet.ReadShort();
var characterGold = packet.ReadInt();
if (!_characterInventoryRepository.SpellInventory.Any(x => x.ID == spellId))
{
_characterInventoryRepository.SpellInventory.Add(new InventorySpell(spellId, 0));
}
_characterInventoryRepository.ItemInventory.RemoveWhere(x => x.ItemID == 1);
_characterInventoryRepository.ItemInventory.Add(new InventoryItem(1, characterGold));
return true;
}
}
}