using Core.Context; using Core.Models.Eft.Match; using Core.Models.Spt.Config; using Core.Models.Utils; using Core.Servers; using Core.Services; using Core.Utils.Cloners; using SptCommon.Annotations; using static Core.Services.MatchLocationService; namespace Core.Controllers; [Injectable] public class MatchController( ISptLogger _logger, SaveServer _saveServer, MatchLocationService _matchLocationService, ConfigServer _configServer, ApplicationContext _applicationContext, LocationLifecycleService _locationLifecycleService, ICloner _cloner ) { protected MatchConfig _matchConfig = _configServer.GetConfig(); protected PmcConfig _pmcConfig = _configServer.GetConfig(); /// /// /// public bool GetEnabled() { return _matchConfig.Enabled; } /// /// Handle client/match/group/delete /// /// public void DeleteGroup(DeleteGroupRequest info) { _matchLocationService.DeleteGroup(info); } /// /// Handle match/group/start_game /// /// /// /// public ProfileStatusResponse JoinMatch(MatchGroupStartGameRequest info, string 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 /// /// /// public MatchGroupStatusResponse GetGroupStatus(MatchGroupStatusRequest info) { return new MatchGroupStatusResponse { Players = [], MaxPveCountExceeded = false }; } /// /// Handle /client/raid/configuration /// /// /// public void ConfigureOfflineRaid(GetRaidConfigurationRequestData request, string sessionId) { // Store request data for access during bot generation _applicationContext.AddValue(ContextVariableType.RAID_CONFIGURATION, 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 private string ConvertDifficultyDropdownIntoBotDifficulty(string botDifficulty) { // Edge case medium - must be altered if (botDifficulty.ToLower() == "medium") { return "normal"; } return botDifficulty; } /// /// Handle client/match/local/start /// /// /// /// public StartLocalRaidResponseData StartLocalRaid(string sessionId, StartLocalRaidRequestData request) { return _locationLifecycleService.StartLocalRaid(sessionId, request); } /// /// Handle client/match/local/end /// /// /// public void EndLocalRaid(string sessionId, EndLocalRaidRequestData request) { _locationLifecycleService.EndLocalRaid(sessionId, request); } }