using Tiger.Communication.Messages.Interfaces; using Tiger.Communication.Messages.Outgoing.User.Data; using Tiger.Communication.Messages.Types; using Tiger.Game.Habbos; using Tiger.Networking.Game.Sessions; using Tiger.Storage; namespace Tiger.Communication.Messages.Incoming.User.Data; public class UserCurrentBadgesEvent : IMessageEvent { private readonly IGameSessionManager _gameSessionManager; private readonly IRepository _badgeRepository; public UserCurrentBadgesEvent(IGameSessionManager gameSessionManager, IRepository badgeRepository) { _gameSessionManager = gameSessionManager; _badgeRepository = badgeRepository; } public IncomingHeaders Header => IncomingHeaders.UserBadgesCurrent; public async Task HandleAsync(GameSession gameSession, ClientMessage request) { if (gameSession.Habbo == null) { await _gameSessionManager.CloseAsync("Not logged in", gameSession); return; } var habboId = request.ReadInt32(); if (habboId == null) return; var badges = await _badgeRepository.FindByAsync(b => b.Habbo.Id == habboId && b.Slot > 0); await gameSession.SendComposerAsync(new UserCurrentBadgesComposer(habboId.Value, badges.ToList())); } }