TigerEmu/Communication/Messages/Incoming/Inventory/Currency/UserCurrencyEvent.cs

30 lines
1.1 KiB
C#

using Tiger.Communication.Messages.Interfaces;
using Tiger.Communication.Messages.Outgoing.Inventory.Currency;
using Tiger.Communication.Messages.Outgoing.Notifications;
using Tiger.Communication.Messages.Types;
using Tiger.Networking.Game.Sessions;
namespace Tiger.Communication.Messages.Incoming.Inventory.Currency;
public class UserCurrencyEvent : IMessageEvent
{
private readonly IGameSessionManager _gameSessionManager;
public UserCurrencyEvent(IGameSessionManager gameSessionManager)
{
_gameSessionManager = gameSessionManager;
}
public IncomingHeaders Header => IncomingHeaders.UserCurrency;
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
{
if (gameSession.Habbo == null)
{
await _gameSessionManager.CloseAsync("Not logged in", gameSession);
return;
}
await gameSession.SendComposerAsync(new UserCreditsComposer(gameSession.Habbo.Credits));
await gameSession.SendComposerAsync(new UserCurrencyComposer(gameSession.Habbo.Activitypoints.Values));
}
}