-
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.
Issue #71: Handle PLAYER_RECOVER packet in new code
- Loading branch information
1 parent
d5bcce9
commit 0c948f0
Showing
5 changed files
with
43 additions
and
18 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 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,40 @@ | ||
// Original Work Copyright (c) Ethan Moffat 2014-2017 | ||
// This file is subject to the GPL v2 License | ||
// For additional details, see the LICENSE file | ||
|
||
using EOLib.Domain.Character; | ||
using EOLib.Domain.Login; | ||
using EOLib.Net; | ||
using EOLib.Net.Handlers; | ||
|
||
namespace EOLib.PacketHandlers | ||
{ | ||
public class PlayerRecoverHandler : InGameOnlyPacketHandler | ||
{ | ||
private readonly ICharacterRepository _characterRepository; | ||
|
||
public override PacketFamily Family => PacketFamily.Recover; | ||
public override PacketAction Action => PacketAction.Player; | ||
|
||
public PlayerRecoverHandler(IPlayerInfoProvider playerInfoProvider, | ||
ICharacterRepository characterRepository) | ||
: base(playerInfoProvider) | ||
{ | ||
_characterRepository = characterRepository; | ||
} | ||
|
||
public override bool HandlePacket(IPacket packet) | ||
{ | ||
var newHP = packet.ReadShort(); | ||
var newTP = packet.ReadShort(); | ||
|
||
var stats = _characterRepository.MainCharacter.Stats | ||
.WithNewStat(CharacterStat.HP, newHP) | ||
.WithNewStat(CharacterStat.TP, newTP); | ||
|
||
_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