Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix packet handling for jukebox packets. Add missing Jukebox_Agree ha…
…ndler.
- Loading branch information
1 parent
01789a3
commit 853d190
Showing
3 changed files
with
52 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Character; | ||
using EOLib.Domain.Login; | ||
using EOLib.Net; | ||
using EOLib.Net.Handlers; | ||
using Optional.Collections; | ||
|
||
namespace EOLib.PacketHandlers.Jukebox | ||
{ | ||
/// <summary> | ||
/// Sent to update character's remaining gold after requesting a song | ||
/// </summary> | ||
[AutoMappedType] | ||
public class JukeboxAgreeHandler : InGameOnlyPacketHandler | ||
{ | ||
private readonly ICharacterInventoryRepository _characterInventoryRepository; | ||
|
||
public override PacketFamily Family => PacketFamily.JukeBox; | ||
|
||
public override PacketAction Action => PacketAction.Agree; | ||
|
||
public JukeboxAgreeHandler(IPlayerInfoProvider playerInfoProvider, | ||
ICharacterInventoryRepository characterInventoryRepository) | ||
: base(playerInfoProvider) | ||
{ | ||
_characterInventoryRepository = characterInventoryRepository; | ||
} | ||
|
||
public override bool HandlePacket(IPacket packet) | ||
{ | ||
var goldRemaining = packet.ReadInt(); | ||
|
||
_characterInventoryRepository.ItemInventory.SingleOrNone(x => x.ItemID == 1).MatchSome(x => _characterInventoryRepository.ItemInventory.Remove(x)); | ||
_characterInventoryRepository.ItemInventory.Add(new InventoryItem(1, goldRemaining)); | ||
|
||
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