-
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.
- Loading branch information
1 parent
bd01cdf
commit 913e5ff
Showing
13 changed files
with
224 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,51 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Character; | ||
using EOLib.Domain.Login; | ||
using EOLib.Domain.Map; | ||
using EOLib.Net; | ||
using EOLib.Net.Handlers; | ||
|
||
namespace EOLib.PacketHandlers.Citizen | ||
{ | ||
/// <summary> | ||
/// Sent when the player has accepted the cost of sleeping at an inn | ||
/// </summary> | ||
[AutoMappedType] | ||
public class CitizenAcceptHandler : InGameOnlyPacketHandler | ||
{ | ||
private readonly ICharacterInventoryRepository _characterInventoryRepository; | ||
private readonly ICurrentMapStateRepository _currentMapStateRepository; | ||
private readonly ICharacterRepository _characterRepository; | ||
|
||
public override PacketFamily Family => PacketFamily.Citizen; | ||
|
||
public override PacketAction Action => PacketAction.Accept; | ||
|
||
public CitizenAcceptHandler(IPlayerInfoProvider playerInfoProvider, | ||
ICharacterInventoryRepository characterInventoryRepository, | ||
ICurrentMapStateRepository currentMapStateRepository, | ||
ICharacterRepository characterRepository) | ||
: base(playerInfoProvider) | ||
{ | ||
_characterInventoryRepository = characterInventoryRepository; | ||
_currentMapStateRepository = currentMapStateRepository; | ||
_characterRepository = characterRepository; | ||
} | ||
|
||
public override bool HandlePacket(IPacket packet) | ||
{ | ||
var goldRemaining = packet.ReadInt(); | ||
_characterInventoryRepository.ItemInventory.RemoveWhere(x => x.ItemID == 1); | ||
_characterInventoryRepository.ItemInventory.Add(new InventoryItem(1, goldRemaining)); | ||
|
||
var stats = _characterRepository.MainCharacter.Stats; | ||
stats = stats.WithNewStat(CharacterStat.HP, stats[CharacterStat.MaxHP]) | ||
.WithNewStat(CharacterStat.TP, stats[CharacterStat.MaxTP]); | ||
_characterRepository.MainCharacter = _characterRepository.MainCharacter.WithStats(stats); | ||
|
||
_currentMapStateRepository.IsSleepWarp = true; | ||
|
||
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,39 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Interact; | ||
using EOLib.Domain.Login; | ||
using EOLib.Net; | ||
using EOLib.Net.Handlers; | ||
using System.Collections.Generic; | ||
|
||
namespace EOLib.PacketHandlers.Citizen | ||
{ | ||
/// <summary> | ||
/// Sent when requesting to sleep at an inn | ||
/// </summary> | ||
[AutoMappedType] | ||
public class CitizenRequestHandler : InGameOnlyPacketHandler | ||
{ | ||
private readonly IEnumerable<INPCInteractionNotifier> _npcInteractionNotifiers; | ||
|
||
public override PacketFamily Family => PacketFamily.Citizen; | ||
|
||
public override PacketAction Action => PacketAction.Request; | ||
|
||
public CitizenRequestHandler(IPlayerInfoProvider playerInfoProvider, | ||
IEnumerable<INPCInteractionNotifier> npcInteractionNotifiers) | ||
: base(playerInfoProvider) | ||
{ | ||
_npcInteractionNotifiers = npcInteractionNotifiers; | ||
} | ||
|
||
public override bool HandlePacket(IPacket packet) | ||
{ | ||
var sleepCost = packet.ReadInt(); | ||
|
||
foreach (var notifier in _npcInteractionNotifiers) | ||
notifier.NotifyCitizenRequestSleep(sleepCost); | ||
|
||
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
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.