-
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.
Merge pull request #182 from ethanmoffat/active_spells
Implement active spells panel
- Loading branch information
Showing
23 changed files
with
1,059 additions
and
995 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,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 StatskillTake : InGameOnlyPacketHandler | ||
{ | ||
private readonly ICharacterInventoryRepository _characterInventoryRepository; | ||
|
||
public override PacketFamily Family => PacketFamily.StatSkill; | ||
|
||
public override PacketAction Action => PacketAction.Take; | ||
|
||
public StatskillTake(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; | ||
} | ||
} | ||
} |
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
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.