-
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.
Implement guild bank deposit logic (#384)
* Implement guild bank deposit logic * Add gold item name suffix to "new balance" dialog * Ensure guild bank balance works if the balance is zero
- Loading branch information
1 parent
e073abf
commit f380b5d
Showing
10 changed files
with
229 additions
and
10 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
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,57 @@ | ||
using System.Collections.Generic; | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Character; | ||
using EOLib.Domain.Interact.Guild; | ||
using EOLib.Domain.Login; | ||
using EOLib.Domain.Notifiers; | ||
using EOLib.Net.Handlers; | ||
using Moffat.EndlessOnline.SDK.Protocol.Net; | ||
using Moffat.EndlessOnline.SDK.Protocol.Net.Server; | ||
using Optional.Collections; | ||
|
||
namespace EOLib.PacketHandlers.Guild | ||
{ | ||
[AutoMappedType] | ||
|
||
public class GuildBuyHandler : InGameOnlyPacketHandler<GuildBuyServerPacket> | ||
{ | ||
private readonly IGuildSessionProvider _guildSessionProvider; | ||
private readonly ICharacterInventoryRepository _characterInventoryRepository; | ||
private readonly IEnumerable<IGuildNotifier> _guildNotifiers; | ||
|
||
public override PacketFamily Family => PacketFamily.Guild; | ||
|
||
public override PacketAction Action => PacketAction.Buy; | ||
|
||
public GuildBuyHandler(IPlayerInfoProvider playerInfoProvider, | ||
IGuildSessionProvider guildSessionProvider, | ||
ICharacterInventoryRepository characterInventoryRepository, | ||
IEnumerable<IGuildNotifier> guildNotifiers) | ||
: base(playerInfoProvider) | ||
{ | ||
_guildSessionProvider = guildSessionProvider; | ||
_characterInventoryRepository = characterInventoryRepository; | ||
_guildNotifiers = guildNotifiers; | ||
} | ||
|
||
public override bool HandlePacket(GuildBuyServerPacket packet) | ||
{ | ||
var oldAmount = _characterInventoryRepository.ItemInventory | ||
.SingleOrNone(x => x.ItemID == 1) | ||
.ValueOr(new InventoryItem(1, 0)) | ||
.Amount; | ||
|
||
_characterInventoryRepository.ItemInventory.RemoveWhere(x => x.ItemID == 1); | ||
_characterInventoryRepository.ItemInventory.Add(new InventoryItem(1, packet.GoldAmount)); | ||
|
||
var newBalance = _guildSessionProvider.GuildBalance + (oldAmount - packet.GoldAmount); | ||
|
||
foreach (var notifier in _guildNotifiers) | ||
{ | ||
notifier.NotifyNewGuildBankBalance(newBalance); | ||
} | ||
|
||
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,33 @@ | ||
using AutomaticTypeMapper; | ||
using EOLib.Domain.Interact.Guild; | ||
using EOLib.Domain.Login; | ||
using EOLib.Net.Handlers; | ||
using Moffat.EndlessOnline.SDK.Protocol.Net; | ||
using Moffat.EndlessOnline.SDK.Protocol.Net.Server; | ||
|
||
namespace EOLib.PacketHandlers.Guild | ||
{ | ||
[AutoMappedType] | ||
|
||
public class GuildSellHandler : InGameOnlyPacketHandler<GuildSellServerPacket> | ||
{ | ||
private readonly IGuildSessionRepository _guildSessionRepository; | ||
|
||
public override PacketFamily Family => PacketFamily.Guild; | ||
|
||
public override PacketAction Action => PacketAction.Sell; | ||
|
||
public GuildSellHandler(IPlayerInfoProvider playerInfoProvider, | ||
IGuildSessionRepository guildSessionRepository) | ||
: base(playerInfoProvider) | ||
{ | ||
_guildSessionRepository = guildSessionRepository; | ||
} | ||
|
||
public override bool HandlePacket(GuildSellServerPacket packet) | ||
{ | ||
_guildSessionRepository.GuildBalance = packet.GoldAmount; | ||
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
Oops, something went wrong.