diff --git a/Core/Callbacks/AchievementCallbacks.cs b/Core/Callbacks/AchievementCallbacks.cs index 06fdc216..e809f24c 100644 --- a/Core/Callbacks/AchievementCallbacks.cs +++ b/Core/Callbacks/AchievementCallbacks.cs @@ -1,13 +1,27 @@ -using Core.Models.Eft.Common; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.Profile; +using Core.Utils; namespace Core.Callbacks; public class AchievementCallbacks { - public AchievementCallbacks() + protected AchievementController _achievementController; + protected ProfileController _profileController; + protected HttpResponseUtil _httpResponseUtil; + + public AchievementCallbacks + ( + AchievementController achievementController, + ProfileController profileController, + HttpResponseUtil httpResponseUtil + ) { + _achievementController = achievementController; + _profileController = profileController; + _httpResponseUtil = httpResponseUtil; } /// @@ -17,9 +31,9 @@ public class AchievementCallbacks /// /// /// - public GetBodyResponseData GetAchievements(string url, EmptyRequestData info, string sessionID) + public string GetAchievements(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_achievementController.GetAchievements(sessionID)); } /// @@ -29,8 +43,8 @@ public class AchievementCallbacks /// /// /// - public GetBodyResponseData Statistic(string url, EmptyRequestData info, string sessionID) + public string Statistic(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_achievementController.GetAchievementStatics(sessionID)); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/BotCallbacks.cs b/Core/Callbacks/BotCallbacks.cs index 543c1a61..e6112219 100644 --- a/Core/Callbacks/BotCallbacks.cs +++ b/Core/Callbacks/BotCallbacks.cs @@ -1,14 +1,32 @@ -using Core.Models.Eft.Bot; +using Core.Annotations; +using Core.Context; +using Core.Controllers; +using Core.Models.Eft.Bot; using Core.Models.Eft.Common; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.HttpResponse; +using Core.Models.Eft.Match; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class BotCallbacks { - public BotCallbacks() + protected BotController _botController; + protected HttpResponseUtil _httpResponseUtil; + protected ApplicationContext _applicationContext; + + public BotCallbacks + ( + BotController botController, + HttpResponseUtil httpResponseUtil, + ApplicationContext applicationContext + ) { + _botController = botController; + _httpResponseUtil = httpResponseUtil; + _applicationContext = applicationContext; } /// @@ -22,7 +40,9 @@ public class BotCallbacks /// public string GetBotLimit(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var splitUrl = url.Split('/'); + var type = splitUrl[splitUrl.Length - 1]; + return _httpResponseUtil.NoBody(_botController.GetBotPresetGenerationLimit(type)); } /// @@ -34,7 +54,15 @@ public class BotCallbacks /// public string GetBotDifficulty(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var splitUrl = url.Split('/'); + var type = splitUrl[splitUrl.Length - 2].ToLower(); + var difficulty = splitUrl[splitUrl.Length - 1]; + if (difficulty == "core") + return _httpResponseUtil.NoBody(_botController.GetBotCoreDifficulty()); + + var raidConfig = (GetRaidConfigurationRequestData)_applicationContext.GetLatestValue(ContextVariableType.RAID_CONFIGURATION)?.Value; + + return _httpResponseUtil.NoBody(_botController.GetBotDifficulty(type, difficulty, raidConfig)); } /// @@ -44,9 +72,9 @@ public class BotCallbacks /// /// /// - public Dictionary GetAllBotDifficulties(string url, EmptyRequestData info, string sessionID) + public string GetAllBotDifficulties(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NoBody(_botController.GetAllBotDifficulties()); } /// @@ -56,18 +84,20 @@ public class BotCallbacks /// /// /// - public GetBodyResponseData> GenerateBots(string url, GenerateBotsRequestData info, string sessionID) + public string GenerateBots(string url, GenerateBotsRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_botController.Generate(sessionID, info)); } /// /// Handle singleplayer/settings/bot/maxCap /// /// - public string GetBotCap() + public string GetBotCap(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var splitUrl = url.Split('/'); + var location = splitUrl[splitUrl.Length - 1]; + return _httpResponseUtil.NoBody(_botController.GetBotCap(location)); } /// @@ -76,6 +106,6 @@ public class BotCallbacks /// public string GetBotBehaviours() { - throw new NotImplementedException(); + return _httpResponseUtil.NoBody(_botController.GetAiBotBrainTypes()); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/BuildsCallbacks.cs b/Core/Callbacks/BuildsCallbacks.cs index 52d0c264..07b44282 100644 --- a/Core/Callbacks/BuildsCallbacks.cs +++ b/Core/Callbacks/BuildsCallbacks.cs @@ -1,15 +1,28 @@ -using Core.Models.Eft.Builds; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Builds; using Core.Models.Eft.Common; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.PresetBuild; using Core.Models.Eft.Profile; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class BuildsCallbacks { - public BuildsCallbacks() + protected HttpResponseUtil _httpResponseUtil; + protected BuildController _buildController; + + public BuildsCallbacks + ( + HttpResponseUtil httpResponseUtil, + BuildController buildController + ) { + _httpResponseUtil = httpResponseUtil; + _buildController = buildController; } /// @@ -19,9 +32,9 @@ public class BuildsCallbacks /// /// /// - public GetBodyResponseData GetBuilds(string url, EmptyRequestData info, string sessionID) + public string GetBuilds(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_buildController.GetUserBuilds(sessionID)); } /// @@ -31,9 +44,10 @@ public class BuildsCallbacks /// /// /// - public NullResponseData CreateMagazineTemplate(string url, SetMagazineRequest info, string sessionID) + public string CreateMagazineTemplate(string url, SetMagazineRequest info, string sessionID) { - throw new NotImplementedException(); + _buildController.CreateMagazineTemplate(sessionID, info); + return _httpResponseUtil.NullResponse(); } /// @@ -43,9 +57,10 @@ public class BuildsCallbacks /// /// /// - public NullResponseData SetWeapon(string url, PresetBuildActionRequestData info, string sessionID) + public string SetWeapon(string url, PresetBuildActionRequestData info, string sessionID) { - throw new NotImplementedException(); + _buildController.SaveWeaponBuild(sessionID, info); + return _httpResponseUtil.NullResponse(); } /// @@ -55,9 +70,10 @@ public class BuildsCallbacks /// /// /// - public NullResponseData SetEquipment(string url, PresetBuildActionRequestData info, string sessionID) + public string SetEquipment(string url, PresetBuildActionRequestData info, string sessionID) { - throw new NotImplementedException(); + _buildController.SaveEquipmentBuild(sessionID, info); + return _httpResponseUtil.NullResponse(); } /// @@ -67,8 +83,9 @@ public class BuildsCallbacks /// /// /// - public NullResponseData DeleteBuild(string url, RemoveBuildRequestData info, string sessionID) + public string DeleteBuild(string url, RemoveBuildRequestData info, string sessionID) { - throw new NotImplementedException(); + _buildController.RemoveBuild(sessionID, info); + return _httpResponseUtil.NullResponse(); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/BundleCallbacks.cs b/Core/Callbacks/BundleCallbacks.cs index d1e93a55..10b6c964 100644 --- a/Core/Callbacks/BundleCallbacks.cs +++ b/Core/Callbacks/BundleCallbacks.cs @@ -1,13 +1,30 @@ -using Core.Models.Spt.Config; +using Core.Annotations; +using Core.Models.Enums; +using Core.Models.Spt.Config; +using Core.Servers; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class BundleCallbacks { - private HttpConfig _httpConfig; + protected HttpResponseUtil _httpResponseUtil; + // protected BundleLoader _bundleLoader; TODO: this needs implementing + protected ConfigServer _configServer; + protected HttpConfig _httpConfig; - public BundleCallbacks() + public BundleCallbacks + ( + HttpResponseUtil httpResponseUtil, + // BundleLoader bundleLoader, + ConfigServer configServer + ) { + _httpResponseUtil = httpResponseUtil; + // _bundleLoader = bundleLoader; + _configServer = configServer; + _httpConfig = configServer.GetConfig(ConfigTypes.HTTP); } /// @@ -19,6 +36,7 @@ public class BundleCallbacks /// public string GetBundles(string url, object info, string sessionID) { + // return _httpResponseUtil.NoBody(_bundleLoader.GetBundles()); throw new NotImplementedException(); } @@ -26,4 +44,4 @@ public class BundleCallbacks { return "BUNDLE"; } -} \ No newline at end of file +} diff --git a/Core/Callbacks/ClientLogCallbacks.cs b/Core/Callbacks/ClientLogCallbacks.cs index 3ec61be1..f1a46793 100644 --- a/Core/Callbacks/ClientLogCallbacks.cs +++ b/Core/Callbacks/ClientLogCallbacks.cs @@ -1,12 +1,38 @@ -using Core.Models.Eft.HttpResponse; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.HttpResponse; +using Core.Models.Enums; +using Core.Models.Spt.Config; using Core.Models.Spt.Logging; +using Core.Servers; +using Core.Services; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class ClientLogCallbacks { - public ClientLogCallbacks() + protected HttpResponseUtil _httpResponseUtil; + protected ClientLogController _clientLogController; + protected ConfigServer _configServer; + protected LocalisationService _localisationService; + + // protected ModLoadOrder _modLoadOrder; // TODO: needs implementing + public ClientLogCallbacks + ( + HttpResponseUtil httpResponseUtil, + ClientLogController clientLogController, + ConfigServer configServer, + LocalisationService localisationService + // ModLoadOrder modLoadOrder + ) { + _httpResponseUtil = httpResponseUtil; + _clientLogController = clientLogController; + _configServer = configServer; + _localisationService = localisationService; + // _modLoadOrder = modLoadOrder; } /// @@ -16,9 +42,10 @@ public class ClientLogCallbacks /// /// /// - public NullResponseData ClientLog(string url, ClientLogRequest info, string sessionID) + public string ClientLog(string url, ClientLogRequest info, string sessionID) { - throw new NotImplementedException(); + _clientLogController.ClientLog(info); + return _httpResponseUtil.NullResponse(); } /// @@ -27,7 +54,28 @@ public class ClientLogCallbacks /// public string ReleaseNotes() { - throw new NotImplementedException(); + var data = _configServer.GetConfig(ConfigTypes.CORE).Release; + + // data.betaDisclaimerText = ProgramStatics.MODS + // ? this.localisationService.getText("release-beta-disclaimer-mods-enabled") + // : this.localisationService.getText("release-beta-disclaimer"); + // + // data.betaDisclaimerAcceptText = this.localisationService.getText("release-beta-disclaimer-accept"); + // data.serverModsLoadedText = this.localisationService.getText("release-server-mods-loaded"); + // data.serverModsLoadedDebugText = this.localisationService.getText("release-server-mods-debug-message"); + // data.clientModsLoadedText = this.localisationService.getText("release-plugins-loaded"); + // data.clientModsLoadedDebugText = this.localisationService.getText("release-plugins-loaded-debug-message"); + // data.illegalPluginsLoadedText = this.localisationService.getText("release-illegal-plugins-loaded"); + // data.illegalPluginsExceptionText = this.localisationService.getText("release-illegal-plugins-exception"); + // data.releaseSummaryText = this.localisationService.getText("release-summary"); + // + // data.isBeta = + // ProgramStatics.ENTRY_TYPE === EntryType.BLEEDING_EDGE || + // ProgramStatics.ENTRY_TYPE === EntryType.BLEEDING_EDGE_MODS; + // data.isModdable = ProgramStatics.MODS; + // data.isModded = this.modLoadOrder.getLoadOrder().length > 0; + + return _httpResponseUtil.NoBody(data); } /// @@ -36,6 +84,7 @@ public class ClientLogCallbacks /// public string BsgLogging() { - throw new NotImplementedException(); + var data = _configServer.GetConfig(ConfigTypes.CORE).BsgLogging; + return _httpResponseUtil.NoBody(data); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/CustomizationCallbacks.cs b/Core/Callbacks/CustomizationCallbacks.cs index 18ad6903..411e77af 100644 --- a/Core/Callbacks/CustomizationCallbacks.cs +++ b/Core/Callbacks/CustomizationCallbacks.cs @@ -1,16 +1,33 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.Customization; using Core.Models.Eft.Hideout; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.ItemEvent; +using Core.Servers; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class CustomizationCallbacks { - public CustomizationCallbacks() + protected CustomizationController _customizationController; + protected SaveServer _saveServer; + protected HttpResponseUtil _httpResponseUtil; + + public CustomizationCallbacks + ( + CustomizationController customizationController, + SaveServer saveServer, + HttpResponseUtil httpResponseUtil + ) { + _customizationController = customizationController; + _saveServer = saveServer; + _httpResponseUtil = httpResponseUtil; } /// @@ -20,9 +37,15 @@ public class CustomizationCallbacks /// /// /// - public GetBodyResponseData GetSuits(string url, EmptyRequestData info, string sessionID) + public string GetSuits(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var result = new GetSuitsResponse + { + Id = sessionID, + Suites = _saveServer.GetProfile(sessionID).Suits + }; + + return _httpResponseUtil.GetBody(result); } /// @@ -32,9 +55,12 @@ public class CustomizationCallbacks /// /// /// - public GetBodyResponseData> GetTraderSuits(string url, object info, string sessionID) + public string GetTraderSuits(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var splitUrl = url.Split('/'); + var traderId = splitUrl[splitUrl.Length - 3]; + + return _httpResponseUtil.GetBody(_customizationController.GetTraderSuits(traderId, sessionID)); } /// @@ -44,9 +70,9 @@ public class CustomizationCallbacks /// /// /// - public ItemEventRouterResponse BuyClothing(PmcData pmcData, BuyClothingRequestData body, string sessionID) + public ItemEventRouterResponse BuyClothing(PmcData pmcData, BuyClothingRequestData info, string sessionID) { - throw new NotImplementedException(); + return _customizationController.BuyClothing(pmcData, info, sessionID); } /// @@ -56,9 +82,9 @@ public class CustomizationCallbacks /// /// /// - public GetBodyResponseData GetHideoutCustomisation(PmcData pmcData, EmptyRequestData body, string sessionID) + public string GetHideoutCustomisation(PmcData pmcData, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_customizationController.GetHideoutCustomisation(sessionID, info)); } /// @@ -68,9 +94,9 @@ public class CustomizationCallbacks /// /// /// - public GetBodyResponseData> GetStorage(string url, EmptyRequestData info, string sessionID) + public string GetStorage(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_customizationController.GetCustomisationStorage(sessionID, info)); } /// @@ -82,6 +108,6 @@ public class CustomizationCallbacks /// public ItemEventRouterResponse SetClothing(PmcData pmcData, CustomizationSetRequest info, string sessionID) { - throw new NotImplementedException(); + return _customizationController.SetClothing(sessionID, info, pmcData); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/DataCallbacks.cs b/Core/Callbacks/DataCallbacks.cs index 1b94e341..ecb32aca 100644 --- a/Core/Callbacks/DataCallbacks.cs +++ b/Core/Callbacks/DataCallbacks.cs @@ -1,16 +1,43 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Helpers; +using Core.Models.Eft.Common; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.Game; using Core.Models.Eft.Hideout; using Core.Models.Eft.HttpResponse; using Core.Models.Spt.Server; +using Core.Services; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class DataCallbacks { - public DataCallbacks() + protected HttpResponseUtil _httpResponseUtil; + protected TimeUtil _timeUtil; + protected TraderHelper _traderHelper; + protected DatabaseService _databaseService; + protected TraderController _traderController; + protected HideoutController _hideoutController; + + public DataCallbacks + ( + HttpResponseUtil httpResponseUtil, + TimeUtil timeUtil, + TraderHelper traderHelper, + DatabaseService databaseService, + TraderController traderController, + HideoutController hideoutController + ) { + _httpResponseUtil = httpResponseUtil; + _timeUtil = timeUtil; + _traderHelper = traderHelper; + _databaseService = databaseService; + _traderController = traderController; + _hideoutController = hideoutController; } /// @@ -20,9 +47,9 @@ public class DataCallbacks /// /// /// - public GetBodyResponseData GetSettings(string url, EmptyRequestData info, string sessionID) + public string GetSettings(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_databaseService.GetSettings()); } /// @@ -32,9 +59,12 @@ public class DataCallbacks /// /// /// - public GetBodyResponseData GetGlobals(string url, EmptyRequestData info, string sessionID) + public string GetGlobals(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var globals = _databaseService.GetGlobals(); + globals.Time = _timeUtil.GetTimeStamp(); + + return _httpResponseUtil.GetBody(globals); } /// @@ -46,7 +76,7 @@ public class DataCallbacks /// public string GetTemplateItems(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetUnclearedBody(_databaseService.GetItems()); } /// @@ -56,9 +86,9 @@ public class DataCallbacks /// /// /// - public GetBodyResponseData GetTemplateHandbook(string url, EmptyRequestData info, string sessionID) + public string GetTemplateHandbook(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_databaseService.GetHandbook()); } /// @@ -68,9 +98,9 @@ public class DataCallbacks /// /// /// - public GetBodyResponseData> GetTemplateSuits(string url, EmptyRequestData info, string sessionID) + public string GetTemplateSuits(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_databaseService.GetTemplates().Customization); } /// @@ -80,9 +110,9 @@ public class DataCallbacks /// /// /// - public GetBodyResponseData> GetTemplateCharacter(string url, EmptyRequestData info, string sessionID) + public string GetTemplateCharacter(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_databaseService.GetTemplates().Character); } /// @@ -92,19 +122,19 @@ public class DataCallbacks /// /// /// - public GetBodyResponseData GetHideoutSettings(string url, EmptyRequestData info, string sessionID) + public string GetHideoutSettings(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_databaseService.GetHideout().Settings); } - public GetBodyResponseData> GetHideoutAreas(string url, EmptyRequestData info, string sessionID) + public string GetHideoutAreas(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_databaseService.GetHideout().Areas); } - public GetBodyResponseData GetHideoutProduction(string url, EmptyRequestData info, string sessionID) + public string GetHideoutProduction(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_databaseService.GetHideout().Production); } /// @@ -114,9 +144,9 @@ public class DataCallbacks /// /// /// - public GetBodyResponseData> GetLocalesLanguages(string url, EmptyRequestData info, string sessionID) + public string GetLocalesLanguages(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_databaseService.GetLocales().Languages); } /// @@ -126,9 +156,19 @@ public class DataCallbacks /// /// /// - public GetBodyResponseData GetLocalesMenu(string url, EmptyRequestData info, string sessionID) + public string GetLocalesMenu(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var localeId = url.Replace("/client/menu/locale/", ""); + var locales = _databaseService.GetLocales(); + var result = locales.Menu[localeId]; + + if (result == null) + result = locales.Menu.FirstOrDefault(m => m.Key == "en").Value; + + if (result == null) + throw new Exception($"Unable to determine locale for request with {localeId}"); + + return _httpResponseUtil.GetBody(result); } /// @@ -140,7 +180,14 @@ public class DataCallbacks /// public string GetLocalesGlobal(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var localeId = url.Replace("/client/locale/", ""); + var locales = _databaseService.GetLocales(); + var result = locales.Global[localeId]; + + if (result == null) + result = locales.Global.FirstOrDefault(m => m.Key == "en").Value; + + return _httpResponseUtil.GetUnclearedBody(result); } /// @@ -152,6 +199,7 @@ public class DataCallbacks /// public string GetQteList(string url, EmptyRequestData info, string sessionID) { + // return _httpResponseUtil.GetUnclearedBody(_hideoutController.GetQteList(sessionID)); TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -162,8 +210,10 @@ public class DataCallbacks /// /// /// - public GetBodyResponseData GetItemPrices(string url, EmptyRequestData info, string sessionID) + public string GetItemPrices(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var traderId = url.Replace("/client/items/prices/", ""); + + return _httpResponseUtil.GetBody(_traderController.GetItemPrices(sessionID, traderId)); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/DialogCallbacks.cs b/Core/Callbacks/DialogCallbacks.cs index 5d7af987..8cd69882 100644 --- a/Core/Callbacks/DialogCallbacks.cs +++ b/Core/Callbacks/DialogCallbacks.cs @@ -1,18 +1,33 @@ using Core.Annotations; +using Core.Controllers; using Core.DI; using Core.Models.Eft.Common; using Core.Models.Eft.Common.Request; using Core.Models.Eft.Dialog; -using Core.Models.Eft.HttpResponse; -using Core.Models.Eft.Profile; +using Core.Utils; namespace Core.Callbacks; [Injectable(TypePriority = OnUpdateOrder.DialogCallbacks)] public class DialogCallbacks : OnUpdate { - public DialogCallbacks() + protected HashUtil _hashUtil; + protected TimeUtil _timeUtil; + protected HttpResponseUtil _httpResponseUtil; + protected DialogueController _dialogueController; + + public DialogCallbacks + ( + HashUtil hashUtil, + TimeUtil timeUtil, + HttpResponseUtil httpResponseUtil, + DialogueController dialogueController + ) { + _hashUtil = hashUtil; + _timeUtil = timeUtil; + _httpResponseUtil = httpResponseUtil; + _dialogueController = dialogueController; } /// @@ -22,9 +37,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData GetFriendList(string url, EmptyRequestData info, string sessionID) + public string GetFriendList(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_dialogueController.GetFriendList(sessionID)); } /// @@ -34,9 +49,26 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData> GetChatServerList(string url, GetChatServerListRequestData info, string sessionID) + public string GetChatServerList(string url, GetChatServerListRequestData info, string sessionID) { - throw new NotImplementedException(); + var chatServer = new List() + { + new ChatServer() + { + Id = _hashUtil.Generate(), + RegistrationId = 20, + DateTime = _timeUtil.GetTimeStamp(), + IsDeveloper = true, + Regions = new() { "EUR" }, + VersionId = "bgkidft87ddd", + Ip = "", + Port = 0, + Chats = [new() { Id = "0", Members = 0 }], + } + }; + + + return _httpResponseUtil.GetBody(chatServer); } /// @@ -46,9 +78,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData> GetMailDialogList(string url, GetMailDialogListRequestData info, string sessionID) + public string GetMailDialogList(string url, GetMailDialogListRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_dialogueController.GenerateDialogueList(sessionID), 0, null, false); } /// @@ -58,9 +90,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData GetMailDialogView(string url, GetMailDialogViewRequestData info, string sessionID) + public string GetMailDialogView(string url, GetMailDialogViewRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_dialogueController.GenerateDialogueView(info, sessionID), 0, null, false); } /// @@ -70,9 +102,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData GetMailDialogInfo(string url, GetMailDialogInfoRequestData info, string sessionID) + public string GetMailDialogInfo(string url, GetMailDialogInfoRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_dialogueController.GetDialogueInfo(info.DialogId, sessionID)); } /// @@ -82,9 +114,10 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData> RemoveDialog(string url, RemoveDialogRequestData info, string sessionID) + public string RemoveDialog(string url, RemoveDialogRequestData info, string sessionID) { - throw new NotImplementedException(); + _dialogueController.RemoveDialogue(info.DialogId, sessionID); + return _httpResponseUtil.EmptyArrayResponse(); } /// @@ -94,9 +127,10 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData> PinDialog(string url, PinDialogRequestData info, string sessionID) + public string PinDialog(string url, PinDialogRequestData info, string sessionID) { - throw new NotImplementedException(); + _dialogueController.SetDialoguePin(info.DialogId, true, sessionID); + return _httpResponseUtil.EmptyArrayResponse(); } /// @@ -106,9 +140,10 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData> UnpinDialog(string url, PinDialogRequestData info, string sessionID) + public string UnpinDialog(string url, PinDialogRequestData info, string sessionID) { - throw new NotImplementedException(); + _dialogueController.SetDialoguePin(info.DialogId, false, sessionID); + return _httpResponseUtil.EmptyArrayResponse(); } /// @@ -118,9 +153,10 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData> SetRead(string url, SetDialogReadRequestData info, string sessionID) + public string SetRead(string url, SetDialogReadRequestData info, string sessionID) { - throw new NotImplementedException(); + _dialogueController.SetRead(info.Dialogs, sessionID); + return _httpResponseUtil.EmptyArrayResponse(); } /// @@ -130,9 +166,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData GetAllAttachments(string url, EmptyRequestData info, string sessionID) // TODO: Fix type - GetBodyResponseData + public string GetAllAttachments(string url, GetAllAttachmentsRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_dialogueController.GetAllAttachments(info.DialogId, sessionID)); } /// @@ -142,9 +178,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData SendMessage(string url, SendMessageRequest info, string sessionID) + public string SendMessage(string url, SendMessageRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_dialogueController.SendMessage(sessionID, info)); } /// @@ -154,9 +190,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData> ListOutbox(string url, EmptyRequestData info, string sessionID) + public string ListOutbox(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.EmptyArrayResponse(); } /// @@ -166,9 +202,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData> ListInbox(string url, EmptyRequestData info, string sessionID) + public string ListInbox(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.EmptyArrayResponse(); } /// @@ -178,9 +214,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData SendFriendRequest(string url, FriendRequestData info, string sessionID) + public string SendFriendRequest(string url, FriendRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_dialogueController.SendFriendRequest(sessionID, info)); } /// @@ -190,9 +226,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public NullResponseData AcceptAllFriendRequests(string url, EmptyRequestData info, string sessionID) + public string AcceptAllFriendRequests(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -202,9 +238,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData AcceptFriendRequest(string url, AcceptFriendRequestData info, string sessionID) + public string AcceptFriendRequest(string url, AcceptFriendRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(true); } /// @@ -214,9 +250,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData DeclineFriendRequest(string url, DeclineFriendRequestData info, string sessionID) + public string DeclineFriendRequest(string url, DeclineFriendRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(true); } /// @@ -226,9 +262,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public GetBodyResponseData CancelFriendRequest(string url, CancelFriendRequestData info, string sessionID) + public string CancelFriendRequest(string url, CancelFriendRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(true); } /// @@ -238,9 +274,10 @@ public class DialogCallbacks : OnUpdate /// /// /// - public NullResponseData DeleteFriend(string url, DeleteFriendRequest info, string sessionID) + public string DeleteFriend(string url, DeleteFriendRequest info, string sessionID) { - throw new NotImplementedException(); + _dialogueController.DeleteFriend(sessionID, info); + return _httpResponseUtil.NullResponse(); } /// @@ -250,9 +287,9 @@ public class DialogCallbacks : OnUpdate /// /// /// - public NullResponseData IgnoreFriend(string url, UIDRequestData info, string sessionID) + public string IgnoreFriend(string url, UIDRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -262,48 +299,49 @@ public class DialogCallbacks : OnUpdate /// /// /// - public NullResponseData UnIgnoreFriend(string url, UIDRequestData info, string sessionID) + public string UnIgnoreFriend(string url, UIDRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } - public GetBodyResponseData> ClearMail(string url, ClearMailMessageRequest info, string sessionID) + public string ClearMail(string url, ClearMailMessageRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.EmptyArrayResponse(); } - public GetBodyResponseData> RemoveMail(string url, RemoveMailMessageRequest info, string sessionID) + public string RemoveMail(string url, RemoveMailMessageRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.EmptyArrayResponse(); } - public GetBodyResponseData> CreateGroupMail(string url, CreateGroupMailRequest info, string sessionID) + public string CreateGroupMail(string url, CreateGroupMailRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.EmptyArrayResponse(); } - public GetBodyResponseData> ChangeMailGroupOwner(string url, ChangeGroupMailOwnerRequest info, string sessionID) + public string ChangeMailGroupOwner(string url, ChangeGroupMailOwnerRequest info, string sessionID) { - throw new NotImplementedException(); + throw new NotImplementedException(); // Not implemented in Node } - public GetBodyResponseData> AddUserToMail(string url, AddUserGroupMailRequest info, string sessionID) + public string AddUserToMail(string url, AddUserGroupMailRequest info, string sessionID) { - throw new NotImplementedException(); + throw new NotImplementedException(); // Not implemented in Node } - public GetBodyResponseData> RemoveUserFromMail(string url, RemoveUserGroupMailRequest info, string sessionID) + public string RemoveUserFromMail(string url, RemoveUserGroupMailRequest info, string sessionID) { - throw new NotImplementedException(); + throw new NotImplementedException(); // Not implemented in Node } public async Task OnUpdate(long timeSinceLastRun) { - throw new NotImplementedException(); + _dialogueController.Update(); + return true; } public string GetRoute() { - throw new NotImplementedException(); + return "spt-dialogue"; } } diff --git a/Core/Callbacks/GameCallbacks.cs b/Core/Callbacks/GameCallbacks.cs index dd262195..a31e7f59 100644 --- a/Core/Callbacks/GameCallbacks.cs +++ b/Core/Callbacks/GameCallbacks.cs @@ -1,27 +1,48 @@ using Core.Annotations; +using Core.Controllers; using Core.DI; using Core.Models.Eft.Common; using Core.Models.Eft.Common.Request; using Core.Models.Eft.Game; using Core.Models.Eft.HttpResponse; +using Core.Servers; +using Core.Utils; namespace Core.Callbacks; [Injectable(TypePriority = OnLoadOrder.GameCallbacks)] public class GameCallbacks : OnLoad { - public GameCallbacks() + protected HttpResponseUtil _httpResponseUtil; + protected Watermark _watermark; + protected SaveServer _saveServer; + protected GameController _gameController; + protected TimeUtil _timeUtil; + + public GameCallbacks + ( + HttpResponseUtil httpResponseUtil, + Watermark watermark, + SaveServer saveServer, + GameController gameController, + TimeUtil timeUtil + ) { + _httpResponseUtil = httpResponseUtil; + _watermark = watermark; + _saveServer = saveServer; + _gameController = gameController; + _timeUtil = timeUtil; } public async Task OnLoad() { - throw new NotImplementedException(); + _gameController.Load(); } public string GetRoute() { - throw new NotImplementedException(); + return "spt-game"; } /// @@ -31,9 +52,9 @@ public class GameCallbacks : OnLoad /// /// /// - public NullResponseData VersionValidate(string url, VersionValidateRequestData info, string sessionID) + public string VersionValidate(string url, VersionValidateRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -43,9 +64,12 @@ public class GameCallbacks : OnLoad /// /// /// - public GetBodyResponseData GameStart(string url, EmptyRequestData info, string sessionID) + public string GameStart(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var today = _timeUtil.GetDate(); + var startTimestampMS = _timeUtil.GetTimeStamp(); + _gameController.GameStart(url, info, sessionID, startTimestampMS); + return _httpResponseUtil.GetBody(new GameStartResponse() { UtcTime = startTimestampMS / 1000 }); } /// @@ -56,9 +80,10 @@ public class GameCallbacks : OnLoad /// /// /// - public GetBodyResponseData GameLogout(string url, EmptyRequestData info, string sessionID) + public string GameLogout(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + _saveServer.Save(); + return _httpResponseUtil.GetBody(new GameLogoutResponseData() { Status = "ok" }); } /// @@ -68,9 +93,9 @@ public class GameCallbacks : OnLoad /// /// /// - public GetBodyResponseData GetGameConfig(string url, GameEmptyCrcRequestData info, string sessionID) + public string GetGameConfig(string url, GameEmptyCrcRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_gameController.GetGameConfig(sessionID)); } /// @@ -80,9 +105,9 @@ public class GameCallbacks : OnLoad /// /// /// - public GetBodyResponseData GetGameMode(string url, GameModeRequestData info, string sessionID) + public string GetGameMode(string url, GameModeRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_gameController.GetGameMode(sessionID, info)); } /// @@ -92,9 +117,9 @@ public class GameCallbacks : OnLoad /// /// /// - public GetBodyResponseData> GetServer(string url, EmptyRequestData info, string sessionID) + public string GetServer(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_gameController.GetServer(sessionID)); } /// @@ -104,9 +129,9 @@ public class GameCallbacks : OnLoad /// /// /// - public GetBodyResponseData GetCurrentGroup(string url, EmptyRequestData info, string sessionID) + public string GetCurrentGroup(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_gameController.GetCurrentGroup(sessionID)); } /// @@ -116,9 +141,9 @@ public class GameCallbacks : OnLoad /// /// /// - public GetBodyResponseData ValidateGameVersion(string url, EmptyRequestData info, string sessionID) + public string ValidateGameVersion(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_gameController.GetValidGameVersion(sessionID)); } /// @@ -128,9 +153,9 @@ public class GameCallbacks : OnLoad /// /// /// - public GetBodyResponseData GameKeepalive(string url, EmptyRequestData info, string sessionID) + public string GameKeepalive(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_gameController.GetKeepAlive(sessionID)); } /// @@ -142,7 +167,8 @@ public class GameCallbacks : OnLoad /// public string GetVersion(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + // change to be a proper type + return _httpResponseUtil.NoBody(new { Version = _watermark.GetInGameVersionLabel() }); } /// @@ -152,9 +178,9 @@ public class GameCallbacks : OnLoad /// /// /// - public NullResponseData ReportNickname(string url, UIDRequestData info, string sessionID) + public string ReportNickname(string url, UIDRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -164,9 +190,9 @@ public class GameCallbacks : OnLoad /// /// /// - public GetRaidTimeResponse GetRaidTime(string url, GetRaidTimeRequest info, string sessionID) + public string GetRaidTime(string url, GetRaidTimeRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NoBody(_gameController.GetRaidTime(sessionID, info)); } /// @@ -176,9 +202,9 @@ public class GameCallbacks : OnLoad /// /// /// - public object GetSurvey(string url, EmptyRequestData info, string sessionID) // TODO: Types given was NullResponseData | GetBodyResponseData + public string GetSurvey(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_gameController.GetSurvey(sessionID)); } /// @@ -188,9 +214,9 @@ public class GameCallbacks : OnLoad /// /// /// - public NullResponseData GetSurveyView(string url, object info, string sessionID) + public string GetSurveyView(string url, object info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -200,8 +226,8 @@ public class GameCallbacks : OnLoad /// /// /// - public NullResponseData SendSurveyOpinion(string url, SendSurveyOpinionRequest info, string sessionID) + public string SendSurveyOpinion(string url, SendSurveyOpinionRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } } diff --git a/Core/Callbacks/HandbookCallbacks.cs b/Core/Callbacks/HandbookCallbacks.cs index 4fe5e97c..01b482a3 100644 --- a/Core/Callbacks/HandbookCallbacks.cs +++ b/Core/Callbacks/HandbookCallbacks.cs @@ -1,4 +1,5 @@ using Core.Annotations; +using Core.Controllers; using Core.DI; namespace Core.Callbacks; @@ -6,17 +7,23 @@ namespace Core.Callbacks; [Injectable(TypePriority = OnLoadOrder.HandbookCallbacks)] public class HandbookCallbacks : OnLoad { - public HandbookCallbacks() + protected HandBookController _handBookController; + + public HandbookCallbacks + ( + HandBookController handBookController + ) { + _handBookController = handBookController; } - public Task OnLoad() + public async Task OnLoad() { - throw new NotImplementedException(); + _handBookController.Load(); } public string GetRoute() { - throw new NotImplementedException(); + return "spt-handbook"; } } diff --git a/Core/Callbacks/HealthCallbacks.cs b/Core/Callbacks/HealthCallbacks.cs index dbbe3f33..0056cf5f 100644 --- a/Core/Callbacks/HealthCallbacks.cs +++ b/Core/Callbacks/HealthCallbacks.cs @@ -1,14 +1,31 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Helpers; +using Core.Models.Eft.Common; using Core.Models.Eft.Health; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.ItemEvent; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class HealthCallbacks { - public HealthCallbacks() + protected HttpResponseUtil _httpResponseUtil; + protected ProfileHelper _profileHelper; + protected HealthController _healthController; + + public HealthCallbacks + ( + HttpResponseUtil httpResponseUtil, + ProfileHelper profileHelper, + HealthController healthController + ) { + _httpResponseUtil = httpResponseUtil; + _profileHelper = profileHelper; + _healthController = healthController; } /// @@ -18,9 +35,10 @@ public class HealthCallbacks /// HealthListener.Instance.CurrentHealth class /// session id /// empty response, no data sent back to client - public GetBodyResponseData handleWorkoutEffects(string url, WorkoutData info, string sessionID) + public string handleWorkoutEffects(string url, WorkoutData info, string sessionID) { - throw new NotImplementedException(); + _healthController.ApplyWorkoutChanges(_profileHelper.GetPmcProfile(sessionID), info, sessionID); + return _httpResponseUtil.EmptyResponse(); } /// @@ -33,7 +51,7 @@ public class HealthCallbacks /// public ItemEventRouterResponse OffraidEat(PmcData pmcData, OffraidEatRequestData info, string sessionID) { - throw new NotImplementedException(); + return _healthController.OffRaidEat(pmcData, info, sessionID); } /// @@ -46,7 +64,7 @@ public class HealthCallbacks /// public ItemEventRouterResponse OffraidHeal(PmcData pmcData, OffraidHealRequestData info, string sessionID) { - throw new NotImplementedException(); + return _healthController.OffRaidHeal(pmcData, info, sessionID); } /// @@ -59,6 +77,6 @@ public class HealthCallbacks /// public ItemEventRouterResponse HealthTreatment(PmcData pmcData, HealthTreatmentRequestData info, string sessionID) { - throw new NotImplementedException(); + return _healthController.HealthTreatment(pmcData, info, sessionID); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/HideoutCallbacks.cs b/Core/Callbacks/HideoutCallbacks.cs index 7dd79e27..853eb772 100644 --- a/Core/Callbacks/HideoutCallbacks.cs +++ b/Core/Callbacks/HideoutCallbacks.cs @@ -1,17 +1,32 @@ -using Core.DI; +using Core.Annotations; +using Core.Controllers; +using Core.DI; using Core.Models.Eft.Common; using Core.Models.Eft.Hideout; using Core.Models.Eft.ItemEvent; +using Core.Models.Enums; using Core.Models.Spt.Config; +using Core.Servers; namespace Core.Callbacks; +[Injectable] public class HideoutCallbacks : OnUpdate { - private HideoutConfig _hideoutConfig; + protected HideoutController _hideoutController; + protected ConfigServer _configServer; - public HideoutCallbacks() + protected HideoutConfig _hideoutConfig; + + public HideoutCallbacks + ( + HideoutController hideoutController, + ConfigServer configServer + ) { + _hideoutController = hideoutController; + _configServer = configServer; + _hideoutConfig = configServer.GetConfig(ConfigTypes.HIDEOUT); } /// @@ -21,9 +36,11 @@ public class HideoutCallbacks : OnUpdate /// /// /// - public ItemEventRouterResponse Upgrade(PmcData pmcData, HideoutUpgradeRequestData info, string sessionID) + public ItemEventRouterResponse Upgrade(PmcData pmcData, HideoutUpgradeRequestData info, string sessionID, ItemEventRouterResponse output) { - throw new NotImplementedException(); + // _hideoutController.StartUpgrade(pmcData, info, sessionID, output); + // TODO: HideoutController is not implemented rn + return output; } /// @@ -33,9 +50,11 @@ public class HideoutCallbacks : OnUpdate /// /// /// - public ItemEventRouterResponse UpgradeComplete(PmcData pmcData, HideoutUpgradeCompleteRequestData info, string sessionID) + public ItemEventRouterResponse UpgradeComplete(PmcData pmcData, HideoutUpgradeCompleteRequestData info, string sessionID, ItemEventRouterResponse output) { - throw new NotImplementedException(); + // _hideoutController.UpgradeComplete(pmcData, info, sessionID, output); + // TODO: HideoutController is not implemented rn + return output; } /// @@ -47,6 +66,8 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse PutItemsInAreaSlots(PmcData pmcData, HideoutPutItemInRequestData info, string sessionID) { + // return _hideoutController.PutItemsInAreaSlots(pmcData, info, sessionID); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -59,6 +80,8 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse TakeItemsFromAreaSlots(PmcData pmcData, HideoutTakeItemOutRequestData info, string sessionID) { + // return _hideoutController.TakeItemsFromAreaSlots(pmcData, info, sessionID); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -71,6 +94,8 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse ToggleArea(PmcData pmcData, HideoutToggleAreaRequestData info, string sessionID) { + // return _hideoutController.ToggleArea(pmcData, info, sessionID); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -83,6 +108,8 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse SingleProductionStart(PmcData pmcData, HideoutSingleProductionStartRequestData info, string sessionID) { + // return _hideoutController.SingleProductionStart(pmcData, info, sessionID); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -95,6 +122,8 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse ScavCaseProductionStart(PmcData pmcData, HideoutScavCaseStartRequestData info, string sessionID) { + // return _hideoutController.ScavCaseProductionStart(pmcData, info, sessionID); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -107,6 +136,8 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse ContinuousProductionStart(PmcData pmcData, HideoutContinuousProductionStartRequestData info, string sessionID) { + // return _hideoutController.ContinuousProductionStart(pmcData, info, sessionID); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -119,6 +150,8 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse TakeProduction(PmcData pmcData, HideoutTakeProductionRequestData info, string sessionID) { + // return _hideoutController.TakeProduction(pmcData, info, sessionID); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -132,7 +165,9 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse HandleQTEEvent(PmcData pmcData, HandleQTEEventRequestData info, string sessionID, ItemEventRouterResponse output) { - throw new NotImplementedException(); + // _hideoutController.HandleQTEEventOutcome(sessionID, pmcData, info, output); + // TODO: HideoutController is not implemented rn + return output; } /// @@ -145,7 +180,9 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse RecordShootingRangePoints(PmcData pmcData, RecordShootingRangePoints info, string sessionID, ItemEventRouterResponse output) { - throw new NotImplementedException(); + // _hideoutController.RecordShootingRangePoints(sessionID, pmcData, info); + // TODO: HideoutController is not implemented rn + return output; } /// @@ -157,6 +194,8 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse ImproveArea(PmcData pmcData, HideoutImproveAreaRequestData info, string sessionID) { + // return _hideoutController.ImproveArea(sessionID, pmcData, info); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -169,6 +208,8 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse CancelProduction(PmcData pmcData, HideoutImproveAreaRequestData info, string sessionID) { + // return _hideoutController.CancelProduction(sessionID, pmcData, info); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -181,6 +222,8 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse CicleOfCultistProductionStart(PmcData pmcData, HideoutCircleOfCultistProductionStartRequestData info, string sessionID) { + // return _hideoutController.CicleOfCultistProductionStart(sessionID, pmcData, info); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -191,8 +234,10 @@ public class HideoutCallbacks : OnUpdate /// /// /// - public ItemEventRouterResponse HideoutDeleteProductionRequestData(PmcData pmcData, HideoutDeleteProductionRequestData info, string sessionID) + public ItemEventRouterResponse HideoutDeleteProductionCommand(PmcData pmcData, HideoutDeleteProductionRequestData info, string sessionID) { + // return _hideoutController.HideoutDeleteProductionCommand(sessionID, pmcData, info); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } @@ -205,16 +250,24 @@ public class HideoutCallbacks : OnUpdate /// public ItemEventRouterResponse HideoutCustomizationApplyCommand(PmcData pmcData, HideoutCustomizationApplyRequestData info, string sessionID) { + // return _hideoutController.HideoutCustomizationApply(sessionID, pmcData, info); + // TODO: HideoutController is not implemented rn throw new NotImplementedException(); } public async Task OnUpdate(long timeSinceLastRun) { - throw new NotImplementedException(); + if (timeSinceLastRun > _hideoutConfig.RunIntervalSeconds) + { + // _hideoutController.Update(); + return true; + } + + return false; } public string GetRoute() { - throw new NotImplementedException(); + return "spt-hideout"; } -} \ No newline at end of file +} diff --git a/Core/Callbacks/InraidCallbacks.cs b/Core/Callbacks/InraidCallbacks.cs index 2515a592..4b6b100f 100644 --- a/Core/Callbacks/InraidCallbacks.cs +++ b/Core/Callbacks/InraidCallbacks.cs @@ -1,13 +1,26 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.InRaid; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class InraidCallbacks { - public InraidCallbacks() + protected InRaidController _inRaidController; + protected HttpResponseUtil _httpResponseUtil; + + public InraidCallbacks + ( + InRaidController inRaidController, + HttpResponseUtil httpResponseUtil + ) { + _inRaidController = inRaidController; + _httpResponseUtil = httpResponseUtil; } /// @@ -18,9 +31,10 @@ public class InraidCallbacks /// register player request /// Session id /// Null http response - public NullResponseData RegisterPlayer(string url, RegisterPlayerRequestData info, string sessionID) + public string RegisterPlayer(string url, RegisterPlayerRequestData info, string sessionID) { - throw new NotImplementedException(); + _inRaidController.AddPlayer(sessionID, info); + return _httpResponseUtil.NullResponse(); } /// @@ -30,9 +44,10 @@ public class InraidCallbacks /// Save progress request /// Session id /// Null http response - public NullResponseData SaveProgress(string url, ScavSaveRequestData info, string sessionID) + public string SaveProgress(string url, ScavSaveRequestData info, string sessionID) { - throw new NotImplementedException(); + _inRaidController.SavePostRaidProfileForScav(info, sessionID); + return _httpResponseUtil.NullResponse(); } /// @@ -41,16 +56,16 @@ public class InraidCallbacks /// JSON as string public string GetRaidMenuSettings() { - throw new NotImplementedException(); + return _httpResponseUtil.NoBody(_inRaidController.GetInRaidConfig().RaidMenuSettings); } public string GetTraitorScavHostileChance(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NoBody(_inRaidController.GetTraitorScavHostileChance(url, sessionID)); } public string GetBossConvertSettings(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NoBody(_inRaidController.GetBossConvertSettings(url, sessionID)); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/InsuranceCallbacks.cs b/Core/Callbacks/InsuranceCallbacks.cs index 3b5fc456..f1c9a56c 100644 --- a/Core/Callbacks/InsuranceCallbacks.cs +++ b/Core/Callbacks/InsuranceCallbacks.cs @@ -1,18 +1,41 @@ -using Core.DI; +using Core.Annotations; +using Core.Controllers; +using Core.DI; using Core.Models.Eft.Common; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.Insurance; using Core.Models.Eft.ItemEvent; +using Core.Models.Enums; using Core.Models.Spt.Config; +using Core.Servers; +using Core.Services; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class InsuranceCallbacks : OnUpdate { + protected InsuranceController _insuranceController; + protected InsuranceService _insuranceService; + protected HttpResponseUtil _httpResponseUtil; + protected ConfigServer _configServer; + private InsuranceConfig _insuranceConfig; - public InsuranceCallbacks() + public InsuranceCallbacks + ( + InsuranceController insuranceController, + InsuranceService insuranceService, + HttpResponseUtil httpResponseUtil, + ConfigServer configServer + ) { + _insuranceController = insuranceController; + _insuranceService = insuranceService; + _httpResponseUtil = httpResponseUtil; + _configServer = configServer; + _insuranceConfig = configServer.GetConfig(ConfigTypes.INSURANCE); } /// @@ -22,8 +45,10 @@ public class InsuranceCallbacks : OnUpdate /// /// /// - public GetBodyResponseData GetInsuranceCost(string url, GetInsuranceCostRequestData info, string sessionID) + public string GetInsuranceCost(string url, GetInsuranceCostRequestData info, string sessionID) { + // return _httpResponseUtil.GetBody(_insuranceController.Cost(info, sessionID)); + // TODO: InsuranceController is not implemented rn throw new NotImplementedException(); } @@ -36,16 +61,25 @@ public class InsuranceCallbacks : OnUpdate /// public ItemEventRouterResponse Insure(PmcData pmcData, InsureRequestData info, string sessionID) { + // return _insuranceController.Insure(pmcData, info, sessionID); + // TODO: InsuranceController is not implemented rn throw new NotImplementedException(); } - public Task OnUpdate(long timeSinceLastRun) + public async Task OnUpdate(long timeSinceLastRun) { - throw new NotImplementedException(); + if (timeSinceLastRun > Math.Max(_insuranceConfig.RunIntervalSeconds, 1)) + { + // _insuranceController.ProcessReturn(); + // TODO: InsuranceController is not implemented rn + return true; + } + + return false; } public string GetRoute() { - throw new NotImplementedException(); + return "spt-insurance"; } -} \ No newline at end of file +} diff --git a/Core/Callbacks/InventoryCallbacks.cs b/Core/Callbacks/InventoryCallbacks.cs index aa439dbb..2ebe275b 100644 --- a/Core/Callbacks/InventoryCallbacks.cs +++ b/Core/Callbacks/InventoryCallbacks.cs @@ -1,14 +1,26 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.Inventory; using Core.Models.Eft.ItemEvent; using Core.Models.Eft.Quests; namespace Core.Callbacks; +[Injectable] public class InventoryCallbacks { - public InventoryCallbacks() + protected InventoryController _inventoryController; + protected QuestController _questController; + + public InventoryCallbacks + ( + InventoryController inventoryController, + QuestController questController + ) { + _inventoryController = inventoryController; + _questController = questController; } /// @@ -18,9 +30,11 @@ public class InventoryCallbacks /// /// /// - /// - public ItemEventRouterResponse MoveItem(PmcData pmcData, InventoryMoveRequestData info, string sessionID) + public ItemEventRouterResponse MoveItem(PmcData pmcData, InventoryMoveRequestData info, string sessionID, ItemEventRouterResponse output) { + // _inventoryController.MoveItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } @@ -31,9 +45,11 @@ public class InventoryCallbacks /// /// /// - /// public ItemEventRouterResponse RemoveItem(PmcData pmcData, InventoryRemoveRequestData info, string sessionID) { + // _inventoryController.RemoveItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } @@ -44,19 +60,41 @@ public class InventoryCallbacks /// /// /// - /// public ItemEventRouterResponse SplitItem(PmcData pmcData, InventorySplitRequestData info, string sessionID) { + // _inventoryController.SplitItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse MergeItem(PmcData pmcData, InventoryMergeRequestData info, string sessionID) { + // _inventoryController.MergeItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse TransferItem(PmcData pmcData, InventoryTransferRequestData info, string sessionID) { + // _inventoryController.TransferItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } @@ -67,39 +105,101 @@ public class InventoryCallbacks /// /// /// - /// public ItemEventRouterResponse SwapItem(PmcData pmcData, InventorySwapRequestData info, string sessionID) { + // _inventoryController.SwapItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse FoldItem(PmcData pmcData, InventoryFoldRequestData info, string sessionID) { + // _inventoryController.FoldItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse ToggleItem(PmcData pmcData, InventoryToggleRequestData info, string sessionID) { + // _inventoryController.ToggleItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse TagItem(PmcData pmcData, InventoryTagRequestData info, string sessionID) { + // _inventoryController.TagItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse BindItem(PmcData pmcData, InventoryBindRequestData info, string sessionID) { + // _inventoryController.BindItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse UnBindItem(PmcData pmcData, InventoryBindRequestData info, string sessionID) { + // _inventoryController.UnBindItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse ExamineItem(PmcData pmcData, InventoryExamineRequestData info, string sessionID) { + // _inventoryController.ExamineItem(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } @@ -110,9 +210,11 @@ public class InventoryCallbacks /// /// /// - /// public ItemEventRouterResponse ReadEncyclopedia(PmcData pmcData, InventoryReadEncyclopediaRequestData info, string sessionID) { + // _inventoryController.ReadEncyclopedia(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } @@ -123,24 +225,56 @@ public class InventoryCallbacks /// /// /// - /// public ItemEventRouterResponse SortInventory(PmcData pmcData, InventorySortRequestData info, string sessionID) { + // _inventoryController.SortInventory(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse CreateMapMarker(PmcData pmcData, InventoryCreateMarkerRequestData info, string sessionID) { + // _inventoryController.CreateMapMarker(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse DeleteMapMarker(PmcData pmcData, InventoryDeleteMarkerRequestData info, string sessionID) { + // _inventoryController.DeleteMapMarker(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse EditMapMarker(PmcData pmcData, InventoryEditMarkerRequestData info, string sessionID) { + // _inventoryController.EditMapMarker(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } @@ -152,20 +286,44 @@ public class InventoryCallbacks /// /// /// - /// public ItemEventRouterResponse OpenRandomLootContainer(PmcData pmcData, OpenRandomLootContainerRequestData info, string sessionID, ItemEventRouterResponse output) { + // _inventoryController.OpenRandomLootContainer(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse RedeemProfileReward(PmcData pmcData, RedeemProfileRequestData info, string sessionID, ItemEventRouterResponse output) { + // _inventoryController.RedeemProfileReward(pmcData, info, sessionID); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse SetFavoriteItem(PmcData pmcData, SetFavoriteItems info, string sessionID, ItemEventRouterResponse output) { + // _inventoryController.SetFavoriteItem(pmcData, info, sessionID); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } @@ -178,14 +336,27 @@ public class InventoryCallbacks /// /// /// - /// public ItemEventRouterResponse FailQuest(PmcData pmcData, FailQuestRequestData info, string sessionID, ItemEventRouterResponse output) { + // _inventoryController.FailQuest(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } + /// + /// + /// + /// + /// + /// + /// + /// public ItemEventRouterResponse PinOrLock(PmcData pmcData, PinOrLockItemRequest info, string sessionID, ItemEventRouterResponse output) { + // _inventoryController.PinOrLock(pmcData, info, sessionID, output); + // TODO: InventoryController is not implemented rn + // return output; throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/ItemEventCallbacks.cs b/Core/Callbacks/ItemEventCallbacks.cs index ffcb3c21..f150b0c1 100644 --- a/Core/Callbacks/ItemEventCallbacks.cs +++ b/Core/Callbacks/ItemEventCallbacks.cs @@ -1,16 +1,35 @@ -using Core.Models.Eft.HttpResponse; +using Core.Annotations; +using Core.Models.Eft.HttpResponse; using Core.Models.Eft.ItemEvent; +using Core.Models.Enums; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class ItemEventCallbacks { - public ItemEventCallbacks() + protected HttpResponseUtil _httpResponseUtil; + // protected ItemEventRouter _itemEventRouter; + + public ItemEventCallbacks + ( + HttpResponseUtil httpResponseUtil + // TODO: Implement ItemEventRouter + // ItemEventRouter itemEventRouter + ) { + _httpResponseUtil = httpResponseUtil; + // _itemEventRouter = itemEventRouter; } public async Task> HandleEvents(string url, ItemEventRouterRequest info, string sessionID) { + // var eventResponse = await _itemEventRouter.HandleEvents(info, sessionID); + // var result = IsCriticalError(ItemEventRouterResponse.Warnings) + // ? _httpResponseUtil.GetBody(eventResponse, GetErrorCode(eventResponse.Warnings), eventResponse.Warnings[0].Errmsg) + // : _httpResponseUtil.GetBody(eventResponse); + // TODO: Implement ItemEventRouter throw new NotImplementedException(); } @@ -19,14 +38,30 @@ public class ItemEventCallbacks /// /// The list of warnings to check for critical errors /// - /// public bool IsCriticalError(List warnings) { - throw new NotImplementedException(); + // List of non-critical error codes, we return true if any error NOT included is passed in + var nonCriticalErrorCodes = new List() { BackendErrorCodes.NOTENOUGHSPACE }; + + foreach (var warning in warnings) + { + BackendErrorCodes code; + + if (!BackendErrorCodes.TryParse(warning.Code, out code)) + throw new Exception($"Unable to parse [{warning.Code}] to BackendErrorCode."); + + if (!nonCriticalErrorCodes.Contains(code)) + return true; + } + + return false; } - public int GetErrorCode(List warnings) + public int? GetErrorCode(List warnings) { - throw new NotImplementedException(); + if (warnings[0].Code != null) + return int.Parse(warnings[0]?.Code); + + return int.Parse(BackendErrorCodes.UNKNOWN_ERROR.ToString()); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/LocationCallbacks.cs b/Core/Callbacks/LocationCallbacks.cs index 4d425b5e..2c471905 100644 --- a/Core/Callbacks/LocationCallbacks.cs +++ b/Core/Callbacks/LocationCallbacks.cs @@ -1,14 +1,27 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.Location; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class LocationCallbacks { - public LocationCallbacks() + protected HttpResponseUtil _httpResponseUtil; + protected LocationController _locationController; + + public LocationCallbacks + ( + HttpResponseUtil httpResponseUtil, + LocationController locationController + ) { + _httpResponseUtil = httpResponseUtil; + _locationController = locationController; } /// @@ -18,10 +31,9 @@ public class LocationCallbacks /// /// /// - /// - public GetBodyResponseData GetLocationData(string url, EmptyRequestData info, string sessionID) + public string GetLocationData(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_locationController.GenerateAll(sessionID)); } /// @@ -31,9 +43,8 @@ public class LocationCallbacks /// /// /// - /// - public GetBodyResponseData GetAirdropLoot(string url, GetAirdropLootRequest info, string sessionID) + public string GetAirdropLoot(string url, GetAirdropLootRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_locationController.GetAirDropLoot(info)); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/MatchCallbacks.cs b/Core/Callbacks/MatchCallbacks.cs index 5ac1972f..03c7ebf6 100644 --- a/Core/Callbacks/MatchCallbacks.cs +++ b/Core/Callbacks/MatchCallbacks.cs @@ -1,14 +1,34 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.Match; +using Core.Services; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class MatchCallbacks { - public MatchCallbacks() + protected HttpResponseUtil _httpResponseUtil; + protected JsonUtil _jsonUtil; + protected MatchController _matchController; + protected DatabaseService _databaseService; + + public MatchCallbacks + ( + HttpResponseUtil httpResponseUtil, + JsonUtil jsonUtil, + MatchController matchController, + DatabaseService databaseService + ) { + _httpResponseUtil = httpResponseUtil; + _jsonUtil = jsonUtil; + _matchController = matchController; + _databaseService = databaseService; } /// @@ -18,9 +38,9 @@ public class MatchCallbacks /// /// /// - public NullResponseData UpdatePing(string url, EmptyRequestData info, string sessionID) + public string UpdatePing(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -30,9 +50,9 @@ public class MatchCallbacks /// /// /// - public NullResponseData ExitMatch(string url, EmptyRequestData info, string sessionID) + public string ExitMatch(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -42,9 +62,9 @@ public class MatchCallbacks /// /// /// - public NullResponseData ExitFromMenu(string url, EmptyRequestData info, string sessionID) + public string ExitFromMenu(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -54,9 +74,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData GroupCurrent(string url, EmptyRequestData info, string sessionID) + public string GroupCurrent(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(new MatchGroupCurrentResponse() { Squad = new() }); } /// @@ -66,9 +86,9 @@ public class MatchCallbacks /// /// /// - public NullResponseData StartGroupSearch(string url, EmptyRequestData info, string sessionID) + public string StartGroupSearch(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -78,9 +98,9 @@ public class MatchCallbacks /// /// /// - public NullResponseData StopGroupSearch(string url, EmptyRequestData info, string sessionID) + public string StopGroupSearch(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -90,9 +110,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData SendGroupInvite(string url, MatchGroupInviteSendRequest info, string sessionID) + public string SendGroupInvite(string url, MatchGroupInviteSendRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody("2427943f23698ay9f2863735"); } /// @@ -102,9 +122,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData> AcceptGroupInvite(string url, RequestIdRequest info, string sessionID) + public string AcceptGroupInvite(string url, RequestIdRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(new List() { new GroupCharacter() }); } /// @@ -114,9 +134,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData DeclineGroupInvite(string url, RequestIdRequest info, string sessionID) + public string DeclineGroupInvite(string url, RequestIdRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(true); } /// @@ -126,9 +146,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData CancelGroupInvite(string url, RequestIdRequest info, string sessionID) + public string CancelGroupInvite(string url, RequestIdRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(true); } /// @@ -138,9 +158,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData TransferGroup(string url, MatchGroupTransferRequest info, string sessionID) + public string TransferGroup(string url, MatchGroupTransferRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(true); } /// @@ -150,9 +170,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData CancelAllGroupInvite(string url, EmptyRequestData info, string sessionID) + public string CancelAllGroupInvite(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(true); } /// @@ -162,9 +182,9 @@ public class MatchCallbacks /// /// /// - public NullResponseData PutMetrics(string url, PutMetricsRequestData info, string sessionID) + public string PutMetrics(string url, PutMetricsRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -174,9 +194,9 @@ public class MatchCallbacks /// /// /// - public NullResponseData EventDisconnect(string url, PutMetricsRequestData info, string sessionID) + public string EventDisconnect(string url, PutMetricsRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -186,9 +206,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData ServerAvailable(string url, EmptyRequestData info, string sessionID) + public string ServerAvailable(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_matchController.GetEnabled()); } /// @@ -198,9 +218,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData JoinMatch(string url, MatchGroupStartGameRequest info, string sessionID) + public string JoinMatch(string url, MatchGroupStartGameRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_matchController.JoinMatch(info, sessionID)); } /// @@ -210,9 +230,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData GetMetrics(string url, object info, string sessionID) // TODO: No type given + public string GetMetrics(string url, object info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_databaseService.GetMatch().Metrics); } /// @@ -223,9 +243,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData GetGroupStatus(string url, MatchGroupStatusRequest info, string sessionID) + public string GetGroupStatus(string url, MatchGroupStatusRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_matchController.GetGroupStatus(info)); } /// @@ -235,9 +255,10 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData DeleteGroup(string url, EmptyRequestData info, string sessionID) + public string DeleteGroup(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + _matchController.DeleteGroup(info); + return _httpResponseUtil.GetBody(true); } /// @@ -247,9 +268,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData LeaveGroup(string url, EmptyRequestData info, string sessionID) + public string LeaveGroup(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(true); } /// @@ -259,9 +280,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData RemovePlayerFromGroup(string url, MatchGroupPlayerRemoveRequest info, string sessionID) + public string RemovePlayerFromGroup(string url, MatchGroupPlayerRemoveRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(true); } /// @@ -271,9 +292,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData StartLocalRaid(string url, StartLocalRaidRequestData info, string sessionID) + public string StartLocalRaid(string url, StartLocalRaidRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_matchController.StartLocalRaid(sessionID, info)); } /// @@ -283,9 +304,10 @@ public class MatchCallbacks /// /// /// - public NullResponseData EndLocalRaid(string url, EndLocalRaidRequestData info, string sessionID) + public string EndLocalRaid(string url, EndLocalRaidRequestData info, string sessionID) { - throw new NotImplementedException(); + _matchController.EndLocalRaid(sessionID, info); + return _httpResponseUtil.NullResponse(); } /// @@ -295,9 +317,9 @@ public class MatchCallbacks /// /// /// - public NullResponseData GetRaidConfiguration(string url, GetRaidConfigurationRequestData info, string sessionID) + public string GetRaidConfiguration(string url, GetRaidConfigurationRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -307,9 +329,9 @@ public class MatchCallbacks /// /// /// - public NullResponseData GetConfigurationByProfile(string url, GetRaidConfigurationRequestData info, string sessionID) + public string GetConfigurationByProfile(string url, GetRaidConfigurationRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } /// @@ -319,9 +341,9 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData RaidReady(string url, EmptyRequestData info, string sessionID) + public string RaidReady(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(true); } /// @@ -331,8 +353,8 @@ public class MatchCallbacks /// /// /// - public GetBodyResponseData NotRaidReady(string url, EmptyRequestData info, string sessionID) + public string NotRaidReady(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(true); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/ModCallbacks.cs b/Core/Callbacks/ModCallbacks.cs index 6ed46c8d..faa1bce6 100644 --- a/Core/Callbacks/ModCallbacks.cs +++ b/Core/Callbacks/ModCallbacks.cs @@ -1,22 +1,53 @@ using Core.Annotations; using Core.DI; +using Core.Models.Enums; +using Core.Models.Spt.Config; +using Core.Servers; +using Core.Services; +using Core.Utils; +using ILogger = Core.Models.Utils.ILogger; namespace Core.Callbacks; [Injectable(TypePriority = OnLoadOrder.ModCallbacks)] public class ModCallbacks : OnLoad { - public ModCallbacks() + protected ILogger _logger; + protected HttpResponseUtil _httpResponseUtil; + protected HttpFileUtil _httpFileUtil; + // protected PostSptModLoader _postSptModLoader; TODO: needs to be implemented + protected LocalisationService _localisationService; + protected ConfigServer _configServer; + + protected HttpConfig _httpConfig; + + public ModCallbacks + ( + ILogger logger, + HttpResponseUtil httpResponseUtil, + HttpFileUtil httpFileUtil, + LocalisationService localisationService, + ConfigServer configServer + ) { + _logger = logger; + _httpResponseUtil = httpResponseUtil; + _httpFileUtil = httpFileUtil; + _localisationService = localisationService; + _configServer = configServer; + _httpConfig = configServer.GetConfig(ConfigTypes.HTTP); } public async Task OnLoad() { + // if (ProgramStatics.MODS) { + // await this.postSptModLoader.load(); + // } TODO: needs to be implemented throw new NotImplementedException(); } public string GetRoute() { - throw new NotImplementedException(); + return "spt-mods"; } } diff --git a/Core/Callbacks/NoteCallbacks.cs b/Core/Callbacks/NoteCallbacks.cs index d7315979..355272db 100644 --- a/Core/Callbacks/NoteCallbacks.cs +++ b/Core/Callbacks/NoteCallbacks.cs @@ -1,13 +1,22 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.ItemEvent; using Core.Models.Eft.Notes; namespace Core.Callbacks; +[Injectable] public class NoteCallbacks { - public NoteCallbacks() + protected NoteController _noteController; + + public NoteCallbacks + ( + NoteController noteController + ) { + _noteController = noteController; } /// @@ -20,7 +29,7 @@ public class NoteCallbacks /// public ItemEventRouterResponse AddNote(PmcData pmcData, NoteActionData info, string sessionID) { - throw new NotImplementedException(); + return _noteController.AddNote(pmcData, info, sessionID); } /// @@ -33,7 +42,7 @@ public class NoteCallbacks /// public ItemEventRouterResponse EditNote(PmcData pmcData, NoteActionData info, string sessionID) { - throw new NotImplementedException(); + return _noteController.EditNote(pmcData, info, sessionID); } /// @@ -46,6 +55,6 @@ public class NoteCallbacks /// public ItemEventRouterResponse DeleteNote(PmcData pmcData, NoteActionData info, string sessionID) { - throw new NotImplementedException(); + return _noteController.DeleteNote(pmcData, info, sessionID); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/NotifierCallbacks.cs b/Core/Callbacks/NotifierCallbacks.cs index e55012ee..b70ffc3d 100644 --- a/Core/Callbacks/NotifierCallbacks.cs +++ b/Core/Callbacks/NotifierCallbacks.cs @@ -1,14 +1,34 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Helpers; +using Core.Models.Eft.Common; using Core.Models.Eft.Common.Request; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.Notifier; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class NotifierCallbacks { - public NotifierCallbacks() + protected HttpResponseUtil _httpResponseUtil; + protected HttpServerHelper _httpServerHelper; + protected JsonUtil _jsonUtil; + protected NotifierController _notifierController; + + public NotifierCallbacks + ( + HttpResponseUtil httpResponseUtil, + HttpServerHelper httpServerHelper, + JsonUtil jsonUtil, + NotifierController notifierController + ) { + _httpResponseUtil = httpResponseUtil; + _httpServerHelper = httpServerHelper; + _jsonUtil = jsonUtil; + _notifierController = notifierController; } /** @@ -19,6 +39,14 @@ public class NotifierCallbacks */ public void SendNotification(string sessionID, object req, object resp, object data) // TODO: no types were given { + // var splitUrl = req.Url.Split("/"); + // var tmpSessionID = splitUrl[splitUrl.Length - 1].Split("?last_id")[0]; + + /** + * Take our array of JSON message objects and cast them to JSON strings, so that they can then + * be sent to client as NEWLINE separated strings... yup. + */ + // _notifierController.NotifyAsync(tmpSessionID) throw new NotImplementedException(); } @@ -32,9 +60,9 @@ public class NotifierCallbacks /// /// /// - public GetBodyResponseData> GetNotifier(string url, object info, string sessionID) // TODO: no types were given + public string GetNotifier(string url, object info, string sessionID) // TODO: no types were given { - throw new NotImplementedException(); + return _httpResponseUtil.EmptyArrayResponse(); } /// @@ -45,9 +73,9 @@ public class NotifierCallbacks /// /// /// - public GetBodyResponseData CreateNotifierChannel(string url, EmptyRequestData info, string sessionID) + public string CreateNotifierChannel(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_notifierController.GetChannel(sessionID)); } /// @@ -58,13 +86,20 @@ public class NotifierCallbacks /// /// /// - public GetBodyResponseData SelectProfile(string url, UIDRequestData info, string sessionID) + public string SelectProfile(string url, UIDRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(new SelectProfileResponse() { Status = "ok" }); } - public string Notify(string url, object info, string sessionID) // TODO: no types were given + /// + /// + /// + /// + /// + /// + /// + public string Notify(string url, object info, string sessionID) { - throw new NotImplementedException(); + return "NOTIFY"; } -} \ No newline at end of file +} diff --git a/Core/Callbacks/PresetCallbacks.cs b/Core/Callbacks/PresetCallbacks.cs index d67286ae..e8be5321 100644 --- a/Core/Callbacks/PresetCallbacks.cs +++ b/Core/Callbacks/PresetCallbacks.cs @@ -1,4 +1,5 @@ using Core.Annotations; +using Core.Controllers; using Core.DI; namespace Core.Callbacks; @@ -6,17 +7,23 @@ namespace Core.Callbacks; [Injectable(TypePriority = OnLoadOrder.PresetCallbacks)] public class PresetCallbacks : OnLoad { - public PresetCallbacks() + protected PresetController _presetController; + + public PresetCallbacks + ( + PresetController presetController + ) { + _presetController = presetController; } public async Task OnLoad() { - throw new NotImplementedException(); + _presetController.Initialize(); } public string GetRoute() { - throw new NotImplementedException(); + return "spt-presets"; } } diff --git a/Core/Callbacks/PrestigeCallbacks.cs b/Core/Callbacks/PrestigeCallbacks.cs index c1a3de91..94c9225c 100644 --- a/Core/Callbacks/PrestigeCallbacks.cs +++ b/Core/Callbacks/PrestigeCallbacks.cs @@ -1,13 +1,30 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Helpers; +using Core.Models.Eft.Common; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.HttpResponse; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class PrestigeCallbacks { - public PrestigeCallbacks() + protected HttpServerHelper _httpServerHelper; + protected HttpResponseUtil _httpResponseUtil; + protected PrestigeController _prestigeController; + + public PrestigeCallbacks + ( + HttpServerHelper httpServerHelper, + HttpResponseUtil httpResponseUtil, + PrestigeController prestigeController + ) { + _httpServerHelper = httpServerHelper; + _httpResponseUtil = httpResponseUtil; + _prestigeController = prestigeController; } /// @@ -18,9 +35,9 @@ public class PrestigeCallbacks /// /// /// - public GetBodyResponseData GetPrestige(string url, EmptyRequestData info, string sessionID) + public string GetPrestige(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_prestigeController.GetPrestige(sessionID, info)); } /// @@ -31,8 +48,8 @@ public class PrestigeCallbacks /// /// /// - public GetBodyResponseData ObtainPrestige(string url, EmptyRequestData info, string sessionID) + public string ObtainPrestige(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_prestigeController.ObtainPrestige(sessionID, info)); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/ProfileCallbacks.cs b/Core/Callbacks/ProfileCallbacks.cs index 4bc861b6..5ba8a45c 100644 --- a/Core/Callbacks/ProfileCallbacks.cs +++ b/Core/Callbacks/ProfileCallbacks.cs @@ -12,22 +12,22 @@ namespace Core.Callbacks; public class ProfileCallbacks { protected HttpResponseUtil _httpResponse; - protected TimeUtil _timeUtil; - protected ProfileController _profileController; - protected ProfileHelper _profileHelper; + protected TimeUtil _timeUtil; + protected ProfileController _profileController; + protected ProfileHelper _profileHelper; - public ProfileCallbacks( - HttpResponseUtil httpResponse, - TimeUtil timeUtil, - ProfileController profileController, - ProfileHelper profileHelper - ) - { - _httpResponse = httpResponse; - _timeUtil = timeUtil; - _profileController = profileController; - _profileHelper = profileHelper; - } + public ProfileCallbacks( + HttpResponseUtil httpResponse, + TimeUtil timeUtil, + ProfileController profileController, + ProfileHelper profileHelper + ) + { + _httpResponse = httpResponse; + _timeUtil = timeUtil; + _profileController = profileController; + _profileHelper = profileHelper; + } /** * Handle client/game/profile/create @@ -35,7 +35,7 @@ public class ProfileCallbacks public string CreateProfile(string url, ProfileCreateRequestData info, string sessionID) { var id = _profileController.CreateProfile(info, sessionID); - return _httpResponse.GetBody(new CreateProfileResponse(){ UserId = id }); + return _httpResponse.GetBody(new CreateProfileResponse() { UserId = id }); } /** @@ -56,7 +56,8 @@ public class ProfileCallbacks * @param sessionID Session id * @returns Profile object */ - public string RegenerateScav(string url, EmptyRequestData info, string sessionID) { + public string RegenerateScav(string url, EmptyRequestData info, string sessionID) + { return _httpResponse.GetBody(new List() { _profileController.GeneratePlayerScav(sessionID) }); } @@ -77,11 +78,13 @@ public class ProfileCallbacks { var output = _profileController.ChangeNickname(info, sessionID); - if (output == "taken") { + if (output == "taken") + { return _httpResponse.GetBody(null, 255, "The nickname is already in use"); } - if (output == "tooshort") { + if (output == "tooshort") + { return _httpResponse.GetBody(null, 1, "The nickname is too short"); } @@ -95,11 +98,13 @@ public class ProfileCallbacks { var output = _profileController.ValidateNickname(info, sessionID); - if (output == "taken") { + if (output == "taken") + { return _httpResponse.GetBody(null, 255, "225 - "); } - if (output == "tooshort") { + if (output == "tooshort") + { return _httpResponse.GetBody(null, 256, "256 - "); } diff --git a/Core/Callbacks/QuestCallbacks.cs b/Core/Callbacks/QuestCallbacks.cs index cab18064..c44293f1 100644 --- a/Core/Callbacks/QuestCallbacks.cs +++ b/Core/Callbacks/QuestCallbacks.cs @@ -1,15 +1,31 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.ItemEvent; using Core.Models.Eft.Quests; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class QuestCallbacks { - public QuestCallbacks() + protected HttpResponseUtil _httpResponseUtil; + protected QuestController _questController; + protected RepeatableQuestController _repeatableQuestController; + + public QuestCallbacks + ( + HttpResponseUtil httpResponseUtil, + QuestController questController, + RepeatableQuestController repeatableQuestController + ) { + _httpResponseUtil = httpResponseUtil; + _questController = questController; + _repeatableQuestController = repeatableQuestController; } /// @@ -22,7 +38,7 @@ public class QuestCallbacks /// public ItemEventRouterResponse ChangeRepeatableQuest(PmcData pmcData, RepeatableQuestChangeRequest info, string sessionID) { - throw new NotImplementedException(); + return _repeatableQuestController.ChangeRepeatableQuest(pmcData, info, sessionID); } /// @@ -35,7 +51,10 @@ public class QuestCallbacks /// public ItemEventRouterResponse AcceptQuest(PmcData pmcData, AcceptQuestRequestData info, string sessionID) { - throw new NotImplementedException(); + if (info.Type == "repeatable") + return _questController.AcceptRepeatableQuest(pmcData, info, sessionID); + + return _questController.AcceptQuest(pmcData, info, sessionID); } /// @@ -48,7 +67,7 @@ public class QuestCallbacks /// public ItemEventRouterResponse CompleteQuest(PmcData pmcData, CompleteQuestRequestData info, string sessionID) { - throw new NotImplementedException(); + return _questController.CompleteQuest(pmcData, info, sessionID); } /// @@ -61,7 +80,7 @@ public class QuestCallbacks /// public ItemEventRouterResponse HandoverQuest(PmcData pmcData, HandoverQuestRequestData info, string sessionID) { - throw new NotImplementedException(); + return _questController.HandoverQuest(pmcData, info, sessionID); } /// @@ -72,9 +91,9 @@ public class QuestCallbacks /// /// /// - public GetBodyResponseData> ListQuests(string url, ListQuestsRequestData info, string sessionID) + public string ListQuests(string url, ListQuestsRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_questController.GetClientQuest(sessionID)); } /// @@ -85,8 +104,8 @@ public class QuestCallbacks /// /// /// - public GetBodyResponseData> ActivityPeriods(string url, EmptyRequestData info, string sessionID) + public string ActivityPeriods(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_repeatableQuestController.GetClientRepeatableQuests(sessionID)); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/RagfairCallbacks.cs b/Core/Callbacks/RagfairCallbacks.cs index bd3cd41a..22c8f0f8 100644 --- a/Core/Callbacks/RagfairCallbacks.cs +++ b/Core/Callbacks/RagfairCallbacks.cs @@ -1,34 +1,72 @@ using Core.Annotations; +using Core.Controllers; using Core.DI; using Core.Models.Eft.Common; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.ItemEvent; using Core.Models.Eft.Ragfair; +using Core.Models.Enums; using Core.Models.Spt.Config; +using Core.Servers; +using Core.Services; +using Core.Utils; namespace Core.Callbacks; [Injectable(TypePriority = OnLoadOrder.RagfairCallbacks)] public class RagfairCallbacks : OnLoad, OnUpdate { + protected HttpResponseUtil _httpResponseUtil; + // protected RagfairServer _ragfairServer; + protected RagfairController _ragfairController; + protected RagfairTaxService _ragfairTaxService; + protected ConfigServer _configServer; + private RagfairConfig _ragfairConfig; - public RagfairCallbacks() + public RagfairCallbacks + ( + HttpResponseUtil httpResponseUtil, + // RagfairServer ragfairServer, + RagfairController ragfairController, + RagfairTaxService ragfairTaxService, + ConfigServer configServer + ) { + _httpResponseUtil = httpResponseUtil; + // _ragfairServer = ragfairServer; + _ragfairController = ragfairController; + _ragfairTaxService = ragfairTaxService; + _configServer = configServer; + _ragfairConfig = _configServer.GetConfig(ConfigTypes.RAGFAIR); } public async Task OnLoad() { - throw new NotImplementedException(); + // await _ragfairServer.Load(); + // TODO: implement RagfairServer } public string GetRoute() { - throw new NotImplementedException(); + return "spt-ragfair"; } public async Task OnUpdate(long timeSinceLastRun) { + // if (timeSinceLastRun > this.ragfairConfig.runIntervalSeconds) { + // // There is a flag inside this class that only makes it run once. + // this.ragfairServer.addPlayerOffers(); + // + // // Check player offers and mail payment to player if sold + // this.ragfairController.update(); + // + // // Process all offers / expire offers + // await this.ragfairServer.update(); + // + // return true; + // } + // return false; throw new NotImplementedException(); } @@ -40,10 +78,9 @@ public class RagfairCallbacks : OnLoad, OnUpdate /// /// /// - /// - public GetBodyResponseData Search(string url, SearchRequestData info, string sessionID) + public string Search(string url, SearchRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_ragfairController.GetOffers(sessionID, info)); } /// @@ -53,49 +90,45 @@ public class RagfairCallbacks : OnLoad, OnUpdate /// /// /// - /// - public GetBodyResponseData GetMarketPrice(string url, GetMarketPriceRequestData info, string sessionID) + public string GetMarketPrice(string url, GetMarketPriceRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_ragfairController.GetItemMinAvgMaxFleaPriceValues(info)); } /// /// Handle RagFairAddOffer event /// - /// + /// /// /// /// - /// - public ItemEventRouterResponse AddOffer(string url, AddOfferRequestData info, string sessionID) + public ItemEventRouterResponse AddOffer(PmcData pmcData, AddOfferRequestData info, string sessionID) { - throw new NotImplementedException(); + return _ragfairController.AddPlayerOffer(pmcData, info, sessionID); } /// /// Handle RagFairRemoveOffer event /// - /// + /// /// /// /// - /// - public ItemEventRouterResponse RemoveOffer(string url, RemoveOfferRequestData info, string sessionID) + public ItemEventRouterResponse RemoveOffer(PmcData pmcData, RemoveOfferRequestData info, string sessionID) { - throw new NotImplementedException(); + return _ragfairController.RemoveOffer(pmcData, info, sessionID); } /// /// Handle RagFairRenewOffer event /// - /// + /// /// /// /// - /// - public ItemEventRouterResponse ExtendOffer(string url, ExtendOfferRequestData info, string sessionID) + public ItemEventRouterResponse ExtendOffer(PmcData pmcData, ExtendOfferRequestData info, string sessionID) { - throw new NotImplementedException(); + return _ragfairController.ExtendOffer(pmcData, info, sessionID); } /// @@ -106,10 +139,9 @@ public class RagfairCallbacks : OnLoad, OnUpdate /// /// /// - /// - public GetBodyResponseData> GetFleaPrices(string url, EmptyRequestData info, string sessionID) + public string GetFleaPrices(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_ragfairController.GetAllFleaPrices()); } /// @@ -119,15 +151,15 @@ public class RagfairCallbacks : OnLoad, OnUpdate /// /// /// - /// - public NullResponseData SendReport(string url, SendRagfairReportRequestData info, string sessionID) + public string SendReport(string url, SendRagfairReportRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.NullResponse(); } - public NullResponseData StorePlayerOfferTaxAmount(string url, StorePlayerOfferTaxAmountRequestData info, string sessionID) + public string StorePlayerOfferTaxAmount(string url, StorePlayerOfferTaxAmountRequestData info, string sessionID) { - throw new NotImplementedException(); + _ragfairTaxService.StoreClientOfferTaxValue(sessionID, info); + return _httpResponseUtil.NullResponse(); } /// @@ -137,9 +169,8 @@ public class RagfairCallbacks : OnLoad, OnUpdate /// /// /// - /// - public GetBodyResponseData GetFleaOfferById(string url, GetRagfairOfferByIdRequest info, string sessionID) + public string GetFleaOfferById(string url, GetRagfairOfferByIdRequest info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_ragfairController.GetOfferById(sessionID, info)); } } diff --git a/Core/Callbacks/RepairCallbacks.cs b/Core/Callbacks/RepairCallbacks.cs index bc692a05..b90a501a 100644 --- a/Core/Callbacks/RepairCallbacks.cs +++ b/Core/Callbacks/RepairCallbacks.cs @@ -1,13 +1,22 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.ItemEvent; using Core.Models.Eft.Repair; namespace Core.Callbacks; +[Injectable] public class RepairCallbacks { - public RepairCallbacks() + protected RepairController _repairController; + + public RepairCallbacks + ( + RepairController repairController + ) { + _repairController = repairController; } /// @@ -18,10 +27,9 @@ public class RepairCallbacks /// /// /// - /// public ItemEventRouterResponse TraderRepair(PmcData pmcData, TraderRepairActionDataRequest info, string sessionID) { - throw new NotImplementedException(); + return _repairController.TraderRepair(sessionID, info, pmcData); } /// @@ -32,9 +40,8 @@ public class RepairCallbacks /// /// /// - /// public ItemEventRouterResponse Repair(PmcData pmcData, RepairActionDataRequest info, string sessionID) { - throw new NotImplementedException(); + return _repairController.RepairWithKit(sessionID, info, pmcData); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/TradeCallbacks.cs b/Core/Callbacks/TradeCallbacks.cs index 1121bcbd..9bbaf4e0 100644 --- a/Core/Callbacks/TradeCallbacks.cs +++ b/Core/Callbacks/TradeCallbacks.cs @@ -1,13 +1,22 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.ItemEvent; using Core.Models.Eft.Trade; namespace Core.Callbacks; +[Injectable] public class TradeCallbacks { - public TradeCallbacks() + protected TradeController _tradeController; + + public TradeCallbacks + ( + TradeController tradeController + ) { + _tradeController = tradeController; } /// @@ -17,10 +26,9 @@ public class TradeCallbacks /// /// /// - /// public ItemEventRouterResponse ProcessTrade(PmcData pmcData, ProcessBaseTradeRequestData info, string sessionID) { - throw new NotImplementedException(); + return _tradeController.ConfirmTrading(pmcData, info, sessionID); } /// @@ -30,10 +38,9 @@ public class TradeCallbacks /// /// /// - /// public ItemEventRouterResponse ProcessRagfairTrade(PmcData pmcData, ProcessRagfairTradeRequestData info, string sessionID) { - throw new NotImplementedException(); + return _tradeController.ConfirmRagfairTrading(pmcData, info, sessionID); } /// @@ -43,9 +50,8 @@ public class TradeCallbacks /// /// /// - /// public ItemEventRouterResponse SellAllFromSavage(PmcData pmcData, SellScavItemsToFenceRequestData info, string sessionID) { - throw new NotImplementedException(); + return _tradeController.SellScavItemsToFence(pmcData, info, sessionID); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/TraderCallbacks.cs b/Core/Callbacks/TraderCallbacks.cs index 2e13b2ec..928c9262 100644 --- a/Core/Callbacks/TraderCallbacks.cs +++ b/Core/Callbacks/TraderCallbacks.cs @@ -1,32 +1,48 @@ using Core.Annotations; +using Core.Controllers; using Core.DI; using Core.Models.Eft.Common; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.HttpResponse; +using Core.Models.Enums; using Core.Models.Spt.Config; +using Core.Servers; +using Core.Utils; namespace Core.Callbacks; [Injectable(TypePriority = OnLoadOrder.TraderCallbacks)] public class TraderCallbacks : OnLoad, OnUpdate { - public TraderCallbacks() + protected HttpResponseUtil _httpResponseUtil; + protected TraderController _traderController; + protected ConfigServer _configServer; + + public TraderCallbacks + ( + HttpResponseUtil httpResponseUtil, + TraderController traderController, + ConfigServer configServer + ) { + _httpResponseUtil = httpResponseUtil; + _traderController = traderController; + _configServer = configServer; } public async Task OnLoad() { - throw new NotImplementedException(); + _traderController.Load(); } public async Task OnUpdate(long _) { - throw new NotImplementedException(); + return _traderController.Update(); } public string GetRoute() { - throw new NotImplementedException(); + return "spt-traders"; } /// @@ -36,10 +52,9 @@ public class TraderCallbacks : OnLoad, OnUpdate /// /// /// - /// - public GetBodyResponseData> GetTraderSettings(string url, EmptyRequestData info, string sessionID) + public string GetTraderSettings(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_traderController.GetAllTraders(sessionID)); } /// @@ -49,10 +64,10 @@ public class TraderCallbacks : OnLoad, OnUpdate /// /// /// - /// - public GetBodyResponseData GetTrader(string url, EmptyRequestData info, string sessionID) + public string GetTrader(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var traderID = url.Replace("/client/trading/api/getTrader/", ""); + return _httpResponseUtil.GetBody(_traderController.GetTrader(sessionID, traderID)); } /// @@ -62,10 +77,10 @@ public class TraderCallbacks : OnLoad, OnUpdate /// /// /// - /// - public GetBodyResponseData GetAssort(string url, EmptyRequestData info, string sessionID) + public string GetAssort(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var traderID = url.Replace("/client/trading/api/getTraderAssort/", ""); + return _httpResponseUtil.GetBody(_traderController.GetAssort(sessionID, traderID)); } /// @@ -75,9 +90,9 @@ public class TraderCallbacks : OnLoad, OnUpdate /// /// /// - /// - public GetBodyResponseData GetModdedTraderData(string url, EmptyRequestData info, string sessionID) + public string GetModdedTraderData(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + var traderConfig = _configServer.GetConfig(ConfigTypes.TRADER); + return _httpResponseUtil.NoBody(traderConfig.ModdedTraders); } } diff --git a/Core/Callbacks/WeatherCallbacks.cs b/Core/Callbacks/WeatherCallbacks.cs index 2b3957c3..e118e51f 100644 --- a/Core/Callbacks/WeatherCallbacks.cs +++ b/Core/Callbacks/WeatherCallbacks.cs @@ -1,14 +1,27 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.HttpResponse; using Core.Models.Eft.Weather; using Core.Models.Spt.Weather; +using Core.Utils; namespace Core.Callbacks; +[Injectable] public class WeatherCallbacks { - public WeatherCallbacks() + protected HttpResponseUtil _httpResponseUtil; + protected WeatherController _weatherController; + + public WeatherCallbacks + ( + HttpResponseUtil httpResponseUtil, + WeatherController weatherController + ) { + _httpResponseUtil = httpResponseUtil; + _weatherController = weatherController; } /// @@ -18,10 +31,9 @@ public class WeatherCallbacks /// /// /// - /// - public GetBodyResponseData GetWeather(string url, EmptyRequestData info, string sessionID) + public string GetWeather(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_weatherController.Generate()); } /// @@ -31,9 +43,8 @@ public class WeatherCallbacks /// /// /// - /// - public GetBodyResponseData GetLocalWeather(string url, EmptyRequestData info, string sessionID) + public string GetLocalWeather(string url, EmptyRequestData info, string sessionID) { - throw new NotImplementedException(); + return _httpResponseUtil.GetBody(_weatherController.GenerateLocal(sessionID)); } -} \ No newline at end of file +} diff --git a/Core/Callbacks/WishlistCallbacks.cs b/Core/Callbacks/WishlistCallbacks.cs index 0a314ede..4af8d259 100644 --- a/Core/Callbacks/WishlistCallbacks.cs +++ b/Core/Callbacks/WishlistCallbacks.cs @@ -1,13 +1,22 @@ -using Core.Models.Eft.Common; +using Core.Annotations; +using Core.Controllers; +using Core.Models.Eft.Common; using Core.Models.Eft.ItemEvent; using Core.Models.Eft.Wishlist; namespace Core.Callbacks; +[Injectable] public class WishlistCallbacks { - public WishlistCallbacks() + protected WishlistController _wishlistController; + + public WishlistCallbacks + ( + WishlistController wishlistController + ) { + _wishlistController = wishlistController; } /// @@ -17,10 +26,9 @@ public class WishlistCallbacks /// /// /// - /// public ItemEventRouterResponse AddToWishlist(PmcData pmcData, AddToWishlistRequest info, string sessionID) { - throw new NotImplementedException(); + return _wishlistController.AddToWishList(pmcData, info, sessionID); } /// @@ -30,10 +38,9 @@ public class WishlistCallbacks /// /// /// - /// public ItemEventRouterResponse RemoveFromWishlist(PmcData pmcData, RemoveFromWishlistRequest info, string sessionID) { - throw new NotImplementedException(); + return _wishlistController.RemoveFromWishList(pmcData, info, sessionID); } /// @@ -43,9 +50,8 @@ public class WishlistCallbacks /// /// /// - /// public ItemEventRouterResponse ChangeWishlistItemCategory(PmcData pmcData, ChangeWishlistItemCategoryRequest info, string sessionID) { - throw new NotImplementedException(); + return _wishlistController.ChangeWishListItemCategory(pmcData, info, sessionID); } -} \ No newline at end of file +} diff --git a/Core/Controllers/AchievementController.cs b/Core/Controllers/AchievementController.cs index 433e2c31..7db73a05 100644 --- a/Core/Controllers/AchievementController.cs +++ b/Core/Controllers/AchievementController.cs @@ -1,20 +1,46 @@ -using Core.Models.Eft.Profile; +using Core.Annotations; +using Core.Models.Eft.Profile; +using Core.Services; namespace Core.Controllers; +[Injectable] public class AchievementController { - public AchievementController() + protected Core.Models.Utils.ILogger _logger; + protected DatabaseService _databaseService; + + public AchievementController + ( + Core.Models.Utils.ILogger logger, + DatabaseService databaseService + ) { + _logger = logger; + _databaseService = databaseService; } public GetAchievementsResponse GetAchievements(string sessionID) { - throw new NotImplementedException(); + return new() + { + Achievements = _databaseService.GetAchievements() + }; } public CompletedAchievementsResponse GetAchievementStatics(string sessionID) { - throw new NotImplementedException(); + var achievements = _databaseService.GetAchievements(); + var stats = new Dictionary(); + + foreach (var achievement in achievements) + { + stats.Add(achievement.Id, 0); + } + + return new() + { + Elements = stats + }; } -} \ No newline at end of file +} diff --git a/Core/Controllers/BotController.cs b/Core/Controllers/BotController.cs index ab46030c..7e9b37c8 100644 --- a/Core/Controllers/BotController.cs +++ b/Core/Controllers/BotController.cs @@ -1,44 +1,131 @@ -using Core.Models.Common; +using Core.Context; +using Core.Generators; +using Core.Helpers; +using Core.Models.Common; using Core.Models.Eft.Bot; using Core.Models.Eft.Common; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.Match; +using Core.Models.Enums; using Core.Models.Spt.Bots; using Core.Models.Spt.Config; +using Core.Servers; +using Core.Services; +using Core.Utils; +using Core.Utils.Cloners; using Condition = Core.Models.Spt.Config.Condition; +using ILogger = Core.Models.Utils.ILogger; namespace Core.Controllers; public class BotController { - private BotConfig _botConfig; - private PmcConfig _pmcConfig; + protected ILogger _logger; - public BotController() + protected DatabaseService _databaseService; + protected BotGenerator _botGenerator; + protected BotHelper _botHelper; + protected BotDifficultyHelper _botDifficultyHelper; + protected WeightedRandomHelper _weightedRandomHelper; + protected BotGenerationCacheService _botGenerationCacheService; + protected MatchBotDeatilsCacheService _matchBotDeatilsCacheService; + protected LocalisationService _localisationService; + protected SeasonalEventService _seasonalEventService; + protected ProfileHelper _profileHelper; + protected ConfigServer _configServer; + protected ApplicationContext _applicationContext; + protected RandomUtil _randomUtil; + protected ICloner _cloner; + + protected BotConfig _botConfig; + protected PmcConfig _pmcConfig; + + public BotController + ( + ILogger logger, + DatabaseService databaseService, + BotGenerator botGenerator, + BotHelper botHelper, + BotDifficultyHelper botDifficultyHelper, + WeightedRandomHelper weightedRandomHelper, + BotGenerationCacheService botGenerationCacheService, + MatchBotDeatilsCacheService matchBotDeatilsCacheService, + LocalisationService localisationService, + SeasonalEventService seasonalEventService, + ProfileHelper profileHelper, + ConfigServer configServer, + ApplicationContext applicationContext, + RandomUtil randomUtil, + ICloner cloner + ) { + _logger = logger; + _databaseService = databaseService; + _botGenerator = botGenerator; + _botHelper = botHelper; + _botDifficultyHelper = botDifficultyHelper; + _weightedRandomHelper = weightedRandomHelper; + _botGenerationCacheService = botGenerationCacheService; + _matchBotDeatilsCacheService = matchBotDeatilsCacheService; + _localisationService = localisationService; + _seasonalEventService = seasonalEventService; + _profileHelper = profileHelper; + _configServer = configServer; + _applicationContext = applicationContext; + _randomUtil = randomUtil; + _cloner = cloner; + _botConfig = _configServer.GetConfig(ConfigTypes.BOT); + _pmcConfig = _configServer.GetConfig(ConfigTypes.PMC); } public int GetBotPresetGenerationLimit(string type) { - throw new NotImplementedException(); + var typeInLower = type.ToLower(); + var value = (int)typeof(PresetBatch).GetProperties().First(p => p.Name.ToLower() == (typeInLower == "assaultgroup" ? "assault" : typeInLower)) + .GetValue(_botConfig.PresetBatch); + + if (value == null) + { + _logger.Warning(_localisationService.GetText("bot-bot_preset_count_value_missing", type)); + return 30; + } + + return value; } public Dictionary GetBotCoreDifficulty() { - throw new NotImplementedException(); + return _databaseService.GetBots().Core; } - public object GetBotDifficulty(string type, string difficulty) // TODO: return type was: IBotCore | IDifficultyCategories + public DifficultyCategories GetBotDifficulty(string type, string diffLevel, GetRaidConfigurationRequestData raidConfig, bool ignoreRaidSettings = false) { - throw new NotImplementedException(); + var difficulty = diffLevel.ToLower(); + + if (!(raidConfig != null || ignoreRaidSettings)) // TODD: this might be wrong logic + _logger.Error(_localisationService.GetText("bot-missing_application_context", "RAID_CONFIGURATION")); + + // Check value chosen in pre-raid difficulty dropdown + // If value is not 'asonline', change requested difficulty to be what was chosen in dropdown + var botDifficultyDropDownValue = raidConfig?.WavesSettings?.BotDifficulty?.ToString().ToLower() ?? "asonline"; + if (botDifficultyDropDownValue != "asonline") + difficulty = _botDifficultyHelper.ConvertBotDifficultyDropdownToBotDifficulty(botDifficultyDropDownValue); + + var botDb = _databaseService.GetBots(); + return _botDifficultyHelper.GetBotDifficultySettings(type, difficulty, botDb); } public Dictionary GetAllBotDifficulties() { - throw new NotImplementedException(); + var result = new Dictionary(); + + var botTypesDb = _databaseService.GetBots().Types; + // TODO: Come back to this, brainfuck + + return result; } - public async Task> Generate(GenerateBotsRequestData info, bool playerscav) + public List Generate(string sessionId, GenerateBotsRequestData info) { throw new NotImplementedException(); } @@ -90,7 +177,7 @@ public class BotController throw new NotImplementedException(); } - public int GetBotCap() + public int GetBotCap(string location) { throw new NotImplementedException(); } @@ -99,4 +186,4 @@ public class BotController { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/Core/Controllers/DialogueController.cs b/Core/Controllers/DialogueController.cs index 989b05ea..30300082 100644 --- a/Core/Controllers/DialogueController.cs +++ b/Core/Controllers/DialogueController.cs @@ -1,4 +1,5 @@ using Core.Models.Eft.Dialog; +using Core.Models.Eft.HttpResponse; using Core.Models.Eft.Profile; using Core.Models.Enums; @@ -85,7 +86,7 @@ public class DialogueController /// Session id /// GetMailDialogViewResponseData object public GetMailDialogViewResponseData GenerateDialogueView( - GetMailDialogViewResponseData request, + GetMailDialogViewRequestData request, string sessionId) { throw new NotImplementedException(); @@ -174,7 +175,7 @@ public class DialogueController /// Dialog ids to set as read /// Player profile id public void SetRead( - HashSet dialogueIds, + List dialogueIds, string sessionId) { throw new NotImplementedException(); @@ -250,4 +251,14 @@ public class DialogueController { throw new NotImplementedException(); } -} \ No newline at end of file + + public FriendRequestSendResponse SendFriendRequest(string sessionId, FriendRequestData request) + { + throw new NotImplementedException(); + } + + public void DeleteFriend(string sessionID, DeleteFriendRequest request) + { + throw new NotImplementedException(); + } +} diff --git a/Core/Controllers/GameController.cs b/Core/Controllers/GameController.cs index 622df961..4a4aa0a9 100644 --- a/Core/Controllers/GameController.cs +++ b/Core/Controllers/GameController.cs @@ -48,7 +48,7 @@ public class GameController /// /// /// - public object GetGameMode( // TODO: Returns `any` in node server + public GameModeResponse GetGameMode( string sessionId, GameModeRequestData requestData) { @@ -70,12 +70,12 @@ public class GameController /// /// /// - /* + public CurrentGroupResponse GetCurrentGroup(string sessionId) { throw new NotImplementedException(); } - */ + /// /// Handle client/checkVersion @@ -182,4 +182,9 @@ public class GameController { throw new NotImplementedException(); } -} \ No newline at end of file + + public void Load() + { + throw new NotImplementedException(); + } +} diff --git a/Core/Controllers/InRaidController.cs b/Core/Controllers/InRaidController.cs index 0431fec7..8aff9cbc 100644 --- a/Core/Controllers/InRaidController.cs +++ b/Core/Controllers/InRaidController.cs @@ -1,9 +1,46 @@ +using Core.Context; +using Core.Helpers; using Core.Models.Eft.InRaid; +using Core.Models.Enums; +using Core.Models.Spt.Config; +using Core.Servers; +using Core.Services; +using ILogger = Core.Models.Utils.ILogger; namespace Core.Controllers; public class InRaidController { + protected ILogger _logger; + protected SaveServer _saveServer; + protected ProfileHelper _profileHelper; + protected LocalisationService _localisationService; + protected ApplicationContext _applicationContext; + protected ConfigServer _configServer; + + protected InRaidConfig _inRaidConfig; + protected BotConfig _botConfig; + + public InRaidController + ( + ILogger logger, + SaveServer saveServer, + ProfileHelper profileHelper, + LocalisationService localisationService, + ApplicationContext applicationContext, + ConfigServer configServer + ) + { + _logger = logger; + _saveServer = saveServer; + _profileHelper = profileHelper; + _localisationService = localisationService; + _applicationContext = applicationContext; + _configServer = configServer; + _inRaidConfig = configServer.GetConfig(ConfigTypes.IN_RAID); + _botConfig = configServer.GetConfig(ConfigTypes.BOT); + } + /// /// Save locationId to active profiles in-raid object AND app context /// @@ -33,9 +70,9 @@ public class InRaidController /// /// Get the inraid config from configs/inraid.json /// - public void GetInRaidConfig() + public InRaidConfig GetInRaidConfig() { - throw new NotImplementedException(); + return _inRaidConfig; } /// @@ -63,4 +100,4 @@ public class InRaidController { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/Core/Controllers/MatchController.cs b/Core/Controllers/MatchController.cs index 14b27307..742bda61 100644 --- a/Core/Controllers/MatchController.cs +++ b/Core/Controllers/MatchController.cs @@ -93,4 +93,4 @@ public class MatchController { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/Core/Controllers/QuestController.cs b/Core/Controllers/QuestController.cs index 4a67e92e..45eaf1ba 100644 --- a/Core/Controllers/QuestController.cs +++ b/Core/Controllers/QuestController.cs @@ -1,6 +1,35 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Common.Tables; +using Core.Models.Eft.ItemEvent; +using Core.Models.Eft.Quests; + namespace Core.Controllers; public class QuestController { // TODO -} \ No newline at end of file + public ItemEventRouterResponse CompleteQuest(PmcData pmcData, CompleteQuestRequestData info, string sessionId) + { + throw new NotImplementedException(); + } + + public ItemEventRouterResponse AcceptRepeatableQuest(PmcData pmcData, AcceptQuestRequestData info, string sessionId) + { + throw new NotImplementedException(); + } + + public ItemEventRouterResponse AcceptQuest(PmcData pmcData, AcceptQuestRequestData info, string sessionId) + { + throw new NotImplementedException(); + } + + public ItemEventRouterResponse HandoverQuest(PmcData pmcData, HandoverQuestRequestData info, string sessionId) + { + throw new NotImplementedException(); + } + + public List GetClientQuest(string sessionId) + { + throw new NotImplementedException(); + } +} diff --git a/Core/Controllers/RagfairController.cs b/Core/Controllers/RagfairController.cs index 829e44d6..fcdbb31f 100644 --- a/Core/Controllers/RagfairController.cs +++ b/Core/Controllers/RagfairController.cs @@ -1,6 +1,44 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.ItemEvent; +using Core.Models.Eft.Ragfair; + namespace Core.Controllers; public class RagfairController { // TODO -} \ No newline at end of file + public GetOffersResult GetOffers(string sessionId, SearchRequestData info) + { + throw new NotImplementedException(); + } + + public GetItemPriceResult GetItemMinAvgMaxFleaPriceValues(GetMarketPriceRequestData info) + { + throw new NotImplementedException(); + } + + public ItemEventRouterResponse AddPlayerOffer(PmcData pmcData, AddOfferRequestData info, string sessionId) + { + throw new NotImplementedException(); + } + + public ItemEventRouterResponse RemoveOffer(PmcData pmcData, RemoveOfferRequestData info, string sessionId) + { + throw new NotImplementedException(); + } + + public ItemEventRouterResponse ExtendOffer(PmcData pmcData, ExtendOfferRequestData info, string sessionId) + { + throw new NotImplementedException(); + } + + public Dictionary GetAllFleaPrices() + { + throw new NotImplementedException(); + } + + public RagfairOffer GetOfferById(string sessionId, GetRagfairOfferByIdRequest info) + { + throw new NotImplementedException(); + } +} diff --git a/Core/Controllers/RepeatableQuestController.cs b/Core/Controllers/RepeatableQuestController.cs index b2c19e66..1cb9012b 100644 --- a/Core/Controllers/RepeatableQuestController.cs +++ b/Core/Controllers/RepeatableQuestController.cs @@ -1,6 +1,20 @@ +using Core.Models.Eft.Common; +using Core.Models.Eft.Common.Tables; +using Core.Models.Eft.ItemEvent; +using Core.Models.Eft.Quests; + namespace Core.Controllers; public class RepeatableQuestController { // TODO -} \ No newline at end of file + public ItemEventRouterResponse ChangeRepeatableQuest(PmcData pmcData, RepeatableQuestChangeRequest info, string sessionId) + { + throw new NotImplementedException(); + } + + public List GetClientRepeatableQuests(string sessionId) + { + throw new NotImplementedException(); + } +} diff --git a/Core/Controllers/TraderController.cs b/Core/Controllers/TraderController.cs index 201f2595..77316bae 100644 --- a/Core/Controllers/TraderController.cs +++ b/Core/Controllers/TraderController.cs @@ -79,8 +79,8 @@ public class TraderController /// Handle client/items/prices/TRADERID /// /// - public GetItemPricesResponse GetItemPrices() + public GetItemPricesResponse GetItemPrices(string sessionId, string traderId) { throw new NotImplementedException(); } -} \ No newline at end of file +} diff --git a/Core/Models/Eft/Dialog/GetAllAttachmentsRequestData.cs b/Core/Models/Eft/Dialog/GetAllAttachmentsRequestData.cs new file mode 100644 index 00000000..49db448c --- /dev/null +++ b/Core/Models/Eft/Dialog/GetAllAttachmentsRequestData.cs @@ -0,0 +1,9 @@ +using System.Text.Json.Serialization; + +namespace Core.Models.Eft.Dialog; + +public class GetAllAttachmentsRequestData +{ + [JsonPropertyName("dialogId")] + public string DialogId { get; set; } +} diff --git a/Core/Models/Eft/Dialog/SetDialogReadRequestData.cs b/Core/Models/Eft/Dialog/SetDialogReadRequestData.cs index 4e235250..1498158b 100644 --- a/Core/Models/Eft/Dialog/SetDialogReadRequestData.cs +++ b/Core/Models/Eft/Dialog/SetDialogReadRequestData.cs @@ -5,5 +5,5 @@ namespace Core.Models.Eft.Dialog; public class SetDialogReadRequestData { [JsonPropertyName("dialogId")] - public List? DialogId { get; set; } -} \ No newline at end of file + public List? Dialogs { get; set; } +} diff --git a/Core/Services/RagfairTaxService.cs b/Core/Services/RagfairTaxService.cs index 9c54e7db..aac05256 100644 --- a/Core/Services/RagfairTaxService.cs +++ b/Core/Services/RagfairTaxService.cs @@ -1,8 +1,10 @@ -namespace Core.Services; +using Core.Models.Eft.Ragfair; + +namespace Core.Services; public class RagfairTaxService { - public void StoreClientOfferTaxValue(string sessionId, Dictionary offer) + public void StoreClientOfferTaxValue(string sessionId, StorePlayerOfferTaxAmountRequestData offer) { throw new NotImplementedException(); }