Replaced minmaxdouble + minmaxint with generic minmax<T>

Updated various doubles to be ints
This commit is contained in:
Chomp
2025-02-10 10:44:24 +00:00
parent 08b5caf337
commit 3219718d27
39 changed files with 187 additions and 225 deletions
+4 -5
View File
@@ -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<double>? 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<int> GetPmcLevelRangeForMap(string? location)
{
return _pmcConfig.LocationSpecificPmcLevelOverride!.GetValueOrDefault(location?.ToLower() ?? "", null);
}
@@ -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<double>(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<RagfairOffer> offers, MinMaxDouble minMax, bool ignoreTraderOffers)
private double GetAveragePriceFromOffers(List<RagfairOffer> offers, MinMax<double> 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;
@@ -360,7 +360,7 @@ public class BotEquipmentModGenerator(
return result;
}
private MinMaxDouble GetMinMaxArmorPlateClass(List<TemplateItem> platePool)
private MinMax<int> GetMinMaxArmorPlateClass(List<TemplateItem> platePool)
{
platePool.Sort(
(x, y) =>
@@ -379,10 +379,10 @@ public class BotEquipmentModGenerator(
}
);
return new MinMaxDouble
return new MinMax<int>
{
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
};
}
+23 -23
View File
@@ -318,7 +318,7 @@ public class BotGenerator(
/// <param name="botDifficulty">the killed bots difficulty</param>
/// <param name="role">Role of bot (optional, used for error logging)</param>
/// <returns>Experience for kill</returns>
public double GetExperienceRewardForKillByDifficulty(Dictionary<string, MinMaxDouble> experiences, string botDifficulty, string role)
public double GetExperienceRewardForKillByDifficulty(Dictionary<string, MinMax<double>> 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);
}
/// <summary>
@@ -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<string, BodyPartHealth>
@@ -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<double>) prop.GetValue(bodyPart);
hpTotal += value.Max;
}
@@ -662,7 +662,7 @@ public class BotGenerator(
/// <param name="skills">Skills to randomise</param>
/// <param name="isCommonSkills">Are the skills 'common' skills</param>
/// <returns>Skills with randomised progress values as an array</returns>
public List<BaseSkill> GetSkillsWithRandomisedProgressValue(Dictionary<string, MinMaxDouble>? skills, bool isCommonSkills)
public List<BaseSkill> GetSkillsWithRandomisedProgressValue(Dictionary<string, MinMax<double>>? 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
@@ -24,7 +24,7 @@ public class BotLevelGenerator(
/// <param name="botGenerationDetails">Details to help generate a bot</param>
/// <param name="bot">Bot the level is being generated for</param>
/// <returns>IRandomisedBotLevelResult object</returns>
public RandomisedBotLevelResult GenerateBotLevel(MinMaxDouble levelDetails, BotGenerationDetails botGenerationDetails, BotBase bot)
public RandomisedBotLevelResult GenerateBotLevel(MinMax<int> 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(
/// <param name="levelDetails"></param>
/// <param name="maxAvailableLevel">Max level allowed</param>
/// <returns>A MinMax of the lowest and highest level to generate the bots</returns>
public MinMaxDouble GetRelativePmcBotLevelRange(BotGenerationDetails botGenerationDetails, MinMaxDouble levelDetails, int maxAvailableLevel)
public MinMax<int> GetRelativePmcBotLevelRange(BotGenerationDetails botGenerationDetails, MinMax<int> 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<int>(minLevel, maxLevel);
}
}
+11 -11
View File
@@ -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(
/// </summary>
/// <param name="forcedLootDict">Dictionary of item tpls with minmax values</param>
/// <returns>Array of Item</returns>
public List<Item> CreateForcedLoot(Dictionary<string, MinMaxInt> forcedLootDict)
public List<Item> CreateForcedLoot(Dictionary<string, MinMax<int>> forcedLootDict)
{
var result = new List<Item>();
@@ -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)
@@ -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) {
@@ -464,20 +464,20 @@ public class ScavCaseRewardGenerator(
amountToGive = itemToCalculate.Id switch
{
Money.ROUBLES => _randomUtil.GetInt(
(int) _scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp<MinMaxDouble>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp<MinMaxDouble>(rarity).Max
_scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp<MinMax<int>>(rarity).Min,
_scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp<MinMax<int>>(rarity).Max
),
Money.EUROS => _randomUtil.GetInt(
(int) _scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp<MinMaxDouble>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp<MinMaxDouble>(rarity).Max
_scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp<MinMax<int>>(rarity).Min,
_scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp<MinMax<int>>(rarity).Max
),
Money.DOLLARS => _randomUtil.GetInt(
(int) _scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp<MinMaxDouble>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp<MinMaxDouble>(rarity).Max
_scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp<MinMax<int>>(rarity).Min,
_scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp<MinMax<int>>(rarity).Max
),
Money.GP => _randomUtil.GetInt(
(int) _scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp<MinMaxDouble>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp<MinMaxDouble>(rarity).Max
_scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp<MinMax<int>>(rarity).Min,
_scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp<MinMax<int>>(rarity).Max
),
_ => amountToGive
};
@@ -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);
}
/**
+4 -4
View File
@@ -112,17 +112,17 @@ public class BotHelper(
}
}
public bool RollChanceToBePmc(MinMaxDouble botConvertMinMax)
public bool RollChanceToBePmc(MinMax<double> botConvertMinMax)
{
return _randomUtil.GetChance100(_randomUtil.GetDouble(botConvertMinMax.Min.Value, botConvertMinMax.Max.Value));
return _randomUtil.GetChance100(_randomUtil.GetDouble(botConvertMinMax.Min, botConvertMinMax.Max));
}
protected Dictionary<string, MinMaxDouble> GetPmcConversionValuesForLocation(string location)
protected Dictionary<string, MinMax<double>> GetPmcConversionValuesForLocation(string location)
{
var result = _pmcConfig.ConvertIntoPmcChance[location.ToLower()];
if (result is null)
{
_pmcConfig.ConvertIntoPmcChance = new Dictionary<string, Dictionary<string, MinMaxDouble>>();
_pmcConfig.ConvertIntoPmcChance = new Dictionary<string, Dictionary<string, MinMax<double>>>();
}
return result;
+3 -3
View File
@@ -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
{
@@ -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);
+2 -2
View File
@@ -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<int>(_traderConfig.UpdateTimeDefault, _traderConfig.UpdateTimeDefault)
}
);
@@ -2,15 +2,15 @@ using System.Text.Json.Serialization;
namespace Core.Models.Common;
public record MinMaxInt
public record MinMax<T>
{
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;
@@ -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;
}
}
@@ -870,7 +870,7 @@ public record NonWaveGroupScenario
}
}
public record Limit : MinMaxDouble
public record Limit : MinMax<int>
{
[JsonPropertyName("items")]
public object[] Items
@@ -1383,7 +1383,7 @@ public record ChancedEnemy
}
}
public record MinMaxBot : MinMaxDouble
public record MinMaxBot : MinMax<int>
{
[JsonPropertyName("WildSpawnType")]
public string? WildSpawnType
@@ -446,7 +446,7 @@ public record Experience
}
[JsonPropertyName("level")]
public MinMaxDouble? Level
public MinMax<int>? Level
{
get;
set;
@@ -456,7 +456,7 @@ public record Experience
* key = bot difficulty
*/
[JsonPropertyName("reward")]
public Dictionary<string, MinMaxDouble>? Reward
public Dictionary<string, MinMax<double>>? Reward
{
get;
set;
@@ -616,19 +616,19 @@ public record BotTypeHealth
set;
}
public MinMaxDouble? Energy
public MinMax<double>? Energy
{
get;
set;
}
public MinMaxDouble? Hydration
public MinMax<double>? Hydration
{
get;
set;
}
public MinMaxDouble? Temperature
public MinMax<double>? Temperature
{
get;
set;
@@ -637,43 +637,43 @@ public record BotTypeHealth
public record BodyPart
{
public MinMaxDouble? Chest
public MinMax<double>? Chest
{
get;
set;
}
public MinMaxDouble? Head
public MinMax<double>? Head
{
get;
set;
}
public MinMaxDouble? LeftArm
public MinMax<double>? LeftArm
{
get;
set;
}
public MinMaxDouble? LeftLeg
public MinMax<double>? LeftLeg
{
get;
set;
}
public MinMaxDouble? RightArm
public MinMax<double>? RightArm
{
get;
set;
}
public MinMaxDouble? RightLeg
public MinMax<double>? RightLeg
{
get;
set;
}
public MinMaxDouble? Stomach
public MinMax<double>? Stomach
{
get;
set;
@@ -832,13 +832,13 @@ public record ItemPools
public record BotDbSkills
{
public Dictionary<string, MinMaxDouble>? Common
public Dictionary<string, MinMax<double>>? Common
{
get;
set;
}
public Dictionary<string, MinMaxDouble>? Mastering
public Dictionary<string, MinMax<double>>? Mastering
{
get;
set;
@@ -232,21 +232,21 @@ public record ScavRecipe
public record EndProducts
{
[JsonPropertyName("Common")]
public MinMaxDouble? Common
public MinMax<int>? Common
{
get;
set;
}
[JsonPropertyName("Rare")]
public MinMaxDouble? Rare
public MinMax<int>? Rare
{
get;
set;
}
[JsonPropertyName("Superrare")]
public MinMaxDouble? Superrare
public MinMax<int>? Superrare
{
get;
set;
@@ -3,7 +3,7 @@ using Core.Models.Common;
namespace Core.Models.Eft.Ragfair;
public record GetItemPriceResult : MinMaxDouble
public record GetItemPriceResult : MinMax<double>
{
[JsonPropertyName("avg")]
public double? Avg
@@ -39,7 +39,7 @@ public record BotGenerationDetails
/// Active players current level
/// </summary>
[JsonPropertyName("playerLevel")]
public double? PlayerLevel
public int? PlayerLevel
{
get;
set;
@@ -56,7 +56,7 @@ public record BotGenerationDetails
/// Level specific overrides for PMC level
/// </summary>
[JsonPropertyName("locationSpecificPmcLevelOverride")]
public MinMaxDouble? LocationSpecificPmcLevelOverride
public MinMax<int> LocationSpecificPmcLevelOverride
{
get;
set;
@@ -66,7 +66,7 @@ public record BotGenerationDetails
/// Delta of highest level of bot e.g. 50 means 50 levels above player
/// </summary>
[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
/// </summary>
[JsonPropertyName("botRelativeLevelDeltaMin")]
public double? BotRelativeLevelDeltaMin
public int? BotRelativeLevelDeltaMin
{
get;
set;
@@ -117,7 +117,7 @@ public record AirdropLoot
/// Min/max of weapons inside crate
/// </summary>
[JsonPropertyName("weaponPresetCount")]
public MinMaxInt? WeaponPresetCount
public MinMax<int>? WeaponPresetCount
{
get;
set;
@@ -127,7 +127,7 @@ public record AirdropLoot
/// Min/max of armors (head/chest/rig) inside crate
/// </summary>
[JsonPropertyName("armorPresetCount")]
public MinMaxInt? ArmorPresetCount
public MinMax<int>? ArmorPresetCount
{
get;
set;
@@ -137,7 +137,7 @@ public record AirdropLoot
/// Min/max of items inside crate
/// </summary>
[JsonPropertyName("itemCount")]
public MinMaxInt ItemCount
public MinMax<int> ItemCount
{
get;
set;
@@ -147,7 +147,7 @@ public record AirdropLoot
/// Min/max of sealed weapon boxes inside crate
/// </summary>
[JsonPropertyName("weaponCrateCount")]
public MinMaxInt WeaponCrateCount
public MinMax<int> WeaponCrateCount
{
get;
set;
@@ -187,7 +187,7 @@ public record AirdropLoot
/// Items to limit stack size of key: item tpl value: min/max stack size
/// </summary>
[JsonPropertyName("itemStackLimits")]
public Dictionary<string, MinMaxInt> ItemStackLimits
public Dictionary<string, MinMax<int>> ItemStackLimits
{
get;
set;
@@ -221,7 +221,7 @@ public record AirdropLoot
}
[JsonPropertyName("forcedLoot")]
public Dictionary<string, MinMaxInt>? ForcedLoot
public Dictionary<string, MinMax<int>>? ForcedLoot
{
get;
set;
@@ -251,7 +251,7 @@ public record AssaultToBossConversion
}
[JsonPropertyName("bossConvertMinMax")]
public Dictionary<string, MinMaxDouble> BossConvertMinMax
public Dictionary<string, MinMax<double>> BossConvertMinMax
{
get;
set;
@@ -599,7 +599,7 @@ public record WalletLootSettings
}
[JsonPropertyName("itemCount")]
public MinMaxDouble ItemCount
public MinMax<int> ItemCount
{
get;
set;
@@ -843,7 +843,7 @@ public record RandomisationDetails
/// Between what levels do these randomisation setting apply to
/// </summary>
[JsonPropertyName("levelRange")]
public MinMaxDouble LevelRange
public MinMax<int> LevelRange
{
get;
set;
@@ -950,7 +950,7 @@ public record EquipmentFilterDetails
/// Between what levels do these equipment filter setting apply to
/// </summary>
[JsonPropertyName("levelRange")]
public MinMaxDouble LevelRange
public MinMax<int> LevelRange
{
get;
set;
@@ -993,7 +993,7 @@ public record WeightingAdjustmentDetails
/// Between what levels do these weight settings apply to
/// </summary>
[JsonPropertyName("levelRange")]
public MinMaxDouble LevelRange
public MinMax<int> LevelRange
{
get;
set;
@@ -1050,7 +1050,7 @@ public record AdjustmentDetails
public class ArmorPlateWeights
{
[JsonPropertyName("levelRange")]
public MinMaxDouble LevelRange
public MinMax<int> LevelRange
{
get;
set;
@@ -127,7 +127,7 @@ public record CultistCircleSettings
}
[JsonPropertyName("rewardPriceMultiplerMinMax")]
public MinMaxDouble RewardPriceMultiplerMinMax
public MinMax<double> RewardPriceMultiplerMinMax
{
get;
set;
@@ -211,7 +211,7 @@ public record CultistCircleSettings
/// Overrides for reward stack sizes, keyed by item tpl
/// </summary>
[JsonPropertyName("directRewardStackSize")]
public Dictionary<string, MinMaxDouble> DirectRewardStackSize
public Dictionary<string, MinMax<int>> DirectRewardStackSize
{
get;
set;
@@ -238,14 +238,14 @@ public record CultistCircleSettings
}
[JsonPropertyName("currencyRewards")]
public Dictionary<string, MinMaxDouble> CurrencyRewards
public Dictionary<string, MinMax<int>> CurrencyRewards
{
get;
set;
}
}
public record CraftTimeThreshold : MinMaxDouble
public record CraftTimeThreshold : MinMax<int>
{
[JsonPropertyName("craftTimeSeconds")]
public int CraftTimeSeconds
@@ -132,14 +132,14 @@ public record SealedAirdropContainerSettings
}
[JsonPropertyName("weaponModRewardLimits")]
public Dictionary<string, MinMaxInt> WeaponModRewardLimits
public Dictionary<string, MinMax<int>> WeaponModRewardLimits
{
get;
set;
}
[JsonPropertyName("rewardTypeLimits")]
public Dictionary<string, MinMaxInt> RewardTypeLimits
public Dictionary<string, MinMax<int>> RewardTypeLimits
{
get;
set;
@@ -341,7 +341,7 @@ public record CustomWaves
}
}
public record BotTypeLimit : MinMaxDouble
public record BotTypeLimit : MinMax<int>
{
[JsonPropertyName("type")]
public string Type
+10 -10
View File
@@ -115,7 +115,7 @@ public record PmcConfig : BaseConfig
* MinMax count of weapons to have in backpack
*/
[JsonPropertyName("looseWeaponInBackpackLootMinMax")]
public MinMaxDouble LooseWeaponInBackpackLootMinMax
public MinMax<int> 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<string, Dictionary<string, MinMaxDouble>> ConvertIntoPmcChance
public Dictionary<string, Dictionary<string, MinMax<double>>> 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<string, MinMaxDouble> LocationSpecificPmcLevelOverride
public Dictionary<string, MinMax<int>> LocationSpecificPmcLevelOverride
{
get;
set;
@@ -383,7 +383,7 @@ public record SlotLootSettings
}
}
public record MinMaxLootValue : MinMaxDouble
public record MinMaxLootValue : MinMax<double>
{
[JsonPropertyName("value")]
public double Value
@@ -393,24 +393,24 @@ public record MinMaxLootValue : MinMaxDouble
}
}
public record MinMaxLootItemValue : MinMaxDouble
public record MinMaxLootItemValue : MinMax<double>
{
[JsonPropertyName("backpack")]
public MinMaxDouble Backpack
public MinMax<double> Backpack
{
get;
set;
}
[JsonPropertyName("pocket")]
public MinMaxDouble Pocket
public MinMax<double> Pocket
{
get;
set;
}
[JsonPropertyName("vest")]
public MinMaxDouble Vest
public MinMax<double> Vest
{
get;
set;
@@ -596,7 +596,7 @@ public record PickupTypeWithMaxCount
public record EliminationConfig : BaseQuestConfig
{
[JsonPropertyName("levelRange")]
public MinMaxDouble? LevelRange
public MinMax<int>? LevelRange
{
get;
set;
@@ -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<double> Time
{
get;
set;
@@ -204,7 +204,7 @@ public record Dynamic
[JsonPropertyName("offerItemCount")]
/** How many offers should be listed */
public MinMaxDouble OfferItemCount
public MinMax<int> OfferItemCount
{
get;
set;
@@ -235,7 +235,7 @@ public record Dynamic
}
[JsonPropertyName("endTimeSeconds")]
public MinMaxDouble EndTimeSeconds
public MinMax<int> 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<double> 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<int> 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<double> Rating
{
get;
set;
@@ -348,21 +348,21 @@ public record Dynamic
public record PriceRanges
{
[JsonPropertyName("default")]
public MinMaxDouble Default
public MinMax<double> Default
{
get;
set;
}
[JsonPropertyName("preset")]
public MinMaxDouble Preset
public MinMax<double> Preset
{
get;
set;
}
[JsonPropertyName("pack")]
public MinMaxDouble Pack
public MinMax<double> Pack
{
get;
set;
@@ -541,14 +541,14 @@ public record Condition
}
[JsonPropertyName("current")]
public MinMaxDouble Current
public MinMax<double> Current
{
get;
set;
}
[JsonPropertyName("max")]
public MinMaxDouble Max
public MinMax<double> Max
{
get;
set;
@@ -219,7 +219,7 @@ public record BonusSettings
public record BonusValues
{
[JsonPropertyName("valuesMinMax")]
public MinMaxDouble ValuesMinMax
public MinMax<double> 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<double> ActiveDurabilityPercentMinMax
{
get;
set;
@@ -13,7 +13,7 @@ public record ScavCaseConfig : BaseConfig
} = "spt-scavcase";
[JsonPropertyName("rewardItemValueRangeRub")]
public Dictionary<string, MinMaxDouble> RewardItemValueRangeRub
public Dictionary<string, MinMax<double>> RewardItemValueRangeRub
{
get;
set;
@@ -110,21 +110,21 @@ public record MoneyRewards
public record MoneyLevels
{
[JsonPropertyName("common")]
public MinMaxDouble Common
public MinMax<int> Common
{
get;
set;
}
[JsonPropertyName("rare")]
public MinMaxDouble Rare
public MinMax<int> Rare
{
get;
set;
}
[JsonPropertyName("superrare")]
public MinMaxDouble SuperRare
public MinMax<int> SuperRare
{
get;
set;
@@ -148,7 +148,7 @@ public record AmmoRewards
}
[JsonPropertyName("ammoRewardValueRangeRub")]
public Dictionary<string, MinMaxDouble> AmmoRewardValueRangeRub
public Dictionary<string, MinMax<double>> AmmoRewardValueRangeRub
{
get;
set;
@@ -86,7 +86,7 @@ public record UpdateTime
* Seconds between trader resets
*/
[JsonPropertyName("seconds")]
public MinMaxDouble Seconds
public MinMax<int> Seconds
{
get;
set;
@@ -124,14 +124,14 @@ public record FenceConfig
}
[JsonPropertyName("weaponPresetMinMax")]
public MinMaxDouble WeaponPresetMinMax
public MinMax<int> WeaponPresetMinMax
{
get;
set;
}
[JsonPropertyName("equipmentPresetMinMax")]
public MinMaxDouble EquipmentPresetMinMax
public MinMax<int> EquipmentPresetMinMax
{
get;
set;
@@ -179,7 +179,7 @@ public record FenceConfig
* Key: item tpl
*/
[JsonPropertyName("itemStackSizeOverrideMinMax")]
public Dictionary<string, MinMaxDouble?> ItemStackSizeOverrideMinMax
public Dictionary<string, MinMax<int>?> ItemStackSizeOverrideMinMax
{
get;
set;
@@ -294,14 +294,14 @@ public record FenceConfig
public record ItemDurabilityCurrentMax
{
[JsonPropertyName("current")]
public MinMaxDouble Current
public MinMax<double> Current
{
get;
set;
}
[JsonPropertyName("max")]
public MinMaxDouble Max
public MinMax<double> Max
{
get;
set;
@@ -363,14 +363,14 @@ public record DiscountOptions
}
[JsonPropertyName("weaponPresetMinMax")]
public MinMaxDouble WeaponPresetMinMax
public MinMax<int> WeaponPresetMinMax
{
get;
set;
}
[JsonPropertyName("equipmentPresetMinMax")]
public MinMaxDouble EquipmentPresetMinMax
public MinMax<int> EquipmentPresetMinMax
{
get;
set;
@@ -146,7 +146,7 @@ public record SeasonalValues
}
[JsonPropertyName("windGustiness")]
public MinMaxDouble? WindGustiness
public MinMax<double>? WindGustiness
{
get;
set;
@@ -160,7 +160,7 @@ public record SeasonalValues
}
[JsonPropertyName("rainIntensity")]
public MinMaxDouble? RainIntensity
public MinMax<double>? RainIntensity
{
get;
set;
@@ -181,7 +181,7 @@ public record SeasonalValues
}
[JsonPropertyName("pressure")]
public MinMaxDouble? Pressure
public MinMax<double>? Pressure
{
get;
set;
@@ -191,14 +191,14 @@ public record SeasonalValues
public record TempDayNight
{
[JsonPropertyName("day")]
public MinMaxDouble? Day
public MinMax<double>? Day
{
get;
set;
}
[JsonPropertyName("night")]
public MinMaxDouble? Night
public MinMax<double>? Night
{
get;
set;
@@ -10,7 +10,7 @@ public record LootRequest
/// Count of weapons to generate
/// </summary>
[JsonPropertyName("weaponPresetCount")]
public MinMaxInt? WeaponPresetCount
public MinMax<int>? WeaponPresetCount
{
get;
set;
@@ -20,7 +20,7 @@ public record LootRequest
/// Count of armor to generate
/// </summary>
[JsonPropertyName("armorPresetCount")]
public MinMaxInt? ArmorPresetCount
public MinMax<int>? ArmorPresetCount
{
get;
set;
@@ -30,7 +30,7 @@ public record LootRequest
/// Count of items to generate
/// </summary>
[JsonPropertyName("itemCount")]
public MinMaxInt? ItemCount
public MinMax<int>? ItemCount
{
get;
set;
@@ -40,7 +40,7 @@ public record LootRequest
/// Count of sealed weapon crates to generate
/// </summary>
[JsonPropertyName("weaponCrateCount")]
public MinMaxInt? WeaponCrateCount
public MinMax<int>? WeaponCrateCount
{
get;
set;
@@ -77,7 +77,7 @@ public record LootRequest
}
[JsonPropertyName("itemStackLimits")]
public Dictionary<string, MinMaxInt>? ItemStackLimits
public Dictionary<string, MinMax<int>>? ItemStackLimits
{
get;
set;
@@ -127,7 +127,7 @@ public record LootRequest
/// Item tpls + count of items to force include
/// </summary>
[JsonPropertyName("forcedLoot")]
public Dictionary<string, MinMaxInt>? ForcedLoot
public Dictionary<string, MinMax<int>>? ForcedLoot
{
get;
set;
@@ -47,7 +47,7 @@ public class BotLootCacheService(
bool isPmc,
string lootType,
BotType botJsonTemplate,
MinMaxDouble? itemPriceMinMax = null)
MinMax<double>? itemPriceMinMax = null)
{
lock (_lock)
{
@@ -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);
+1 -1
View File
@@ -1336,7 +1336,7 @@ public class FenceService(
*/
protected int GetSingleItemStackCount(TemplateItem itemDbDetails)
{
MinMaxDouble? overrideValues;
MinMax<int>? overrideValues;
if (itemHelper.IsOfBaseclass(itemDbDetails.Id, BaseClasses.AMMO))
{
overrideValues = traderConfig.Fence.ItemStackSizeOverrideMinMax[itemDbDetails.Parent];
@@ -356,7 +356,7 @@ public class RagfairPriceService(
/// <param name="isPreset">Offer is a preset</param>
/// <param name="isPack">Offer is a pack</param>
/// <returns>MinMax values</returns>
protected MinMaxDouble GetOfferTypeRangeValues(bool isPreset, bool isPack)
protected MinMax<double> 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(
/// <param name="existingPrice">price to alter</param>
/// <param name="rangeValues">min and max to adjust price by</param>
/// <returns>multiplied price</returns>
protected double RandomiseOfferPrice(double existingPrice, MinMaxDouble rangeValues)
protected double RandomiseOfferPrice(double existingPrice, MinMax<double> 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);
+3 -3
View File
@@ -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
@@ -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