using SPTarkov.DI.Annotations; using SPTarkov.Server.Core.Helpers; using SPTarkov.Server.Core.Models.Common; using SPTarkov.Server.Core.Models.Eft.Match; using SPTarkov.Server.Core.Models.Spt.Config; using SPTarkov.Server.Core.Models.Utils; using SPTarkov.Server.Core.Servers; using SPTarkov.Server.Core.Services; using static SPTarkov.Server.Core.Services.MatchLocationService; namespace SPTarkov.Server.Core.Controllers; [Injectable] public class MatchController( ISptLogger logger, MatchLocationService matchLocationService, ConfigServer configServer, LocationLifecycleService locationLifecycleService, ProfileActivityService profileActivityService, WeatherHelper weatherHelper ) { protected readonly MatchConfig _matchConfig = configServer.GetConfig(); protected readonly PmcConfig _pmcConfig = configServer.GetConfig(); /// /// Handle client/match/available /// /// True if server should be available public bool GetEnabled() { return _matchConfig.Enabled; } /// /// Handle client/match/group/delete /// /// Delete group request public void DeleteGroup(DeleteGroupRequest request) { matchLocationService.DeleteGroup(request); } /// /// Handle match/group/start_game /// /// Start game request /// Session/Player id /// ProfileStatusResponse public ProfileStatusResponse JoinMatch(MatchGroupJoinRequest request, MongoId sessionId) { var output = new ProfileStatusResponse { MaxPveCountExceeded = false, // get list of players joining into the match Profiles = [ new SessionStatus { ProfileId = "TODO", ProfileToken = "TODO", Status = "MatchWait", Sid = "", Ip = "", Port = 0, Version = "live", Location = "TODO get location", RaidMode = "Online", Mode = "deathmatch", ShortId = null, AdditionalInfo = null, }, ], }; return output; } /// /// Handle client/match/group/status /// /// Group status request /// MatchGroupStatusResponse public MatchGroupStatusResponse GetGroupStatus(MatchGroupStatusRequest request) { return new MatchGroupStatusResponse { Players = [], MaxPveCountExceeded = false }; } /// /// Handle /client/raid/configuration /// /// /// Session/Player id public void ConfigureOfflineRaid(GetRaidConfigurationRequestData request, MongoId sessionId) { // set IsNightRaid to use it later for bot inventory generation request.IsNightRaid = weatherHelper.IsNightTime(request.TimeVariant, request.Location); // Store request data for access during bot generation profileActivityService.GetProfileActivityRaidData(sessionId).RaidConfiguration = request; // TODO: add code to strip PMC of equipment now they've started the raid // Set pmcs to difficulty set in pre-raid screen if override in bot config isnt enabled if (!_pmcConfig.UseDifficultyOverride) { _pmcConfig.Difficulty = ConvertDifficultyDropdownIntoBotDifficulty(request.WavesSettings.BotDifficulty.ToString()); } } /// /// Convert a difficulty value from pre-raid screen to a bot difficulty /// /// dropdown difficulty value /// Bot difficulty protected string ConvertDifficultyDropdownIntoBotDifficulty(string botDifficulty) { // Edge case medium - must be altered if (string.Equals(botDifficulty, "medium", StringComparison.OrdinalIgnoreCase)) { return "normal"; } return botDifficulty; } /// /// Handle client/match/local/start /// /// Session/Player id /// Start raid request /// StartLocalRaidResponseData public StartLocalRaidResponseData StartLocalRaid(MongoId sessionId, StartLocalRaidRequestData request) { return locationLifecycleService.StartLocalRaid(sessionId, request); } /// /// Handle client/match/local/end /// /// Session/Player id /// Emd local raid request public void EndLocalRaid(MongoId sessionId, EndLocalRaidRequestData request) { locationLifecycleService.EndLocalRaid(sessionId, request); } }