From 3219718d27761f3f49221e6e0263bc78ce3885ac Mon Sep 17 00:00:00 2001 From: Chomp Date: Mon, 10 Feb 2025 10:44:24 +0000 Subject: [PATCH] Replaced minmaxdouble + minmaxint with generic minmax Updated various doubles to be ints --- Libraries/Core/Controllers/BotController.cs | 9 ++-- .../Core/Controllers/RagfairController.cs | 8 ++-- .../Generators/BotEquipmentModGenerator.cs | 8 ++-- Libraries/Core/Generators/BotGenerator.cs | 46 +++++++++---------- .../Core/Generators/BotLevelGenerator.cs | 16 +++---- Libraries/Core/Generators/LootGenerator.cs | 22 ++++----- .../Core/Generators/RagfairOfferGenerator.cs | 8 ++-- .../Generators/ScavCaseRewardGenerator.cs | 16 +++---- Libraries/Core/Generators/WeatherGenerator.cs | 8 ++-- Libraries/Core/Helpers/BotHelper.cs | 8 ++-- Libraries/Core/Helpers/RagfairSellHelper.cs | 6 +-- Libraries/Core/Helpers/RagfairServerHelper.cs | 4 +- Libraries/Core/Helpers/TraderHelper.cs | 4 +- .../Models/Common/{MinMaxInt.cs => MinMax.cs} | 10 ++-- Libraries/Core/Models/Common/MinMaxDouble.cs | 37 --------------- .../Core/Models/Eft/Common/LocationBase.cs | 4 +- .../Core/Models/Eft/Common/Tables/BotType.cs | 28 +++++------ .../Models/Eft/Hideout/HideoutProduction.cs | 6 +-- .../Models/Eft/Ragfair/GetItemPriceResult.cs | 2 +- .../Models/Spt/Bots/BotGenerationDetails.cs | 8 ++-- .../Core/Models/Spt/Config/AirdropConfig.cs | 12 ++--- Libraries/Core/Models/Spt/Config/BotConfig.cs | 12 ++--- .../Core/Models/Spt/Config/HideoutConfig.cs | 8 ++-- .../Core/Models/Spt/Config/InventoryConfig.cs | 4 +- .../Core/Models/Spt/Config/LocationConfig.cs | 2 +- Libraries/Core/Models/Spt/Config/PmcConfig.cs | 20 ++++---- .../Core/Models/Spt/Config/QuestConfig.cs | 2 +- .../Core/Models/Spt/Config/RagfairConfig.cs | 22 ++++----- .../Core/Models/Spt/Config/RepairConfig.cs | 4 +- .../Core/Models/Spt/Config/ScavCaseConfig.cs | 10 ++-- .../Core/Models/Spt/Config/TraderConfig.cs | 16 +++---- .../Core/Models/Spt/Config/WeatherConfig.cs | 10 ++-- .../Core/Models/Spt/Services/LootRequest.cs | 12 ++--- .../Core/Services/BotLootCacheService.cs | 2 +- .../Core/Services/CircleOfCultistService.cs | 2 +- Libraries/Core/Services/FenceService.cs | 2 +- .../Core/Services/RagfairPriceService.cs | 6 +-- Libraries/Core/Services/RepairService.cs | 6 +-- .../TraderPurchasePersisterService.cs | 2 +- 39 files changed, 187 insertions(+), 225 deletions(-) rename Libraries/Core/Models/Common/{MinMaxInt.cs => MinMax.cs} (74%) delete mode 100644 Libraries/Core/Models/Common/MinMaxDouble.cs diff --git a/Libraries/Core/Controllers/BotController.cs b/Libraries/Core/Controllers/BotController.cs index 8c31cd26..4698f2ea 100644 --- a/Libraries/Core/Controllers/BotController.cs +++ b/Libraries/Core/Controllers/BotController.cs @@ -16,7 +16,6 @@ using Core.Services; using Core.Utils; using Core.Utils.Cloners; using SptCommon.Annotations; -using SptCommon.Extensions; using LogLevel = Core.Models.Spt.Logging.LogLevel; namespace Core.Controllers; @@ -301,7 +300,7 @@ public class BotController( ); if (convertIntoPmcChanceMinMax is not null && !botGenerationDetails.IsPmc.GetValueOrDefault(false)) { - // Bot has % chance to become pmc and isnt one pmc already + // Bot has % chance to become pmc and isn't one pmc already var convertToPmc = _botHelper.RollChanceToBePmc(convertIntoPmcChanceMinMax); if (convertToPmc) { @@ -324,7 +323,7 @@ public class BotController( if (bossConvertPercent is not null) // Roll a percentage check if we should convert scav to boss { - if (_randomUtil.GetChance100(_randomUtil.GetDouble(bossConvertPercent.Min!.Value, bossConvertPercent.Max!.Value))) + if (_randomUtil.GetChance100(_randomUtil.GetDouble(bossConvertPercent.Min, bossConvertPercent.Max))) { UpdateBotGenerationDetailsToRandomBoss(botGenerationDetails, bossesToConvertToWeights); } @@ -388,7 +387,7 @@ public class BotController( }; } - private MinMaxDouble? GetPmcConversionMinMaxForLocation(string? requestedBotRole, string? location) + private MinMax? GetPmcConversionMinMaxForLocation(string? requestedBotRole, string? location) { return _pmcConfig.ConvertIntoPmcChance!.TryGetValue(location?.ToLower() ?? "", out var mapSpecificConversionValues) ? mapSpecificConversionValues.GetValueOrDefault(requestedBotRole?.ToLower()) @@ -409,7 +408,7 @@ public class BotController( return raidSettings; } - private MinMaxDouble? GetPmcLevelRangeForMap(string? location) + private MinMax GetPmcLevelRangeForMap(string? location) { return _pmcConfig.LocationSpecificPmcLevelOverride!.GetValueOrDefault(location?.ToLower() ?? "", null); } diff --git a/Libraries/Core/Controllers/RagfairController.cs b/Libraries/Core/Controllers/RagfairController.cs index 36f054fc..4f1b7d2c 100644 --- a/Libraries/Core/Controllers/RagfairController.cs +++ b/Libraries/Core/Controllers/RagfairController.cs @@ -369,7 +369,7 @@ public class RagfairController if (offers.Count > 0) { // These get calculated while iterating through the list below - var minMax = new MinMaxDouble(int.MaxValue, 0); + var minMax = new MinMax(int.MaxValue, 0); // Get the average offer price, excluding barter offers var average = GetAveragePriceFromOffers(offers, minMax, ignoreTraderOffers); @@ -398,7 +398,7 @@ public class RagfairController }; } - private double GetAveragePriceFromOffers(List offers, MinMaxDouble minMax, bool ignoreTraderOffers) + private double GetAveragePriceFromOffers(List offers, MinMax minMax, bool ignoreTraderOffers) { var sum = 0d; var totalOfferCount = 0; @@ -425,11 +425,11 @@ public class RagfairController // Handle min/max calculations based on the per-item price if (perItemPrice < minMax.Min) { - minMax.Min = perItemPrice; + minMax.Min = perItemPrice.Value; } else if (perItemPrice > minMax.Max) { - minMax.Max = perItemPrice; + minMax.Max = perItemPrice.Value; } sum += perItemPrice.Value; diff --git a/Libraries/Core/Generators/BotEquipmentModGenerator.cs b/Libraries/Core/Generators/BotEquipmentModGenerator.cs index bae44d27..06f74df4 100644 --- a/Libraries/Core/Generators/BotEquipmentModGenerator.cs +++ b/Libraries/Core/Generators/BotEquipmentModGenerator.cs @@ -360,7 +360,7 @@ public class BotEquipmentModGenerator( return result; } - private MinMaxDouble GetMinMaxArmorPlateClass(List platePool) + private MinMax GetMinMaxArmorPlateClass(List platePool) { platePool.Sort( (x, y) => @@ -379,10 +379,10 @@ public class BotEquipmentModGenerator( } ); - return new MinMaxDouble + return new MinMax { - Min = platePool[0].Properties.ArmorClass, - Max = platePool[platePool.Count - 1].Properties.ArmorClass + Min = platePool[0].Properties.ArmorClass.Value, + Max = platePool[platePool.Count - 1].Properties.ArmorClass.Value }; } diff --git a/Libraries/Core/Generators/BotGenerator.cs b/Libraries/Core/Generators/BotGenerator.cs index 4c58b864..a80a76a7 100644 --- a/Libraries/Core/Generators/BotGenerator.cs +++ b/Libraries/Core/Generators/BotGenerator.cs @@ -318,7 +318,7 @@ public class BotGenerator( /// the killed bots difficulty /// Role of bot (optional, used for error logging) /// Experience for kill - public double GetExperienceRewardForKillByDifficulty(Dictionary experiences, string botDifficulty, string role) + public double GetExperienceRewardForKillByDifficulty(Dictionary> experiences, string botDifficulty, string role) { if (!experiences.TryGetValue(botDifficulty.ToLower(), out var result)) { @@ -327,10 +327,10 @@ public class BotGenerator( _logger.Debug($"Unable to find experience: {botDifficulty} for {role} bot, falling back to `normal`"); } - return _randomUtil.GetDouble(experiences["normal"].Min.Value, experiences["normal"].Max.Value); + return _randomUtil.GetDouble(experiences["normal"].Min, experiences["normal"].Max); } - return _randomUtil.GetDouble(result.Min.Value, result.Max.Value); + return _randomUtil.GetDouble(result.Min, result.Max); } /// @@ -510,17 +510,17 @@ public class BotGenerator( { Hydration = new CurrentMinMax { - Current = _randomUtil.GetDouble(healthObj.Hydration.Min.Value, healthObj.Hydration.Max.Value), + Current = _randomUtil.GetDouble(healthObj.Hydration.Min, healthObj.Hydration.Max), Maximum = healthObj.Hydration.Max }, Energy = new CurrentMinMax { - Current = _randomUtil.GetDouble(healthObj.Energy.Min.Value, healthObj.Energy.Max.Value), + Current = _randomUtil.GetDouble(healthObj.Energy.Min, healthObj.Energy.Max), Maximum = healthObj.Energy.Max }, Temperature = new CurrentMinMax { - Current = _randomUtil.GetDouble(healthObj.Temperature.Min.Value, healthObj.Temperature.Max.Value), + Current = _randomUtil.GetDouble(healthObj.Temperature.Min, healthObj.Temperature.Max), Maximum = healthObj.Temperature.Max }, BodyParts = new Dictionary @@ -530,8 +530,8 @@ public class BotGenerator( { Health = new CurrentMinMax { - Current = _randomUtil.GetDouble(bodyParts.Head.Min.Value, bodyParts.Head.Max.Value), - Maximum = Math.Round(bodyParts.Head.Max ?? 0) + Current = _randomUtil.GetDouble(bodyParts.Head.Min, bodyParts.Head.Max), + Maximum = (double)Math.Round(bodyParts.Head.Max) } } }, @@ -540,8 +540,8 @@ public class BotGenerator( { Health = new CurrentMinMax { - Current = _randomUtil.GetDouble(bodyParts.Chest.Min.Value, bodyParts.Chest.Max.Value), - Maximum = Math.Round(bodyParts.Chest.Max ?? 0) + Current = _randomUtil.GetDouble(bodyParts.Chest.Min, bodyParts.Chest.Max), + Maximum = (double)Math.Round(bodyParts.Chest.Max) } } }, @@ -550,8 +550,8 @@ public class BotGenerator( { Health = new CurrentMinMax { - Current = _randomUtil.GetDouble(bodyParts.Stomach.Min.Value, bodyParts.Stomach.Max.Value), - Maximum = Math.Round(bodyParts.Stomach.Max ?? 0) + Current = _randomUtil.GetDouble(bodyParts.Stomach.Min, bodyParts.Stomach.Max), + Maximum = Math.Round(bodyParts.Stomach.Max) } } }, @@ -560,8 +560,8 @@ public class BotGenerator( { Health = new CurrentMinMax { - Current = _randomUtil.GetDouble(bodyParts.LeftArm.Min.Value, bodyParts.LeftArm.Max.Value), - Maximum = Math.Round(bodyParts.LeftArm.Max ?? 0) + Current = _randomUtil.GetDouble(bodyParts.LeftArm.Min, bodyParts.LeftArm.Max), + Maximum = Math.Round(bodyParts.LeftArm.Max) } } }, @@ -570,8 +570,8 @@ public class BotGenerator( { Health = new CurrentMinMax { - Current = _randomUtil.GetDouble(bodyParts.RightArm.Min.Value, bodyParts.RightArm.Max.Value), - Maximum = Math.Round(bodyParts.RightArm.Max ?? 0) + Current = _randomUtil.GetDouble(bodyParts.RightArm.Min, bodyParts.RightArm.Max), + Maximum = Math.Round(bodyParts.RightArm.Max) } } }, @@ -580,8 +580,8 @@ public class BotGenerator( { Health = new CurrentMinMax { - Current = _randomUtil.GetDouble(bodyParts.LeftLeg.Min.Value, bodyParts.LeftLeg.Max.Value), - Maximum = Math.Round(bodyParts.LeftLeg.Max ?? 0) + Current = _randomUtil.GetDouble(bodyParts.LeftLeg.Min, bodyParts.LeftLeg.Max), + Maximum = Math.Round(bodyParts.LeftLeg.Max) } } }, @@ -590,8 +590,8 @@ public class BotGenerator( { Health = new CurrentMinMax { - Current = _randomUtil.GetDouble(bodyParts.RightLeg.Min.Value, bodyParts.RightLeg.Max.Value), - Maximum = Math.Round(bodyParts.RightLeg.Max ?? 0) + Current = _randomUtil.GetDouble(bodyParts.RightLeg.Min, bodyParts.RightLeg.Max), + Maximum = Math.Round(bodyParts.RightLeg.Max) } } } @@ -624,7 +624,7 @@ public class BotGenerator( foreach (var prop in props) { - var value = (MinMaxDouble) prop.GetValue(bodyPart); + var value = (MinMax) prop.GetValue(bodyPart); hpTotal += value.Max; } @@ -662,7 +662,7 @@ public class BotGenerator( /// Skills to randomise /// Are the skills 'common' skills /// Skills with randomised progress values as an array - public List GetSkillsWithRandomisedProgressValue(Dictionary? skills, bool isCommonSkills) + public List GetSkillsWithRandomisedProgressValue(Dictionary>? skills, bool isCommonSkills) { if (skills is null) { @@ -683,7 +683,7 @@ public class BotGenerator( var skillToAdd = new BaseSkill { Id = kvp.Key, - Progress = _randomUtil.GetDouble(skill.Min.Value, skill.Max.Value) + Progress = _randomUtil.GetDouble(skill.Min, skill.Max) }; // Common skills have additional props diff --git a/Libraries/Core/Generators/BotLevelGenerator.cs b/Libraries/Core/Generators/BotLevelGenerator.cs index 62b89381..47379392 100644 --- a/Libraries/Core/Generators/BotLevelGenerator.cs +++ b/Libraries/Core/Generators/BotLevelGenerator.cs @@ -24,7 +24,7 @@ public class BotLevelGenerator( /// Details to help generate a bot /// Bot the level is being generated for /// IRandomisedBotLevelResult object - public RandomisedBotLevelResult GenerateBotLevel(MinMaxDouble levelDetails, BotGenerationDetails botGenerationDetails, BotBase bot) + public RandomisedBotLevelResult GenerateBotLevel(MinMax levelDetails, BotGenerationDetails botGenerationDetails, BotBase bot) { if (!botGenerationDetails.IsPmc.GetValueOrDefault(false)) { @@ -41,7 +41,7 @@ public class BotLevelGenerator( // Get random level based on the exp table. var exp = 0; var level = int.Parse( - ChooseBotLevel(botLevelRange.Min.Value, botLevelRange.Max.Value, 1, 1.15) + ChooseBotLevel(botLevelRange.Min, botLevelRange.Max, 1, 1.15) .ToString() ); // TODO - nasty double to string to int conversion for (var i = 0; i < level; i++) @@ -74,22 +74,22 @@ public class BotLevelGenerator( /// /// Max level allowed /// A MinMax of the lowest and highest level to generate the bots - public MinMaxDouble GetRelativePmcBotLevelRange(BotGenerationDetails botGenerationDetails, MinMaxDouble levelDetails, int maxAvailableLevel) + public MinMax GetRelativePmcBotLevelRange(BotGenerationDetails botGenerationDetails, MinMax levelDetails, int maxAvailableLevel) { var levelOverride = botGenerationDetails.LocationSpecificPmcLevelOverride; // Create a min limit PMCs level cannot fall below var minPossibleLevel = levelOverride is not null ? Math.Min( - Math.Max(levelDetails.Min.Value, levelOverride.Min.Value), // Biggest between json min and the botgen min + Math.Max(levelDetails.Min, levelOverride.Min), // Biggest between json min and the botgen min maxAvailableLevel // Fallback if value above is crazy (default is 79) ) - : Math.Min(levelDetails.Min.Value, maxAvailableLevel); // Not pmc with override or non-pmc + : Math.Min(levelDetails.Min, maxAvailableLevel); // Not pmc with override or non-pmc // Create a max limit PMCs level cannot go above var maxPossibleLevel = levelOverride is not null - ? Math.Min(levelOverride.Max.Value, maxAvailableLevel) // Was a PMC and they have a level override - : Math.Min(levelDetails.Max.Value, maxAvailableLevel); // Not pmc with override or non-pmc + ? Math.Min(levelOverride.Max, maxAvailableLevel) // Was a PMC and they have a level override + : Math.Min(levelDetails.Max, maxAvailableLevel); // Not pmc with override or non-pmc // Get min level relative to player if value exists var minLevel = botGenerationDetails.PlayerLevel.HasValue @@ -105,6 +105,6 @@ public class BotLevelGenerator( maxLevel = Math.Min(Math.Max(maxLevel, minPossibleLevel), maxPossibleLevel); minLevel = Math.Min(Math.Max(minLevel, minPossibleLevel), maxPossibleLevel); - return new MinMaxDouble(minLevel, maxLevel); + return new MinMax(minLevel, maxLevel); } } diff --git a/Libraries/Core/Generators/LootGenerator.cs b/Libraries/Core/Generators/LootGenerator.cs index 60d73322..6f774503 100644 --- a/Libraries/Core/Generators/LootGenerator.cs +++ b/Libraries/Core/Generators/LootGenerator.cs @@ -42,8 +42,8 @@ public class LootGenerator( // Handle sealed weapon containers var sealedWeaponCrateCount = _randomUtil.GetInt( - options.WeaponCrateCount.Min.Value, - options.WeaponCrateCount.Max.Value + options.WeaponCrateCount.Min, + options.WeaponCrateCount.Max ); if (sealedWeaponCrateCount > 0) { @@ -84,7 +84,7 @@ public class LootGenerator( // Pool has items we could add as loot, proceed if (rewardPoolResults.ItemPool.Count > 0) { - var randomisedItemCount = _randomUtil.GetInt(options.ItemCount.Min.Value, options.ItemCount.Max.Value); + var randomisedItemCount = _randomUtil.GetInt(options.ItemCount.Min, options.ItemCount.Max); for (var index = 0; index < randomisedItemCount; index++) { if (!FindAndAddRandomItemToLoot(rewardPoolResults.ItemPool, itemTypeCounts, options, result)) @@ -99,8 +99,8 @@ public class LootGenerator( // Filter default presets to just weapons var randomisedWeaponPresetCount = _randomUtil.GetInt( - options.WeaponPresetCount.Min.Value, - options.WeaponPresetCount.Max.Value + options.WeaponPresetCount.Min, + options.WeaponPresetCount.Max ); if (randomisedWeaponPresetCount > 0) { @@ -132,8 +132,8 @@ public class LootGenerator( // Filter default presets to just armors and then filter again by protection level var randomisedArmorPresetCount = _randomUtil.GetInt( - options.ArmorPresetCount.Min.Value, - options.ArmorPresetCount.Max.Value + options.ArmorPresetCount.Min, + options.ArmorPresetCount.Max ); if (randomisedArmorPresetCount > 0) { @@ -177,7 +177,7 @@ public class LootGenerator( /// /// Dictionary of item tpls with minmax values /// Array of Item - public List CreateForcedLoot(Dictionary forcedLootDict) + public List CreateForcedLoot(Dictionary> forcedLootDict) { var result = new List(); @@ -186,7 +186,7 @@ public class LootGenerator( foreach (var forcedItemKvP in forcedItems) { var details = forcedLootDict[forcedItemKvP.Key]; - var randomisedItemCount = _randomUtil.GetInt(details.Min.Value, details.Max.Value); + var randomisedItemCount = _randomUtil.GetInt(details.Min, details.Max); // Add forced loot item to result var newLootItem = new Item @@ -542,7 +542,7 @@ public class LootGenerator( foreach (var (rewardKey, settings) in containerSettings.RewardTypeLimits) { - var rewardCount = _randomUtil.GetInt(settings.Min.Value, settings.Max.Value); + var rewardCount = _randomUtil.GetInt(settings.Min, settings.Max); if (rewardCount == 0) { continue; @@ -649,7 +649,7 @@ public class LootGenerator( foreach (var (rewardKey, settings) in containerSettings.WeaponModRewardLimits) { - var rewardCount = _randomUtil.GetInt(settings.Min.Value, settings.Max.Value); + var rewardCount = _randomUtil.GetInt(settings.Min, settings.Max); // Nothing to add, skip reward type if (rewardCount == 0) diff --git a/Libraries/Core/Generators/RagfairOfferGenerator.cs b/Libraries/Core/Generators/RagfairOfferGenerator.cs index b9f869e4..4ede30ff 100644 --- a/Libraries/Core/Generators/RagfairOfferGenerator.cs +++ b/Libraries/Core/Generators/RagfairOfferGenerator.cs @@ -198,8 +198,8 @@ public class RagfairOfferGenerator( MemberType = MemberCategory.Default, Nickname = botHelper.GetPmcNicknameOfMaxLength(botConfig.BotNameLengthLimit), Rating = randomUtil.GetDouble( - (double) ragfairConfig.Dynamic.Rating.Min, - (double) ragfairConfig.Dynamic.Rating.Max + ragfairConfig.Dynamic.Rating.Min, + ragfairConfig.Dynamic.Rating.Max ), IsRatingGrowing = randomUtil.GetBool(), Avatar = null, @@ -342,7 +342,7 @@ public class RagfairOfferGenerator( // Generated fake-player offer return (long) Math.Round( - time + randomUtil.GetDouble(ragfairConfig.Dynamic.EndTimeSeconds.Min.Value, ragfairConfig.Dynamic.EndTimeSeconds.Max.Value) + time + randomUtil.GetDouble(ragfairConfig.Dynamic.EndTimeSeconds.Min, ragfairConfig.Dynamic.EndTimeSeconds.Max) ); } @@ -417,7 +417,7 @@ public class RagfairOfferGenerator( // Limit to 1 offer when processing expired - like-for-like replacement var offerCount = isExpiredOffer ? 1 - : randomUtil.GetDouble(config.OfferItemCount.Min.Value, config.OfferItemCount.Max.Value); + : randomUtil.GetDouble(config.OfferItemCount.Min, config.OfferItemCount.Max); /* // TODO: ??????? if (ProgramStatics.DEBUG && !ProgramStatics.COMPILED) { diff --git a/Libraries/Core/Generators/ScavCaseRewardGenerator.cs b/Libraries/Core/Generators/ScavCaseRewardGenerator.cs index 76388d70..f62a6d20 100644 --- a/Libraries/Core/Generators/ScavCaseRewardGenerator.cs +++ b/Libraries/Core/Generators/ScavCaseRewardGenerator.cs @@ -464,20 +464,20 @@ public class ScavCaseRewardGenerator( amountToGive = itemToCalculate.Id switch { Money.ROUBLES => _randomUtil.GetInt( - (int) _scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp(rarity).Min, - (int) _scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp(rarity).Max + _scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp>(rarity).Min, + _scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp>(rarity).Max ), Money.EUROS => _randomUtil.GetInt( - (int) _scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp(rarity).Min, - (int) _scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp(rarity).Max + _scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp>(rarity).Min, + _scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp>(rarity).Max ), Money.DOLLARS => _randomUtil.GetInt( - (int) _scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp(rarity).Min, - (int) _scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp(rarity).Max + _scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp>(rarity).Min, + _scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp>(rarity).Max ), Money.GP => _randomUtil.GetInt( - (int) _scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp(rarity).Min, - (int) _scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp(rarity).Max + _scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp>(rarity).Min, + _scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp>(rarity).Max ), _ => amountToGive }; diff --git a/Libraries/Core/Generators/WeatherGenerator.cs b/Libraries/Core/Generators/WeatherGenerator.cs index 301abe2f..5c5241cd 100644 --- a/Libraries/Core/Generators/WeatherGenerator.cs +++ b/Libraries/Core/Generators/WeatherGenerator.cs @@ -78,13 +78,13 @@ public class WeatherGenerator( // TODO: Ensure Weather settings match Ts Server GetRandomDouble produces a decimal value way higher than ts server var result = new Weather { - Pressure = GetRandomDouble(weatherValues.Pressure.Min ?? 0, weatherValues.Pressure.Max ?? 0), + Pressure = GetRandomDouble(weatherValues.Pressure.Min, weatherValues.Pressure.Max), Temperature = 0, Fog = GetWeightedFog(weatherValues), RainIntensity = - rain > 1 ? GetRandomDouble(weatherValues.RainIntensity.Min ?? 0, weatherValues.RainIntensity.Max ?? 0) : 0, + rain > 1 ? GetRandomDouble(weatherValues.RainIntensity.Min, weatherValues.RainIntensity.Max) : 0, Rain = rain, - WindGustiness = GetRandomDouble(weatherValues.WindGustiness.Min ?? 0, weatherValues.WindGustiness.Max ?? 0, 2), + WindGustiness = GetRandomDouble(weatherValues.WindGustiness.Min, weatherValues.WindGustiness.Max, 2), WindDirection = GetWeightedWindDirection(weatherValues), WindSpeed = GetWeightedWindSpeed(weatherValues), Cloud = clouds, @@ -126,7 +126,7 @@ public class WeatherGenerator( ? weather.Temp.Night : weather.Temp.Day; - return Math.Round(_randomUtil.GetDouble(minMax.Min ?? 0, minMax.Max ?? 0), 2); + return Math.Round(_randomUtil.GetDouble(minMax.Min, minMax.Max), 2); } /** diff --git a/Libraries/Core/Helpers/BotHelper.cs b/Libraries/Core/Helpers/BotHelper.cs index 82543aba..f000b340 100644 --- a/Libraries/Core/Helpers/BotHelper.cs +++ b/Libraries/Core/Helpers/BotHelper.cs @@ -112,17 +112,17 @@ public class BotHelper( } } - public bool RollChanceToBePmc(MinMaxDouble botConvertMinMax) + public bool RollChanceToBePmc(MinMax botConvertMinMax) { - return _randomUtil.GetChance100(_randomUtil.GetDouble(botConvertMinMax.Min.Value, botConvertMinMax.Max.Value)); + return _randomUtil.GetChance100(_randomUtil.GetDouble(botConvertMinMax.Min, botConvertMinMax.Max)); } - protected Dictionary GetPmcConversionValuesForLocation(string location) + protected Dictionary> GetPmcConversionValuesForLocation(string location) { var result = _pmcConfig.ConvertIntoPmcChance[location.ToLower()]; if (result is null) { - _pmcConfig.ConvertIntoPmcChance = new Dictionary>(); + _pmcConfig.ConvertIntoPmcChance = new Dictionary>>(); } return result; diff --git a/Libraries/Core/Helpers/RagfairSellHelper.cs b/Libraries/Core/Helpers/RagfairSellHelper.cs index beefbc64..3841786f 100644 --- a/Libraries/Core/Helpers/RagfairSellHelper.cs +++ b/Libraries/Core/Helpers/RagfairSellHelper.cs @@ -102,8 +102,8 @@ public class RagfairSellHelper( // Passed roll check, item will be sold // Weight time to sell towards selling faster based on how cheap the item sold var weighting = (100 - effectiveSellChance) / 100; - var maximumTime = weighting * _ragfairConfig.Sell.Time.Max * 60; - var minimumTime = _ragfairConfig.Sell.Time.Min * 60; + var maximumTime = weighting * _ragfairConfig.Sell.Time.Max * 60d; + var minimumTime = _ragfairConfig.Sell.Time.Min * 60d; if (maximumTime < minimumTime) { maximumTime = minimumTime + 5; @@ -111,7 +111,7 @@ public class RagfairSellHelper( // Sell time will be random between min/max var random = new Random(); - var newSellTime = Math.Floor(random.NextDouble() * (maximumTime.Value - minimumTime.Value) + minimumTime.Value); + var newSellTime = Math.Floor(random.NextDouble() * (maximumTime.Value - minimumTime) + minimumTime); if (newSellTime == 0) // Ensure all sales don't occur the same exact time { diff --git a/Libraries/Core/Helpers/RagfairServerHelper.cs b/Libraries/Core/Helpers/RagfairServerHelper.cs index 4e3b2aaa..b100429b 100644 --- a/Libraries/Core/Helpers/RagfairServerHelper.cs +++ b/Libraries/Core/Helpers/RagfairServerHelper.cs @@ -166,11 +166,11 @@ public class RagfairServerHelper( // non-stackable - use different values to calculate stack size if (maxStackSize == 1) { - return (int) randomUtil.GetDouble(config.NonStackableCount.Min.Value, config.NonStackableCount.Max.Value); + return randomUtil.GetInt(config.NonStackableCount.Min, config.NonStackableCount.Max); } // Get a % to get of stack size - var stackPercent = randomUtil.GetDouble(config.StackablePercent.Min.Value, config.StackablePercent.Max.Value); + var stackPercent = randomUtil.GetDouble(config.StackablePercent.Min, config.StackablePercent.Max); // Min value to return should be no less than 1 return Math.Max((int) randomUtil.GetPercentOfValue(stackPercent, maxStackSize, 0), 1); diff --git a/Libraries/Core/Helpers/TraderHelper.cs b/Libraries/Core/Helpers/TraderHelper.cs index 5c4ddbc6..e01e47b2 100644 --- a/Libraries/Core/Helpers/TraderHelper.cs +++ b/Libraries/Core/Helpers/TraderHelper.cs @@ -376,7 +376,7 @@ public class TraderHelper( public long? GetTraderUpdateSeconds(string traderId) { var traderDetails = _traderConfig.UpdateTime.FirstOrDefault(x => x.TraderId == traderId); - if (traderDetails is null || traderDetails.Seconds?.Min is null || traderDetails.Seconds.Max is null) + if (traderDetails?.Seconds?.Min is null || traderDetails.Seconds?.Max is null) { _logger.Warning( _localisationService.GetText( @@ -394,7 +394,7 @@ public class TraderHelper( // create temporary entry to prevent logger spam { TraderId = traderId, - Seconds = new MinMaxDouble(_traderConfig.UpdateTimeDefault, _traderConfig.UpdateTimeDefault) + Seconds = new MinMax(_traderConfig.UpdateTimeDefault, _traderConfig.UpdateTimeDefault) } ); diff --git a/Libraries/Core/Models/Common/MinMaxInt.cs b/Libraries/Core/Models/Common/MinMax.cs similarity index 74% rename from Libraries/Core/Models/Common/MinMaxInt.cs rename to Libraries/Core/Models/Common/MinMax.cs index 36ca6710..a2e0d96a 100644 --- a/Libraries/Core/Models/Common/MinMaxInt.cs +++ b/Libraries/Core/Models/Common/MinMax.cs @@ -2,15 +2,15 @@ using System.Text.Json.Serialization; namespace Core.Models.Common; -public record MinMaxInt +public record MinMax { - public MinMaxInt(int min, int max) + public MinMax(T min, T max) { Min = min; Max = max; } - public MinMaxInt() + public MinMax() { } @@ -22,14 +22,14 @@ public record MinMaxInt } [JsonPropertyName("max")] - public int? Max + public T Max { get; set; } [JsonPropertyName("min")] - public int? Min + public T Min { get; set; diff --git a/Libraries/Core/Models/Common/MinMaxDouble.cs b/Libraries/Core/Models/Common/MinMaxDouble.cs deleted file mode 100644 index 2090632b..00000000 --- a/Libraries/Core/Models/Common/MinMaxDouble.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System.Text.Json.Serialization; - -namespace Core.Models.Common; - -public record MinMaxDouble -{ - public MinMaxDouble(double min, double max) - { - Min = min; - Max = max; - } - - public MinMaxDouble() - { - } - - [JsonPropertyName("type")] - public string? Type - { - get; - set; - } - - [JsonPropertyName("max")] - public double? Max - { - get; - set; - } - - [JsonPropertyName("min")] - public double? Min - { - get; - set; - } -} diff --git a/Libraries/Core/Models/Eft/Common/LocationBase.cs b/Libraries/Core/Models/Eft/Common/LocationBase.cs index f2c603de..76df7d41 100644 --- a/Libraries/Core/Models/Eft/Common/LocationBase.cs +++ b/Libraries/Core/Models/Eft/Common/LocationBase.cs @@ -870,7 +870,7 @@ public record NonWaveGroupScenario } } -public record Limit : MinMaxDouble +public record Limit : MinMax { [JsonPropertyName("items")] public object[] Items @@ -1383,7 +1383,7 @@ public record ChancedEnemy } } -public record MinMaxBot : MinMaxDouble +public record MinMaxBot : MinMax { [JsonPropertyName("WildSpawnType")] public string? WildSpawnType diff --git a/Libraries/Core/Models/Eft/Common/Tables/BotType.cs b/Libraries/Core/Models/Eft/Common/Tables/BotType.cs index a133dfb3..674031e3 100644 --- a/Libraries/Core/Models/Eft/Common/Tables/BotType.cs +++ b/Libraries/Core/Models/Eft/Common/Tables/BotType.cs @@ -446,7 +446,7 @@ public record Experience } [JsonPropertyName("level")] - public MinMaxDouble? Level + public MinMax? Level { get; set; @@ -456,7 +456,7 @@ public record Experience * key = bot difficulty */ [JsonPropertyName("reward")] - public Dictionary? Reward + public Dictionary>? Reward { get; set; @@ -616,19 +616,19 @@ public record BotTypeHealth set; } - public MinMaxDouble? Energy + public MinMax? Energy { get; set; } - public MinMaxDouble? Hydration + public MinMax? Hydration { get; set; } - public MinMaxDouble? Temperature + public MinMax? Temperature { get; set; @@ -637,43 +637,43 @@ public record BotTypeHealth public record BodyPart { - public MinMaxDouble? Chest + public MinMax? Chest { get; set; } - public MinMaxDouble? Head + public MinMax? Head { get; set; } - public MinMaxDouble? LeftArm + public MinMax? LeftArm { get; set; } - public MinMaxDouble? LeftLeg + public MinMax? LeftLeg { get; set; } - public MinMaxDouble? RightArm + public MinMax? RightArm { get; set; } - public MinMaxDouble? RightLeg + public MinMax? RightLeg { get; set; } - public MinMaxDouble? Stomach + public MinMax? Stomach { get; set; @@ -832,13 +832,13 @@ public record ItemPools public record BotDbSkills { - public Dictionary? Common + public Dictionary>? Common { get; set; } - public Dictionary? Mastering + public Dictionary>? Mastering { get; set; diff --git a/Libraries/Core/Models/Eft/Hideout/HideoutProduction.cs b/Libraries/Core/Models/Eft/Hideout/HideoutProduction.cs index 2f2eca50..15300878 100644 --- a/Libraries/Core/Models/Eft/Hideout/HideoutProduction.cs +++ b/Libraries/Core/Models/Eft/Hideout/HideoutProduction.cs @@ -232,21 +232,21 @@ public record ScavRecipe public record EndProducts { [JsonPropertyName("Common")] - public MinMaxDouble? Common + public MinMax? Common { get; set; } [JsonPropertyName("Rare")] - public MinMaxDouble? Rare + public MinMax? Rare { get; set; } [JsonPropertyName("Superrare")] - public MinMaxDouble? Superrare + public MinMax? Superrare { get; set; diff --git a/Libraries/Core/Models/Eft/Ragfair/GetItemPriceResult.cs b/Libraries/Core/Models/Eft/Ragfair/GetItemPriceResult.cs index f427c289..468d9ac1 100644 --- a/Libraries/Core/Models/Eft/Ragfair/GetItemPriceResult.cs +++ b/Libraries/Core/Models/Eft/Ragfair/GetItemPriceResult.cs @@ -3,7 +3,7 @@ using Core.Models.Common; namespace Core.Models.Eft.Ragfair; -public record GetItemPriceResult : MinMaxDouble +public record GetItemPriceResult : MinMax { [JsonPropertyName("avg")] public double? Avg diff --git a/Libraries/Core/Models/Spt/Bots/BotGenerationDetails.cs b/Libraries/Core/Models/Spt/Bots/BotGenerationDetails.cs index 6d1c2e64..f18227d6 100644 --- a/Libraries/Core/Models/Spt/Bots/BotGenerationDetails.cs +++ b/Libraries/Core/Models/Spt/Bots/BotGenerationDetails.cs @@ -39,7 +39,7 @@ public record BotGenerationDetails /// Active players current level /// [JsonPropertyName("playerLevel")] - public double? PlayerLevel + public int? PlayerLevel { get; set; @@ -56,7 +56,7 @@ public record BotGenerationDetails /// Level specific overrides for PMC level /// [JsonPropertyName("locationSpecificPmcLevelOverride")] - public MinMaxDouble? LocationSpecificPmcLevelOverride + public MinMax LocationSpecificPmcLevelOverride { get; set; @@ -66,7 +66,7 @@ public record BotGenerationDetails /// Delta of highest level of bot e.g. 50 means 50 levels above player /// [JsonPropertyName("botRelativeLevelDeltaMax")] - public double? BotRelativeLevelDeltaMax + public int? BotRelativeLevelDeltaMax { get; set; @@ -76,7 +76,7 @@ public record BotGenerationDetails /// Delta of lowest level of bot e.g. 50 means 50 levels below player /// [JsonPropertyName("botRelativeLevelDeltaMin")] - public double? BotRelativeLevelDeltaMin + public int? BotRelativeLevelDeltaMin { get; set; diff --git a/Libraries/Core/Models/Spt/Config/AirdropConfig.cs b/Libraries/Core/Models/Spt/Config/AirdropConfig.cs index 12c9078b..348f45fc 100644 --- a/Libraries/Core/Models/Spt/Config/AirdropConfig.cs +++ b/Libraries/Core/Models/Spt/Config/AirdropConfig.cs @@ -117,7 +117,7 @@ public record AirdropLoot /// Min/max of weapons inside crate /// [JsonPropertyName("weaponPresetCount")] - public MinMaxInt? WeaponPresetCount + public MinMax? WeaponPresetCount { get; set; @@ -127,7 +127,7 @@ public record AirdropLoot /// Min/max of armors (head/chest/rig) inside crate /// [JsonPropertyName("armorPresetCount")] - public MinMaxInt? ArmorPresetCount + public MinMax? ArmorPresetCount { get; set; @@ -137,7 +137,7 @@ public record AirdropLoot /// Min/max of items inside crate /// [JsonPropertyName("itemCount")] - public MinMaxInt ItemCount + public MinMax ItemCount { get; set; @@ -147,7 +147,7 @@ public record AirdropLoot /// Min/max of sealed weapon boxes inside crate /// [JsonPropertyName("weaponCrateCount")] - public MinMaxInt WeaponCrateCount + public MinMax WeaponCrateCount { get; set; @@ -187,7 +187,7 @@ public record AirdropLoot /// Items to limit stack size of key: item tpl value: min/max stack size /// [JsonPropertyName("itemStackLimits")] - public Dictionary ItemStackLimits + public Dictionary> ItemStackLimits { get; set; @@ -221,7 +221,7 @@ public record AirdropLoot } [JsonPropertyName("forcedLoot")] - public Dictionary? ForcedLoot + public Dictionary>? ForcedLoot { get; set; diff --git a/Libraries/Core/Models/Spt/Config/BotConfig.cs b/Libraries/Core/Models/Spt/Config/BotConfig.cs index b890e871..9846d903 100644 --- a/Libraries/Core/Models/Spt/Config/BotConfig.cs +++ b/Libraries/Core/Models/Spt/Config/BotConfig.cs @@ -251,7 +251,7 @@ public record AssaultToBossConversion } [JsonPropertyName("bossConvertMinMax")] - public Dictionary BossConvertMinMax + public Dictionary> BossConvertMinMax { get; set; @@ -599,7 +599,7 @@ public record WalletLootSettings } [JsonPropertyName("itemCount")] - public MinMaxDouble ItemCount + public MinMax ItemCount { get; set; @@ -843,7 +843,7 @@ public record RandomisationDetails /// Between what levels do these randomisation setting apply to /// [JsonPropertyName("levelRange")] - public MinMaxDouble LevelRange + public MinMax LevelRange { get; set; @@ -950,7 +950,7 @@ public record EquipmentFilterDetails /// Between what levels do these equipment filter setting apply to /// [JsonPropertyName("levelRange")] - public MinMaxDouble LevelRange + public MinMax LevelRange { get; set; @@ -993,7 +993,7 @@ public record WeightingAdjustmentDetails /// Between what levels do these weight settings apply to /// [JsonPropertyName("levelRange")] - public MinMaxDouble LevelRange + public MinMax LevelRange { get; set; @@ -1050,7 +1050,7 @@ public record AdjustmentDetails public class ArmorPlateWeights { [JsonPropertyName("levelRange")] - public MinMaxDouble LevelRange + public MinMax LevelRange { get; set; diff --git a/Libraries/Core/Models/Spt/Config/HideoutConfig.cs b/Libraries/Core/Models/Spt/Config/HideoutConfig.cs index e37c30f5..a961245c 100644 --- a/Libraries/Core/Models/Spt/Config/HideoutConfig.cs +++ b/Libraries/Core/Models/Spt/Config/HideoutConfig.cs @@ -127,7 +127,7 @@ public record CultistCircleSettings } [JsonPropertyName("rewardPriceMultiplerMinMax")] - public MinMaxDouble RewardPriceMultiplerMinMax + public MinMax RewardPriceMultiplerMinMax { get; set; @@ -211,7 +211,7 @@ public record CultistCircleSettings /// Overrides for reward stack sizes, keyed by item tpl /// [JsonPropertyName("directRewardStackSize")] - public Dictionary DirectRewardStackSize + public Dictionary> DirectRewardStackSize { get; set; @@ -238,14 +238,14 @@ public record CultistCircleSettings } [JsonPropertyName("currencyRewards")] - public Dictionary CurrencyRewards + public Dictionary> CurrencyRewards { get; set; } } -public record CraftTimeThreshold : MinMaxDouble +public record CraftTimeThreshold : MinMax { [JsonPropertyName("craftTimeSeconds")] public int CraftTimeSeconds diff --git a/Libraries/Core/Models/Spt/Config/InventoryConfig.cs b/Libraries/Core/Models/Spt/Config/InventoryConfig.cs index 46bbe6fc..5610a43a 100644 --- a/Libraries/Core/Models/Spt/Config/InventoryConfig.cs +++ b/Libraries/Core/Models/Spt/Config/InventoryConfig.cs @@ -132,14 +132,14 @@ public record SealedAirdropContainerSettings } [JsonPropertyName("weaponModRewardLimits")] - public Dictionary WeaponModRewardLimits + public Dictionary> WeaponModRewardLimits { get; set; } [JsonPropertyName("rewardTypeLimits")] - public Dictionary RewardTypeLimits + public Dictionary> RewardTypeLimits { get; set; diff --git a/Libraries/Core/Models/Spt/Config/LocationConfig.cs b/Libraries/Core/Models/Spt/Config/LocationConfig.cs index 3bd45809..536c3e0a 100644 --- a/Libraries/Core/Models/Spt/Config/LocationConfig.cs +++ b/Libraries/Core/Models/Spt/Config/LocationConfig.cs @@ -341,7 +341,7 @@ public record CustomWaves } } -public record BotTypeLimit : MinMaxDouble +public record BotTypeLimit : MinMax { [JsonPropertyName("type")] public string Type diff --git a/Libraries/Core/Models/Spt/Config/PmcConfig.cs b/Libraries/Core/Models/Spt/Config/PmcConfig.cs index 244fe80f..fe4fb990 100644 --- a/Libraries/Core/Models/Spt/Config/PmcConfig.cs +++ b/Libraries/Core/Models/Spt/Config/PmcConfig.cs @@ -115,7 +115,7 @@ public record PmcConfig : BaseConfig * MinMax count of weapons to have in backpack */ [JsonPropertyName("looseWeaponInBackpackLootMinMax")] - public MinMaxDouble LooseWeaponInBackpackLootMinMax + public MinMax LooseWeaponInBackpackLootMinMax { get; set; @@ -200,7 +200,7 @@ public record PmcConfig : BaseConfig * Percentage chance a bot from a wave is converted into a PMC, first key = map, second key = bot wildspawn type (assault/exusec), value: min+max chance to be converted */ [JsonPropertyName("convertIntoPmcChance")] - public Dictionary> ConvertIntoPmcChance + public Dictionary>> ConvertIntoPmcChance { get; set; @@ -210,7 +210,7 @@ public record PmcConfig : BaseConfig * How many levels above player level can a PMC be */ [JsonPropertyName("botRelativeLevelDeltaMax")] - public double BotRelativeLevelDeltaMax + public int BotRelativeLevelDeltaMax { get; set; @@ -220,7 +220,7 @@ public record PmcConfig : BaseConfig * How many levels below player level can a PMC be */ [JsonPropertyName("botRelativeLevelDeltaMin")] - public double BotRelativeLevelDeltaMin + public int BotRelativeLevelDeltaMin { get; set; @@ -251,7 +251,7 @@ public record PmcConfig : BaseConfig } [JsonPropertyName("locationSpecificPmcLevelOverride")] - public Dictionary LocationSpecificPmcLevelOverride + public Dictionary> LocationSpecificPmcLevelOverride { get; set; @@ -383,7 +383,7 @@ public record SlotLootSettings } } -public record MinMaxLootValue : MinMaxDouble +public record MinMaxLootValue : MinMax { [JsonPropertyName("value")] public double Value @@ -393,24 +393,24 @@ public record MinMaxLootValue : MinMaxDouble } } -public record MinMaxLootItemValue : MinMaxDouble +public record MinMaxLootItemValue : MinMax { [JsonPropertyName("backpack")] - public MinMaxDouble Backpack + public MinMax Backpack { get; set; } [JsonPropertyName("pocket")] - public MinMaxDouble Pocket + public MinMax Pocket { get; set; } [JsonPropertyName("vest")] - public MinMaxDouble Vest + public MinMax Vest { get; set; diff --git a/Libraries/Core/Models/Spt/Config/QuestConfig.cs b/Libraries/Core/Models/Spt/Config/QuestConfig.cs index e84418b2..0bc28ad9 100644 --- a/Libraries/Core/Models/Spt/Config/QuestConfig.cs +++ b/Libraries/Core/Models/Spt/Config/QuestConfig.cs @@ -596,7 +596,7 @@ public record PickupTypeWithMaxCount public record EliminationConfig : BaseQuestConfig { [JsonPropertyName("levelRange")] - public MinMaxDouble? LevelRange + public MinMax? LevelRange { get; set; diff --git a/Libraries/Core/Models/Spt/Config/RagfairConfig.cs b/Libraries/Core/Models/Spt/Config/RagfairConfig.cs index 57ea196d..a60e8a16 100644 --- a/Libraries/Core/Models/Spt/Config/RagfairConfig.cs +++ b/Libraries/Core/Models/Spt/Config/RagfairConfig.cs @@ -93,7 +93,7 @@ public record Sell * Settings to control how long it takes for a player offer to sell */ [JsonPropertyName("time")] - public MinMaxDouble Time + public MinMax Time { get; set; @@ -204,7 +204,7 @@ public record Dynamic [JsonPropertyName("offerItemCount")] /** How many offers should be listed */ - public MinMaxDouble OfferItemCount + public MinMax OfferItemCount { get; set; @@ -235,7 +235,7 @@ public record Dynamic } [JsonPropertyName("endTimeSeconds")] - public MinMaxDouble EndTimeSeconds + public MinMax EndTimeSeconds { get; set; @@ -251,7 +251,7 @@ public record Dynamic [JsonPropertyName("stackablePercent")] /** Size stackable items should be listed for in percent of max stack size */ - public MinMaxDouble StackablePercent + public MinMax StackablePercent { get; set; @@ -259,7 +259,7 @@ public record Dynamic [JsonPropertyName("nonStackableCount")] /** Items that cannot be stacked can have multiples sold in one offer, what range of values can be listed */ - public MinMaxDouble NonStackableCount + public MinMax NonStackableCount { get; set; @@ -267,7 +267,7 @@ public record Dynamic [JsonPropertyName("rating")] /** Range of rating offers for items being listed */ - public MinMaxDouble Rating + public MinMax Rating { get; set; @@ -348,21 +348,21 @@ public record Dynamic public record PriceRanges { [JsonPropertyName("default")] - public MinMaxDouble Default + public MinMax Default { get; set; } [JsonPropertyName("preset")] - public MinMaxDouble Preset + public MinMax Preset { get; set; } [JsonPropertyName("pack")] - public MinMaxDouble Pack + public MinMax Pack { get; set; @@ -541,14 +541,14 @@ public record Condition } [JsonPropertyName("current")] - public MinMaxDouble Current + public MinMax Current { get; set; } [JsonPropertyName("max")] - public MinMaxDouble Max + public MinMax Max { get; set; diff --git a/Libraries/Core/Models/Spt/Config/RepairConfig.cs b/Libraries/Core/Models/Spt/Config/RepairConfig.cs index 704b206f..87585a79 100644 --- a/Libraries/Core/Models/Spt/Config/RepairConfig.cs +++ b/Libraries/Core/Models/Spt/Config/RepairConfig.cs @@ -219,7 +219,7 @@ public record BonusSettings public record BonusValues { [JsonPropertyName("valuesMinMax")] - public MinMaxDouble ValuesMinMax + public MinMax ValuesMinMax { get; set; @@ -229,7 +229,7 @@ public record BonusValues * What dura is buff active between (min max of current max) */ [JsonPropertyName("activeDurabilityPercentMinMax")] - public MinMaxDouble ActiveDurabilityPercentMinMax + public MinMax ActiveDurabilityPercentMinMax { get; set; diff --git a/Libraries/Core/Models/Spt/Config/ScavCaseConfig.cs b/Libraries/Core/Models/Spt/Config/ScavCaseConfig.cs index a3bb1965..000957ae 100644 --- a/Libraries/Core/Models/Spt/Config/ScavCaseConfig.cs +++ b/Libraries/Core/Models/Spt/Config/ScavCaseConfig.cs @@ -13,7 +13,7 @@ public record ScavCaseConfig : BaseConfig } = "spt-scavcase"; [JsonPropertyName("rewardItemValueRangeRub")] - public Dictionary RewardItemValueRangeRub + public Dictionary> RewardItemValueRangeRub { get; set; @@ -110,21 +110,21 @@ public record MoneyRewards public record MoneyLevels { [JsonPropertyName("common")] - public MinMaxDouble Common + public MinMax Common { get; set; } [JsonPropertyName("rare")] - public MinMaxDouble Rare + public MinMax Rare { get; set; } [JsonPropertyName("superrare")] - public MinMaxDouble SuperRare + public MinMax SuperRare { get; set; @@ -148,7 +148,7 @@ public record AmmoRewards } [JsonPropertyName("ammoRewardValueRangeRub")] - public Dictionary AmmoRewardValueRangeRub + public Dictionary> AmmoRewardValueRangeRub { get; set; diff --git a/Libraries/Core/Models/Spt/Config/TraderConfig.cs b/Libraries/Core/Models/Spt/Config/TraderConfig.cs index ad2fad45..1fd89cd6 100644 --- a/Libraries/Core/Models/Spt/Config/TraderConfig.cs +++ b/Libraries/Core/Models/Spt/Config/TraderConfig.cs @@ -86,7 +86,7 @@ public record UpdateTime * Seconds between trader resets */ [JsonPropertyName("seconds")] - public MinMaxDouble Seconds + public MinMax Seconds { get; set; @@ -124,14 +124,14 @@ public record FenceConfig } [JsonPropertyName("weaponPresetMinMax")] - public MinMaxDouble WeaponPresetMinMax + public MinMax WeaponPresetMinMax { get; set; } [JsonPropertyName("equipmentPresetMinMax")] - public MinMaxDouble EquipmentPresetMinMax + public MinMax EquipmentPresetMinMax { get; set; @@ -179,7 +179,7 @@ public record FenceConfig * Key: item tpl */ [JsonPropertyName("itemStackSizeOverrideMinMax")] - public Dictionary ItemStackSizeOverrideMinMax + public Dictionary?> ItemStackSizeOverrideMinMax { get; set; @@ -294,14 +294,14 @@ public record FenceConfig public record ItemDurabilityCurrentMax { [JsonPropertyName("current")] - public MinMaxDouble Current + public MinMax Current { get; set; } [JsonPropertyName("max")] - public MinMaxDouble Max + public MinMax Max { get; set; @@ -363,14 +363,14 @@ public record DiscountOptions } [JsonPropertyName("weaponPresetMinMax")] - public MinMaxDouble WeaponPresetMinMax + public MinMax WeaponPresetMinMax { get; set; } [JsonPropertyName("equipmentPresetMinMax")] - public MinMaxDouble EquipmentPresetMinMax + public MinMax EquipmentPresetMinMax { get; set; diff --git a/Libraries/Core/Models/Spt/Config/WeatherConfig.cs b/Libraries/Core/Models/Spt/Config/WeatherConfig.cs index 6ff11611..4ce5ef79 100644 --- a/Libraries/Core/Models/Spt/Config/WeatherConfig.cs +++ b/Libraries/Core/Models/Spt/Config/WeatherConfig.cs @@ -146,7 +146,7 @@ public record SeasonalValues } [JsonPropertyName("windGustiness")] - public MinMaxDouble? WindGustiness + public MinMax? WindGustiness { get; set; @@ -160,7 +160,7 @@ public record SeasonalValues } [JsonPropertyName("rainIntensity")] - public MinMaxDouble? RainIntensity + public MinMax? RainIntensity { get; set; @@ -181,7 +181,7 @@ public record SeasonalValues } [JsonPropertyName("pressure")] - public MinMaxDouble? Pressure + public MinMax? Pressure { get; set; @@ -191,14 +191,14 @@ public record SeasonalValues public record TempDayNight { [JsonPropertyName("day")] - public MinMaxDouble? Day + public MinMax? Day { get; set; } [JsonPropertyName("night")] - public MinMaxDouble? Night + public MinMax? Night { get; set; diff --git a/Libraries/Core/Models/Spt/Services/LootRequest.cs b/Libraries/Core/Models/Spt/Services/LootRequest.cs index a5bf0ef4..5b1ddf04 100644 --- a/Libraries/Core/Models/Spt/Services/LootRequest.cs +++ b/Libraries/Core/Models/Spt/Services/LootRequest.cs @@ -10,7 +10,7 @@ public record LootRequest /// Count of weapons to generate /// [JsonPropertyName("weaponPresetCount")] - public MinMaxInt? WeaponPresetCount + public MinMax? WeaponPresetCount { get; set; @@ -20,7 +20,7 @@ public record LootRequest /// Count of armor to generate /// [JsonPropertyName("armorPresetCount")] - public MinMaxInt? ArmorPresetCount + public MinMax? ArmorPresetCount { get; set; @@ -30,7 +30,7 @@ public record LootRequest /// Count of items to generate /// [JsonPropertyName("itemCount")] - public MinMaxInt? ItemCount + public MinMax? ItemCount { get; set; @@ -40,7 +40,7 @@ public record LootRequest /// Count of sealed weapon crates to generate /// [JsonPropertyName("weaponCrateCount")] - public MinMaxInt? WeaponCrateCount + public MinMax? WeaponCrateCount { get; set; @@ -77,7 +77,7 @@ public record LootRequest } [JsonPropertyName("itemStackLimits")] - public Dictionary? ItemStackLimits + public Dictionary>? ItemStackLimits { get; set; @@ -127,7 +127,7 @@ public record LootRequest /// Item tpls + count of items to force include /// [JsonPropertyName("forcedLoot")] - public Dictionary? ForcedLoot + public Dictionary>? ForcedLoot { get; set; diff --git a/Libraries/Core/Services/BotLootCacheService.cs b/Libraries/Core/Services/BotLootCacheService.cs index 60efad75..03699ab2 100644 --- a/Libraries/Core/Services/BotLootCacheService.cs +++ b/Libraries/Core/Services/BotLootCacheService.cs @@ -47,7 +47,7 @@ public class BotLootCacheService( bool isPmc, string lootType, BotType botJsonTemplate, - MinMaxDouble? itemPriceMinMax = null) + MinMax? itemPriceMinMax = null) { lock (_lock) { diff --git a/Libraries/Core/Services/CircleOfCultistService.cs b/Libraries/Core/Services/CircleOfCultistService.cs index c40ad343..161b597b 100644 --- a/Libraries/Core/Services/CircleOfCultistService.cs +++ b/Libraries/Core/Services/CircleOfCultistService.cs @@ -604,7 +604,7 @@ public class CircleOfCultistService( var settings = _hideoutConfig.CultistCircle.CurrencyRewards[itemTpl]; // What % of the pool remaining should be rewarded as chosen currency - var percentOfPoolToUse = _randomUtil.GetDouble(settings.Min.Value, settings.Max.Value); + var percentOfPoolToUse = _randomUtil.GetDouble(settings.Min, settings.Max); // Rouble amount of pool we want to reward as currency var roubleAmountToFill = _randomUtil.GetPercentOfValue(percentOfPoolToUse, rewardPoolRemaining); diff --git a/Libraries/Core/Services/FenceService.cs b/Libraries/Core/Services/FenceService.cs index 4d83720e..f8c2b6cb 100644 --- a/Libraries/Core/Services/FenceService.cs +++ b/Libraries/Core/Services/FenceService.cs @@ -1336,7 +1336,7 @@ public class FenceService( */ protected int GetSingleItemStackCount(TemplateItem itemDbDetails) { - MinMaxDouble? overrideValues; + MinMax? overrideValues; if (itemHelper.IsOfBaseclass(itemDbDetails.Id, BaseClasses.AMMO)) { overrideValues = traderConfig.Fence.ItemStackSizeOverrideMinMax[itemDbDetails.Parent]; diff --git a/Libraries/Core/Services/RagfairPriceService.cs b/Libraries/Core/Services/RagfairPriceService.cs index 3275e36c..4f6677fa 100644 --- a/Libraries/Core/Services/RagfairPriceService.cs +++ b/Libraries/Core/Services/RagfairPriceService.cs @@ -356,7 +356,7 @@ public class RagfairPriceService( /// Offer is a preset /// Offer is a pack /// MinMax values - protected MinMaxDouble GetOfferTypeRangeValues(bool isPreset, bool isPack) + protected MinMax GetOfferTypeRangeValues(bool isPreset, bool isPack) { // Use different min/max values if the item is a preset or pack var priceRanges = _ragfairConfig.Dynamic.PriceRanges; @@ -406,10 +406,10 @@ public class RagfairPriceService( /// price to alter /// min and max to adjust price by /// multiplied price - protected double RandomiseOfferPrice(double existingPrice, MinMaxDouble rangeValues) + protected double RandomiseOfferPrice(double existingPrice, MinMax rangeValues) { // Multiply by 100 to get 2 decimal places of precision - var multiplier = _randomUtil.GetBiasedRandomNumber(rangeValues.Min.Value * 100, rangeValues.Max.Value * 100, 2, 2); + var multiplier = _randomUtil.GetBiasedRandomNumber(rangeValues.Min * 100, rangeValues.Max * 100, 2, 2); // return multiplier back to its original decimal place location return existingPrice * (multiplier / 100); diff --git a/Libraries/Core/Services/RepairService.cs b/Libraries/Core/Services/RepairService.cs index 7b4f2456..1bc5a7b5 100644 --- a/Libraries/Core/Services/RepairService.cs +++ b/Libraries/Core/Services/RepairService.cs @@ -540,12 +540,12 @@ public class RepairService( var bonusRarity = bonusRarityName == "Rare" ? itemConfig.Rare : itemConfig.Common; var bonusValues = bonusRarity[bonusTypeName].ValuesMinMax; - var bonusValue = _randomUtil.GetDouble(bonusValues.Min.Value, bonusValues.Max.Value); + var bonusValue = _randomUtil.GetDouble(bonusValues.Min, bonusValues.Max); var bonusThresholdPercents = bonusRarity[bonusTypeName].ActiveDurabilityPercentMinMax; var bonusThresholdPercent = _randomUtil.GetDouble( - bonusThresholdPercents.Min.Value, - bonusThresholdPercents.Max.Value + bonusThresholdPercents.Min, + bonusThresholdPercents.Max ); item.Upd.Buff = new UpdBuff diff --git a/Libraries/Core/Services/TraderPurchasePersisterService.cs b/Libraries/Core/Services/TraderPurchasePersisterService.cs index 60d4518e..60d48b8e 100644 --- a/Libraries/Core/Services/TraderPurchasePersisterService.cs +++ b/Libraries/Core/Services/TraderPurchasePersisterService.cs @@ -145,7 +145,7 @@ public class TraderPurchasePersisterService( var purchaseDetails = purchaseKvP.Value; var resetTimeForItem = purchaseDetails.PurchaseTimestamp + - _randomUtil.GetDouble(traderUpdateDetails.Seconds.Min.Value, traderUpdateDetails.Seconds.Max.Value); + _randomUtil.GetDouble(traderUpdateDetails.Seconds.Min, traderUpdateDetails.Seconds.Max); if (resetTimeForItem < _timeUtil.GetTimeStamp()) { // Item was purchased far enough in past a trader refresh would have occured, remove purchase record from profile