using SPTarkov.DI.Annotations;
using SPTarkov.Server.Core.Controllers;
using SPTarkov.Server.Core.Helpers;
using SPTarkov.Server.Core.Models.Common;
using SPTarkov.Server.Core.Models.Eft.Common;
using SPTarkov.Server.Core.Models.Eft.Launcher;
using SPTarkov.Server.Core.Models.Eft.Profile;
using SPTarkov.Server.Core.Models.Enums;
using SPTarkov.Server.Core.Models.Spt.Launcher;
using SPTarkov.Server.Core.Utils;
namespace SPTarkov.Server.Core.Callbacks;
[Injectable]
public class ProfileCallbacks(
HttpResponseUtil httpResponse,
TimeUtil timeUtil,
ProfileController profileController,
ProfileHelper profileHelper
)
{
///
/// Handle client/game/profile/create
///
///
public async ValueTask CreateProfile(
string url,
ProfileCreateRequestData info,
MongoId sessionID
)
{
var id = await profileController.CreateProfile(info, sessionID);
return httpResponse.GetBody(new CreateProfileResponse { UserId = id });
}
///
/// Handle client/game/profile/list
/// Get the complete player profile (scav + pmc character)
///
///
public ValueTask GetProfileData(string url, EmptyRequestData _, MongoId sessionID)
{
return new ValueTask(
httpResponse.GetBody(profileController.GetCompleteProfile(sessionID))
);
}
///
/// Handle client/game/profile/savage/regenerate
/// Handle the creation of a scav profile for player
/// Occurs post-raid and when profile first created immediately after character details are confirmed by player
///
///
public ValueTask RegenerateScav(string url, EmptyRequestData _, MongoId sessionID)
{
return new ValueTask(
httpResponse.GetBody(
new List { profileController.GeneratePlayerScav(sessionID) }
)
);
}
///
/// Handle client/game/profile/voice/change event
///
///
public ValueTask ChangeVoice(
string url,
ProfileChangeVoiceRequestData info,
MongoId sessionID
)
{
profileController.ChangeVoice(info, sessionID);
return new ValueTask(httpResponse.NullResponse());
}
///
/// Handle client/game/profile/nickname/change event
/// Client allows player to adjust their profile name
///
/// Client response as string
public ValueTask ChangeNickname(
string url,
ProfileChangeNicknameRequestData info,
MongoId sessionId
)
{
var output = profileController.ChangeNickname(info, sessionId);
return output switch
{
NicknameValidationResult.Taken => new ValueTask(
httpResponse.GetBody