diff --git a/Libraries/Core/Controllers/BotController.cs b/Libraries/Core/Controllers/BotController.cs index dae9d175..9ffdbc12 100644 --- a/Libraries/Core/Controllers/BotController.cs +++ b/Libraries/Core/Controllers/BotController.cs @@ -279,7 +279,7 @@ public class BotController( pmcProfile, false, raidSettings, - _botConfig.PresetBatch?.GetByJsonProp(requestedBot?.Role ?? string.Empty), + _botConfig.PresetBatch.GetValueOrDefault(requestedBot?.Role, 5), _botHelper.IsBotPmc(requestedBot?.Role) ); @@ -310,7 +310,7 @@ public class BotController( botGenerationDetails.Role = _botHelper.GetRandomizedPmcRole(); botGenerationDetails.Side = _botHelper.GetPmcSideByRole(botGenerationDetails.Role); botGenerationDetails.BotDifficulty = GetPmcDifficulty(requestedBot?.Difficulty); - botGenerationDetails.BotCountToGenerate = _botConfig.PresetBatch?.GetByJsonProp(botGenerationDetails.Role); + botGenerationDetails.BotCountToGenerate = _botConfig.PresetBatch?.GetValueOrDefault(botGenerationDetails.Role, 5); } } @@ -320,7 +320,7 @@ public class BotController( var bossesToConvertToWeights = _botConfig.AssaultToBossConversion.BossesToConvertToWeights; if (bossConvertEnabled && botGenerationDetails.IsPmc is not null && !botGenerationDetails.IsPmc.Value) { - var bossConvertPercent = bossConvertMinMax.GetByJsonProp(requestedBot?.Role?.ToLower() ?? string.Empty); + var bossConvertPercent = bossConvertMinMax.GetValueOrDefault(requestedBot?.Role?.ToLower()); if (bossConvertPercent is not null) // Roll a percentage check if we should convert scav to boss { @@ -374,7 +374,7 @@ public class BotController( // Bosses are only ever 'normal' botGenerationDetails.BotDifficulty = "normal"; - botGenerationDetails.BotCountToGenerate = _botConfig.PresetBatch?.GetByJsonProp(botGenerationDetails.Role); + botGenerationDetails.BotCountToGenerate = _botConfig.PresetBatch?.GetValueOrDefault(botGenerationDetails.Role); } private string? GetPmcDifficulty(string? requestedBotDifficulty) @@ -391,8 +391,8 @@ public class BotController( private MinMax? GetPmcConversionMinMaxForLocation(string? requestedBotRole, string? location) { return _pmcConfig.ConvertIntoPmcChance!.TryGetValue(location?.ToLower() ?? "", out var mapSpecificConversionValues) - ? mapSpecificConversionValues.GetByJsonProp(requestedBotRole?.ToLower()) - : _pmcConfig.ConvertIntoPmcChance.GetValueOrDefault("default")?.GetValueOrDefault(requestedBotRole); + ? mapSpecificConversionValues.GetValueOrDefault(requestedBotRole?.ToLower()) + : _pmcConfig.ConvertIntoPmcChance["default"]?.GetValueOrDefault(requestedBotRole); } private GetRaidConfigurationRequestData? GetMostRecentRaidSettings() diff --git a/Libraries/Core/Controllers/CustomizationController.cs b/Libraries/Core/Controllers/CustomizationController.cs index 21b042cf..5789c035 100644 --- a/Libraries/Core/Controllers/CustomizationController.cs +++ b/Libraries/Core/Controllers/CustomizationController.cs @@ -107,7 +107,7 @@ public class CustomizationController( var profile = _saveServer.GetProfile(sessionId); - //TODO: Merge with function _profileHelper.addHideoutCustomisationUnlock + // TODO: Merge with function _profileHelper.addHideoutCustomisationUnlock var rewardToStore = new CustomisationStorage { Id = suitId, diff --git a/Libraries/Core/Controllers/MatchController.cs b/Libraries/Core/Controllers/MatchController.cs index 51fcf70e..a1521cb1 100644 --- a/Libraries/Core/Controllers/MatchController.cs +++ b/Libraries/Core/Controllers/MatchController.cs @@ -36,7 +36,7 @@ public class MatchController( /// Handle client/match/group/delete /// /// - public void DeleteGroup(DeleteGroupRequest info) // TODO: info is `any` in the node server + public void DeleteGroup(DeleteGroupRequest info) { _matchLocationService.DeleteGroup(info); } diff --git a/Libraries/Core/Controllers/PrestigeController.cs b/Libraries/Core/Controllers/PrestigeController.cs index a9f7f850..e11eaa1e 100644 --- a/Libraries/Core/Controllers/PrestigeController.cs +++ b/Libraries/Core/Controllers/PrestigeController.cs @@ -148,7 +148,6 @@ public class PrestigeController( { newProfile.CharacterData.PmcData.Achievements.Add("676091c0f457869a94017a23", _timeUtil.GetTimeStamp()); } - // TODO: is there one for second prestige // Add existing Stats to profile newProfile.CharacterData.PmcData.Stats = prePrestigePmc.Stats; diff --git a/Libraries/Core/Generators/BotGenerator.cs b/Libraries/Core/Generators/BotGenerator.cs index c35af6da..e435bc57 100644 --- a/Libraries/Core/Generators/BotGenerator.cs +++ b/Libraries/Core/Generators/BotGenerator.cs @@ -253,7 +253,7 @@ public class BotGenerator( bot.Info.Settings.UseSimpleAnimator = botJsonTemplate.BotExperience.UseSimpleAnimator ?? false; bot.Info.Voice = _weightedRandomHelper.GetWeightedValue(botJsonTemplate.BotAppearance.Voice); bot.Health = GenerateHealth(botJsonTemplate.BotHealth, botGenerationDetails.IsPlayerScav.GetValueOrDefault(false)); - bot.Skills = GenerateSkills(botJsonTemplate.BotSkills); // TODO: fix bad type, bot jsons store skills in dict, output needs to be array + bot.Skills = GenerateSkills(botJsonTemplate.BotSkills); bot.Info.PrestigeLevel = 0; if (botGenerationDetails.IsPmc.GetValueOrDefault(false)) diff --git a/Libraries/Core/Generators/LocationLootGenerator.cs b/Libraries/Core/Generators/LocationLootGenerator.cs index 9e631a50..a93fdc68 100644 --- a/Libraries/Core/Generators/LocationLootGenerator.cs +++ b/Libraries/Core/Generators/LocationLootGenerator.cs @@ -698,7 +698,7 @@ public class LocationLootGenerator( // Draw from random distribution var desiredSpawnpointCount = Math.Round( - GetLooseLootMultiplerForLocation(locationName) * + GetLooseLootMultiplierForLocation(locationName) * _randomUtil.GetNormallyDistributedRandomNumber( (double) dynamicLootDist.SpawnpointCount.Mean, (double) dynamicLootDist.SpawnpointCount.Std @@ -1087,16 +1087,6 @@ public class LocationLootGenerator( }; } - private double GetLooseLootMultiplerForLocation(string location) - { - return _locationConfig.LooseLootMultiplier[location]; - } - - protected double getStaticLootMultiplerForLocation(string location) - { - return _locationConfig.StaticLootMultiplier[location]; - } - // TODO: rewrite, BIG yikes protected ContainerItem? CreateStaticLootItem( diff --git a/Libraries/Core/Generators/RagfairOfferGenerator.cs b/Libraries/Core/Generators/RagfairOfferGenerator.cs index f4f54950..b9f869e4 100644 --- a/Libraries/Core/Generators/RagfairOfferGenerator.cs +++ b/Libraries/Core/Generators/RagfairOfferGenerator.cs @@ -419,7 +419,7 @@ public class RagfairOfferGenerator( ? 1 : randomUtil.GetDouble(config.OfferItemCount.Min.Value, config.OfferItemCount.Max.Value); - /* //TODO: ??????? + /* // TODO: ??????? if (ProgramStatics.DEBUG && !ProgramStatics.COMPILED) { offerCount = 2; } diff --git a/Libraries/Core/Loaders/BundleLoader.cs b/Libraries/Core/Loaders/BundleLoader.cs index a637ad53..9f934ec4 100644 --- a/Libraries/Core/Loaders/BundleLoader.cs +++ b/Libraries/Core/Loaders/BundleLoader.cs @@ -89,7 +89,7 @@ namespace Core.Loaders public void AddBundles(string modPath) { - //TODO: Implement + // TODO: Implement var modBundlesJson = _fileUtil.ReadFile(Path.Combine(modPath, "bundles.json")); var modBundles = _jsonUtil.Deserialize(modBundlesJson); diff --git a/Libraries/Core/Services/BotEquipmentFilterService.cs b/Libraries/Core/Services/BotEquipmentFilterService.cs index 98b7fb31..89754d19 100644 --- a/Libraries/Core/Services/BotEquipmentFilterService.cs +++ b/Libraries/Core/Services/BotEquipmentFilterService.cs @@ -344,11 +344,11 @@ public class BotEquipmentFilterService /// Weighting change to apply to bot /// Bot item dictionary to adjust protected void AdjustWeighting( - AdjustmentDetails weightingAdjustments, + AdjustmentDetails? weightingAdjustments, Dictionary> botItemPool, bool showEditWarnings = true) { - //TODO, bad typing by key with method below due to, EquipmentSlots + // TODO: bad typing by key with method below due to, EquipmentSlots if (weightingAdjustments is null) { return; diff --git a/Libraries/Core/Services/I18nService.cs b/Libraries/Core/Services/I18nService.cs index 5a9e983f..22e3a679 100644 --- a/Libraries/Core/Services/I18nService.cs +++ b/Libraries/Core/Services/I18nService.cs @@ -14,9 +14,8 @@ public class I18nService private readonly Dictionary>> _loadedLocales = new(); private List _locales; - private string _setLocale; + private string? _setLocale; - // TODO: try convert to primary ctor public I18nService( FileUtil fileUtil, JsonUtil jsonUtil, diff --git a/Libraries/Core/Services/LocationLifecycleService.cs b/Libraries/Core/Services/LocationLifecycleService.cs index cdf8db46..8a66cc78 100644 --- a/Libraries/Core/Services/LocationLifecycleService.cs +++ b/Libraries/Core/Services/LocationLifecycleService.cs @@ -151,7 +151,7 @@ public class LocationLifecycleService // Only has value when transitioning into map from previous one if (request.Transition is not null) - // TODO - why doesnt the raid after transit have any transit data? + // TODO - why doesn't the raid after transit have any transit data? { result.Transition = request.Transition; } diff --git a/Libraries/Core/Services/Mod/CustomItemService.cs b/Libraries/Core/Services/Mod/CustomItemService.cs index 0bdbcb08..9b73e0d3 100644 --- a/Libraries/Core/Services/Mod/CustomItemService.cs +++ b/Libraries/Core/Services/Mod/CustomItemService.cs @@ -12,12 +12,12 @@ namespace Core.Services.Mod; [Injectable] public class CustomItemService( - ISptLogger _logger, - HashUtil _hashUtil, - DatabaseService _databaseService, - ItemHelper _itemHelper, - ItemBaseClassService _itemBaseClassService, - ICloner _cloner + ISptLogger logger, + HashUtil hashUtil, + DatabaseService databaseService, + ItemHelper itemHelper, + ItemBaseClassService itemBaseClassService, + ICloner cloner ) { /** @@ -33,7 +33,7 @@ public class CustomItemService( public CreateItemResult CreateItemFromClone(NewItemFromCloneDetails newItemDetails) { var result = new CreateItemResult(); - var tables = _databaseService.GetTables(); + var tables = databaseService.GetTables(); // Generate new id for item if none supplied var newItemId = GetOrGenerateIdForItem(newItemDetails.NewId); @@ -49,7 +49,7 @@ public class CustomItemService( } // Clone existing item - var itemClone = _cloner.Clone(tables.Templates.Items[newItemDetails.ItemTplToClone]); + var itemClone = cloner.Clone(tables.Templates.Items[newItemDetails.ItemTplToClone]); // Update id and parentId of item itemClone.Id = newItemId; @@ -65,9 +65,9 @@ public class CustomItemService( AddToFleaPriceDb(newItemId, newItemDetails.FleaPriceRoubles); - _itemBaseClassService.HydrateItemBaseClassCache(); + itemBaseClassService.HydrateItemBaseClassCache(); - if (_itemHelper.IsOfBaseclass(itemClone.Id, BaseClasses.WEAPON)) + if (itemHelper.IsOfBaseclass(itemClone.Id, BaseClasses.WEAPON)) { AddToWeaponShelf(newItemId); } @@ -90,7 +90,7 @@ public class CustomItemService( public CreateItemResult CreateItem(NewItemDetails newItemDetails) { var result = new CreateItemResult(); - var tables = _databaseService.GetTables(); + var tables = databaseService.GetTables(); var newItem = newItemDetails.NewItem; @@ -109,9 +109,9 @@ public class CustomItemService( AddToFleaPriceDb(newItem.Id, newItemDetails.FleaPriceRoubles); - _itemBaseClassService.HydrateItemBaseClassCache(); + itemBaseClassService.HydrateItemBaseClassCache(); - if (_itemHelper.IsOfBaseclass(newItem.Id, BaseClasses.WEAPON)) + if (itemHelper.IsOfBaseclass(newItem.Id, BaseClasses.WEAPON)) { AddToWeaponShelf(newItem.Id); } @@ -129,7 +129,7 @@ public class CustomItemService( */ protected string GetOrGenerateIdForItem(string newId) { - return newId == "" ? _hashUtil.Generate() : newId; + return newId == "" ? hashUtil.Generate() : newId; } /** @@ -153,9 +153,9 @@ public class CustomItemService( */ protected void AddToItemsDb(string newItemId, TemplateItem itemToAdd) { - if (!_databaseService.GetItems().TryAdd(newItemId, itemToAdd)) + if (!databaseService.GetItems().TryAdd(newItemId, itemToAdd)) { - _logger.Warning($"Unable to add: {newItemId} To Database"); + logger.Warning($"Unable to add: {newItemId} To Database"); } } @@ -167,7 +167,7 @@ public class CustomItemService( */ protected void AddToHandbookDb(string newItemId, string parentId, double? priceRoubles) { - _databaseService + databaseService .GetTemplates() .Handbook.Items.Add( new HandbookItem @@ -182,7 +182,7 @@ public class CustomItemService( /** * Iterate through the passed in locale data and add to each locale in turn - * If data is not provided for each langauge eft uses, the first object will be used in its place + * If data is not provided for each language EFT uses, the first object will be used in its place * e.g. * en[0] * fr[1] @@ -193,22 +193,25 @@ public class CustomItemService( */ protected void AddToLocaleDbs(Dictionary localeDetails, string newItemId) { - var languages = _databaseService.GetLocales().Languages; + var languages = databaseService.GetLocales().Languages; foreach (var shortNameKey in languages) { // Get locale details passed in, if not provided by caller use first record in newItemDetails.locales localeDetails.TryGetValue(shortNameKey.Key, out var newLocaleDetails); - if (newLocaleDetails is null) - { - newLocaleDetails = localeDetails[localeDetails.Keys.FirstOrDefault()]; - } + newLocaleDetails ??= localeDetails[localeDetails.Keys.FirstOrDefault()]; // Create new record in locale file - var globals = _databaseService.GetLocales(); - globals.Global[shortNameKey.Key].Value[$"{newItemId} Name"] = newLocaleDetails.Name; - globals.Global[shortNameKey.Key].Value[$"{newItemId} ShortName"] = newLocaleDetails.ShortName; - globals.Global[shortNameKey.Key].Value[$"{newItemId} Description"] = newLocaleDetails.Description; + if (!databaseService.GetLocales().Global.TryGetValue(shortNameKey.Key, out var desiredGlobal)) + { + logger.Error($"Unable to add locale keys to {shortNameKey.Key}"); + + return; + } + + desiredGlobal.Value[$"{newItemId} Name"] = newLocaleDetails.Name; + desiredGlobal.Value[$"{newItemId} ShortName"] = newLocaleDetails.ShortName; + desiredGlobal.Value[$"{newItemId} Description"] = newLocaleDetails.Description; } } @@ -219,7 +222,7 @@ public class CustomItemService( */ protected void AddToFleaPriceDb(string newItemId, double? fleaPriceRoubles) { - _databaseService.GetTemplates().Prices[newItemId] = fleaPriceRoubles ?? 0; + databaseService.GetTemplates().Prices[newItemId] = fleaPriceRoubles ?? 0; } /** @@ -237,7 +240,7 @@ public class CustomItemService( ]; foreach (var wallId in wallStashIds) { - var wall = _itemHelper.GetItem(wallId); + var wall = itemHelper.GetItem(wallId); if (wall.Key) { wall.Value.Properties.Grids[0].Props.Filters[0].Filter.Add(newItemId); @@ -253,32 +256,32 @@ public class CustomItemService( */ public void AddCustomWeaponToPMCs(string weaponTpl, double weaponWeight, string weaponSlot) { - var weapon = _itemHelper.GetItem(weaponTpl); + var weapon = itemHelper.GetItem(weaponTpl); if (!weapon.Key) { - _logger.Warning($"Unable to add custom weapon {weaponTpl} to PMCs as it cannot be found in the Item db"); + logger.Warning($"Unable to add custom weapon {weaponTpl} to PMCs as it cannot be found in the Item db"); return; } - Dictionary?> baseWeaponModObject = new Dictionary?>(); + var baseWeaponModObject = new Dictionary?>(); // Get all slots weapon has and create a dictionary of them with possible mods that slot into each var weaponSlots = weapon.Value.Properties.Slots; foreach (var slot in weaponSlots) { - baseWeaponModObject[slot.Name] = new HashSet(slot.Props.Filters[0].Filter); + baseWeaponModObject[slot.Name] = [..slot.Props.Filters[0].Filter]; } // Get PMCs - var botTypes = _databaseService.GetBots().Types; + var botTypes = databaseService.GetBots().Types; // Add weapon base+mods into bear/usec data botTypes["usec"].BotInventory.Mods[weaponTpl] = baseWeaponModObject; botTypes["bear"].BotInventory.Mods[weaponTpl] = baseWeaponModObject; // Add weapon to array of allowed weapons + weighting to be picked - botTypes["usec"].BotInventory.Equipment.GetByJsonProp>(weaponSlot)[weaponTpl] = weaponWeight; - botTypes["bear"].BotInventory.Equipment.GetByJsonProp>(weaponSlot)[weaponTpl] = weaponWeight; + botTypes["usec"].BotInventory.Equipment[Enum.Parse(weaponSlot)][weaponTpl] = weaponWeight; + botTypes["bear"].BotInventory.Equipment[Enum.Parse(weaponSlot)][weaponTpl] = weaponWeight; } } diff --git a/Server/Logger/WebApplicationLogger.cs b/Server/Logger/WebApplicationLogger.cs index ed7d3478..ab24b6a1 100644 --- a/Server/Logger/WebApplicationLogger.cs +++ b/Server/Logger/WebApplicationLogger.cs @@ -64,7 +64,7 @@ public class SptWebApplicationLogger : ISptLogger public void WriteToLogFile(string data) { - //TODO - implement + turn object into json + // TODO: implement + turn object into json _logger.LogError("NOT IMPLEMENTED - WriteToLogFile"); } diff --git a/Server/ModDllLoader.cs b/Server/ModDllLoader.cs index 34c7cd87..69b22315 100644 --- a/Server/ModDllLoader.cs +++ b/Server/ModDllLoader.cs @@ -69,7 +69,7 @@ public class ModDllLoader private static void SortMods(List mods) { - //TODO: implement + // TODO: implement Console.WriteLine($"NOT IMPLEMENTED: SortMods"); }