34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
|
using Tiger.Communication.Messages.Interfaces;
|
||
|
using Tiger.Communication.Messages.Outgoing.Inventory.Subscription;
|
||
|
using Tiger.Communication.Messages.Types;
|
||
|
using Tiger.Game.Achievements;
|
||
|
using Tiger.Networking.Game.Sessions;
|
||
|
|
||
|
namespace Tiger.Communication.Messages.Incoming.Inventory.Subscription;
|
||
|
|
||
|
public class UserSubscriptionEvent : IMessageEvent
|
||
|
{
|
||
|
private readonly IGameSessionManager _gameSessionManager;
|
||
|
private readonly IAchievementManager _achievementManager;
|
||
|
|
||
|
public UserSubscriptionEvent(IGameSessionManager gameSessionManager, IAchievementManager achievementManager)
|
||
|
{
|
||
|
_gameSessionManager = gameSessionManager;
|
||
|
_achievementManager = achievementManager;
|
||
|
}
|
||
|
|
||
|
public IncomingHeaders Header => IncomingHeaders.UserSubscription;
|
||
|
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
|
||
|
{
|
||
|
if (gameSession.Habbo == null)
|
||
|
{
|
||
|
await _gameSessionManager.CloseAsync("Not logged in", gameSession);
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
_achievementManager.UpdateAchievementAsync("ACH_HC", ((gameSession.Habbo.GetPastSubscriptionDays() / 31)), gameSession);
|
||
|
|
||
|
await gameSession.SendComposerAsync(new UserSubscriptionComposer(gameSession.Habbo.GetActiveSubscription(),
|
||
|
gameSession.Habbo.GetPastSubscriptionDays()));
|
||
|
}
|
||
|
}
|