35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
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<Badge> _badgeRepository;
|
|
|
|
public UserCurrentBadgesEvent(IGameSessionManager gameSessionManager, IRepository<Badge> 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();
|
|
|
|
var badges = await _badgeRepository.FindByAsync(b => b.Habbo.Id == habboId && b.Slot > 0);
|
|
await gameSession.SendComposerAsync(new UserCurrentBadgesComposer(habboId, badges.ToList()));
|
|
}
|
|
} |