53 lines
2.0 KiB
C#
53 lines
2.0 KiB
C#
using Tiger.Communication.Messages.Interfaces;
|
|
using Tiger.Communication.Messages.Outgoing.Avatar;
|
|
using Tiger.Communication.Messages.Types;
|
|
using Tiger.Game.Achievements;
|
|
using Tiger.Game.Figuredata;
|
|
using Tiger.Game.Habbos;
|
|
using Tiger.Networking.Game.Sessions;
|
|
using Tiger.Storage;
|
|
|
|
namespace Tiger.Communication.Messages.Incoming.User.Data;
|
|
|
|
public class UserFigureEvent : IMessageEvent
|
|
{
|
|
private readonly IGameSessionManager _gameSessionManager;
|
|
private readonly IFigureDataManager _figureDataManager;
|
|
private readonly IRepository<Habbo> _habboRepository;
|
|
private readonly IAchievementManager _achievementManager;
|
|
|
|
public UserFigureEvent(IGameSessionManager gameSessionManager, IFigureDataManager figureDataManager, IRepository<Habbo> habboRepository, IAchievementManager achievementManager)
|
|
{
|
|
_gameSessionManager = gameSessionManager;
|
|
_figureDataManager = figureDataManager;
|
|
_habboRepository = habboRepository;
|
|
_achievementManager = achievementManager;
|
|
}
|
|
|
|
public IncomingHeaders Header => IncomingHeaders.UserFigure;
|
|
public async Task HandleAsync(GameSession gameSession, ClientMessage request)
|
|
{
|
|
if (gameSession.Habbo == null)
|
|
{
|
|
await _gameSessionManager.CloseAsync("Not logged in", gameSession);
|
|
return;
|
|
}
|
|
|
|
var gender = request.ReadString().ToUpper();
|
|
var figure = request.ReadString();
|
|
|
|
if ((gender != "M" && gender != "F") || (figure == gameSession.Habbo.Figure && gender == gameSession.Habbo.Gender.ToUpper()) /*||
|
|
!_figureDataManager.ValidateFigure(figure, gender, gameSession.Habbo)*/)
|
|
{
|
|
return;
|
|
}
|
|
|
|
gameSession.Habbo.Figure = figure;
|
|
gameSession.Habbo.Gender = gender;
|
|
_habboRepository.SaveAsync(gameSession.Habbo);
|
|
|
|
_achievementManager.UpdateAchievementAsync("ACH_AvatarLooks", 1, gameSession);
|
|
|
|
await gameSession.SendComposerAsync(new FigureUpdateComposer(figure, gender));
|
|
}
|
|
} |