Renamed Minmax to MinMaxDouble and added MinMaxInt

Swapped various doubles for ints across loot generator and airdrop code paths

Fixed forced airdrop loot being returned with a decimal stack count
This commit is contained in:
Chomp
2025-02-10 09:57:01 +00:00
parent c8dadd106c
commit 08b5caf337
33 changed files with 175 additions and 139 deletions
+2 -2
View File
@@ -388,7 +388,7 @@ public class BotController(
};
}
private MinMax? GetPmcConversionMinMaxForLocation(string? requestedBotRole, string? location)
private MinMaxDouble? GetPmcConversionMinMaxForLocation(string? requestedBotRole, string? location)
{
return _pmcConfig.ConvertIntoPmcChance!.TryGetValue(location?.ToLower() ?? "", out var mapSpecificConversionValues)
? mapSpecificConversionValues.GetValueOrDefault(requestedBotRole?.ToLower())
@@ -409,7 +409,7 @@ public class BotController(
return raidSettings;
}
private MinMax? GetPmcLevelRangeForMap(string? location)
private MinMaxDouble? 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 MinMax(int.MaxValue, 0);
var minMax = new MinMaxDouble(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, MinMax minMax, bool ignoreTraderOffers)
private double GetAveragePriceFromOffers(List<RagfairOffer> offers, MinMaxDouble minMax, bool ignoreTraderOffers)
{
var sum = 0d;
var totalOfferCount = 0;
@@ -360,7 +360,7 @@ public class BotEquipmentModGenerator(
return result;
}
private MinMax GetMinMaxArmorPlateClass(List<TemplateItem> platePool)
private MinMaxDouble GetMinMaxArmorPlateClass(List<TemplateItem> platePool)
{
platePool.Sort(
(x, y) =>
@@ -379,7 +379,7 @@ public class BotEquipmentModGenerator(
}
);
return new MinMax
return new MinMaxDouble
{
Min = platePool[0].Properties.ArmorClass,
Max = platePool[platePool.Count - 1].Properties.ArmorClass
+3 -3
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, MinMax> experiences, string botDifficulty, string role)
public double GetExperienceRewardForKillByDifficulty(Dictionary<string, MinMaxDouble> experiences, string botDifficulty, string role)
{
if (!experiences.TryGetValue(botDifficulty.ToLower(), out var result))
{
@@ -624,7 +624,7 @@ public class BotGenerator(
foreach (var prop in props)
{
var value = (MinMax) prop.GetValue(bodyPart);
var value = (MinMaxDouble) 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, MinMax>? skills, bool isCommonSkills)
public List<BaseSkill> GetSkillsWithRandomisedProgressValue(Dictionary<string, MinMaxDouble>? skills, bool isCommonSkills)
{
if (skills is null)
{
@@ -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(MinMax levelDetails, BotGenerationDetails botGenerationDetails, BotBase bot)
public RandomisedBotLevelResult GenerateBotLevel(MinMaxDouble levelDetails, BotGenerationDetails botGenerationDetails, BotBase bot)
{
if (!botGenerationDetails.IsPmc.GetValueOrDefault(false))
{
@@ -74,7 +74,7 @@ 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 MinMax GetRelativePmcBotLevelRange(BotGenerationDetails botGenerationDetails, MinMax levelDetails, int maxAvailableLevel)
public MinMaxDouble GetRelativePmcBotLevelRange(BotGenerationDetails botGenerationDetails, MinMaxDouble levelDetails, int maxAvailableLevel)
{
var levelOverride = botGenerationDetails.LocationSpecificPmcLevelOverride;
@@ -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 MinMax(minLevel, maxLevel);
return new MinMaxDouble(minLevel, maxLevel);
}
}
+14 -15
View File
@@ -41,7 +41,7 @@ public class LootGenerator(
var itemTypeCounts = InitItemLimitCounter(options.ItemLimits);
// Handle sealed weapon containers
var sealedWeaponCrateCount = _randomUtil.GetDouble(
var sealedWeaponCrateCount = _randomUtil.GetInt(
options.WeaponCrateCount.Min.Value,
options.WeaponCrateCount.Max.Value
);
@@ -84,7 +84,7 @@ public class LootGenerator(
// Pool has items we could add as loot, proceed
if (rewardPoolResults.ItemPool.Count > 0)
{
var randomisedItemCount = _randomUtil.GetDouble(options.ItemCount.Min.Value, options.ItemCount.Max.Value);
var randomisedItemCount = _randomUtil.GetInt(options.ItemCount.Min.Value, options.ItemCount.Max.Value);
for (var index = 0; index < randomisedItemCount; index++)
{
if (!FindAndAddRandomItemToLoot(rewardPoolResults.ItemPool, itemTypeCounts, options, result))
@@ -98,7 +98,7 @@ public class LootGenerator(
var globalDefaultPresets = _presetHelper.GetDefaultPresets().Values;
// Filter default presets to just weapons
var randomisedWeaponPresetCount = _randomUtil.GetDouble(
var randomisedWeaponPresetCount = _randomUtil.GetInt(
options.WeaponPresetCount.Min.Value,
options.WeaponPresetCount.Max.Value
);
@@ -131,7 +131,7 @@ public class LootGenerator(
}
// Filter default presets to just armors and then filter again by protection level
var randomisedArmorPresetCount = _randomUtil.GetDouble(
var randomisedArmorPresetCount = _randomUtil.GetInt(
options.ArmorPresetCount.Min.Value,
options.ArmorPresetCount.Max.Value
);
@@ -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, MinMax> forcedLootDict)
public List<Item> CreateForcedLoot(Dictionary<string, MinMaxInt> 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.GetDouble(details.Min.Value, details.Max.Value);
var randomisedItemCount = _randomUtil.GetInt(details.Min.Value, details.Max.Value);
// Add forced loot item to result
var newLootItem = new Item
@@ -296,7 +296,7 @@ public class LootGenerator(
/// </summary>
/// <param name="limits">limits as defined in config</param>
/// <returns>record, key: item tplId, value: current/max item count allowed</returns>
private Dictionary<string, ItemLimit> InitItemLimitCounter(Dictionary<string, double> limits)
private Dictionary<string, ItemLimit> InitItemLimitCounter(Dictionary<string, int> limits)
{
var itemTypeCounts = new Dictionary<string, ItemLimit>();
foreach (var itemTypeId in limits)
@@ -380,8 +380,8 @@ public class LootGenerator(
if (options.ItemStackLimits.TryGetValue(item.Id, out var itemLimits))
{
min = (int?) itemLimits.Min;
max = (int?) itemLimits.Max;
min = itemLimits.Min;
max = itemLimits.Max;
}
return _randomUtil.GetInt(min ?? 1, max ?? 1);
@@ -542,8 +542,7 @@ public class LootGenerator(
foreach (var (rewardKey, settings) in containerSettings.RewardTypeLimits)
{
var rewardCount = _randomUtil.GetDouble(settings.Min.Value, settings.Max.Value);
var rewardCount = _randomUtil.GetInt(settings.Min.Value, settings.Max.Value);
if (rewardCount == 0)
{
continue;
@@ -552,7 +551,7 @@ public class LootGenerator(
// Edge case - ammo boxes
if (rewardKey == BaseClasses.AMMO_BOX)
{
// Get ammoboxes from db
// Get ammo boxes from db
var ammoBoxesDetails = containerSettings.AmmoBoxWhitelist.Select(
tpl =>
{
@@ -650,7 +649,7 @@ public class LootGenerator(
foreach (var (rewardKey, settings) in containerSettings.WeaponModRewardLimits)
{
var rewardCount = _randomUtil.GetDouble(settings.Min.Value, settings.Max.Value);
var rewardCount = _randomUtil.GetInt(settings.Min.Value, settings.Max.Value);
// Nothing to add, skip reward type
if (rewardCount == 0)
@@ -775,14 +774,14 @@ public class LootGenerator(
public class ItemLimit
{
[JsonPropertyName("current")]
public double Current
public int Current
{
get;
set;
}
[JsonPropertyName("max")]
public double Max
public int Max
{
get;
set;
@@ -464,20 +464,20 @@ public class ScavCaseRewardGenerator(
amountToGive = itemToCalculate.Id switch
{
Money.ROUBLES => _randomUtil.GetInt(
(int) _scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp<MinMax>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp<MinMax>(rarity).Max
(int) _scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp<MinMaxDouble>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.RubCount.GetByJsonProp<MinMaxDouble>(rarity).Max
),
Money.EUROS => _randomUtil.GetInt(
(int) _scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp<MinMax>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp<MinMax>(rarity).Max
(int) _scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp<MinMaxDouble>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.EurCount.GetByJsonProp<MinMaxDouble>(rarity).Max
),
Money.DOLLARS => _randomUtil.GetInt(
(int) _scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp<MinMax>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp<MinMax>(rarity).Max
(int) _scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp<MinMaxDouble>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.UsdCount.GetByJsonProp<MinMaxDouble>(rarity).Max
),
Money.GP => _randomUtil.GetInt(
(int) _scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp<MinMax>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp<MinMax>(rarity).Max
(int) _scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp<MinMaxDouble>(rarity).Min,
(int) _scavCaseConfig.MoneyRewards.GpCount.GetByJsonProp<MinMaxDouble>(rarity).Max
),
_ => amountToGive
};
+3 -3
View File
@@ -112,17 +112,17 @@ public class BotHelper(
}
}
public bool RollChanceToBePmc(MinMax botConvertMinMax)
public bool RollChanceToBePmc(MinMaxDouble botConvertMinMax)
{
return _randomUtil.GetChance100(_randomUtil.GetDouble(botConvertMinMax.Min.Value, botConvertMinMax.Max.Value));
}
protected Dictionary<string, MinMax> GetPmcConversionValuesForLocation(string location)
protected Dictionary<string, MinMaxDouble> GetPmcConversionValuesForLocation(string location)
{
var result = _pmcConfig.ConvertIntoPmcChance[location.ToLower()];
if (result is null)
{
_pmcConfig.ConvertIntoPmcChance = new Dictionary<string, Dictionary<string, MinMax>>();
_pmcConfig.ConvertIntoPmcChance = new Dictionary<string, Dictionary<string, MinMaxDouble>>();
}
return result;
+1 -1
View File
@@ -394,7 +394,7 @@ public class TraderHelper(
// create temporary entry to prevent logger spam
{
TraderId = traderId,
Seconds = new MinMax(_traderConfig.UpdateTimeDefault, _traderConfig.UpdateTimeDefault)
Seconds = new MinMaxDouble(_traderConfig.UpdateTimeDefault, _traderConfig.UpdateTimeDefault)
}
);
@@ -2,15 +2,15 @@ using System.Text.Json.Serialization;
namespace Core.Models.Common;
public record MinMax
public record MinMaxDouble
{
public MinMax(double min, double max)
public MinMaxDouble(double min, double max)
{
Min = min;
Max = max;
}
public MinMax()
public MinMaxDouble()
{
}
+37
View File
@@ -0,0 +1,37 @@
using System.Text.Json.Serialization;
namespace Core.Models.Common;
public record MinMaxInt
{
public MinMaxInt(int min, int max)
{
Min = min;
Max = max;
}
public MinMaxInt()
{
}
[JsonPropertyName("type")]
public string? Type
{
get;
set;
}
[JsonPropertyName("max")]
public int? Max
{
get;
set;
}
[JsonPropertyName("min")]
public int? Min
{
get;
set;
}
}
@@ -870,7 +870,7 @@ public record NonWaveGroupScenario
}
}
public record Limit : MinMax
public record Limit : MinMaxDouble
{
[JsonPropertyName("items")]
public object[] Items
@@ -1383,7 +1383,7 @@ public record ChancedEnemy
}
}
public record MinMaxBot : MinMax
public record MinMaxBot : MinMaxDouble
{
[JsonPropertyName("WildSpawnType")]
public string? WildSpawnType
@@ -446,7 +446,7 @@ public record Experience
}
[JsonPropertyName("level")]
public MinMax? Level
public MinMaxDouble? Level
{
get;
set;
@@ -456,7 +456,7 @@ public record Experience
* key = bot difficulty
*/
[JsonPropertyName("reward")]
public Dictionary<string, MinMax>? Reward
public Dictionary<string, MinMaxDouble>? Reward
{
get;
set;
@@ -616,19 +616,19 @@ public record BotTypeHealth
set;
}
public MinMax? Energy
public MinMaxDouble? Energy
{
get;
set;
}
public MinMax? Hydration
public MinMaxDouble? Hydration
{
get;
set;
}
public MinMax? Temperature
public MinMaxDouble? Temperature
{
get;
set;
@@ -637,43 +637,43 @@ public record BotTypeHealth
public record BodyPart
{
public MinMax? Chest
public MinMaxDouble? Chest
{
get;
set;
}
public MinMax? Head
public MinMaxDouble? Head
{
get;
set;
}
public MinMax? LeftArm
public MinMaxDouble? LeftArm
{
get;
set;
}
public MinMax? LeftLeg
public MinMaxDouble? LeftLeg
{
get;
set;
}
public MinMax? RightArm
public MinMaxDouble? RightArm
{
get;
set;
}
public MinMax? RightLeg
public MinMaxDouble? RightLeg
{
get;
set;
}
public MinMax? Stomach
public MinMaxDouble? Stomach
{
get;
set;
@@ -832,13 +832,13 @@ public record ItemPools
public record BotDbSkills
{
public Dictionary<string, MinMax>? Common
public Dictionary<string, MinMaxDouble>? Common
{
get;
set;
}
public Dictionary<string, MinMax>? Mastering
public Dictionary<string, MinMaxDouble>? Mastering
{
get;
set;
@@ -232,21 +232,21 @@ public record ScavRecipe
public record EndProducts
{
[JsonPropertyName("Common")]
public MinMax? Common
public MinMaxDouble? Common
{
get;
set;
}
[JsonPropertyName("Rare")]
public MinMax? Rare
public MinMaxDouble? Rare
{
get;
set;
}
[JsonPropertyName("Superrare")]
public MinMax? Superrare
public MinMaxDouble? Superrare
{
get;
set;
@@ -3,7 +3,7 @@ using Core.Models.Common;
namespace Core.Models.Eft.Ragfair;
public record GetItemPriceResult : MinMax
public record GetItemPriceResult : MinMaxDouble
{
[JsonPropertyName("avg")]
public double? Avg
@@ -56,7 +56,7 @@ public record BotGenerationDetails
/// Level specific overrides for PMC level
/// </summary>
[JsonPropertyName("locationSpecificPmcLevelOverride")]
public MinMax? LocationSpecificPmcLevelOverride
public MinMaxDouble? LocationSpecificPmcLevelOverride
{
get;
set;
@@ -117,7 +117,7 @@ public record AirdropLoot
/// Min/max of weapons inside crate
/// </summary>
[JsonPropertyName("weaponPresetCount")]
public MinMax? WeaponPresetCount
public MinMaxInt? WeaponPresetCount
{
get;
set;
@@ -127,7 +127,7 @@ public record AirdropLoot
/// Min/max of armors (head/chest/rig) inside crate
/// </summary>
[JsonPropertyName("armorPresetCount")]
public MinMax? ArmorPresetCount
public MinMaxInt? ArmorPresetCount
{
get;
set;
@@ -137,7 +137,7 @@ public record AirdropLoot
/// Min/max of items inside crate
/// </summary>
[JsonPropertyName("itemCount")]
public MinMax ItemCount
public MinMaxInt ItemCount
{
get;
set;
@@ -147,7 +147,7 @@ public record AirdropLoot
/// Min/max of sealed weapon boxes inside crate
/// </summary>
[JsonPropertyName("weaponCrateCount")]
public MinMax WeaponCrateCount
public MinMaxInt WeaponCrateCount
{
get;
set;
@@ -177,7 +177,7 @@ public record AirdropLoot
/// Item type/ item tpls to limit count of inside crate - key: item base type: value: max count
/// </summary>
[JsonPropertyName("itemLimits")]
public Dictionary<string, double> ItemLimits
public Dictionary<string, int> ItemLimits
{
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, MinMax> ItemStackLimits
public Dictionary<string, MinMaxInt> ItemStackLimits
{
get;
set;
@@ -221,7 +221,7 @@ public record AirdropLoot
}
[JsonPropertyName("forcedLoot")]
public Dictionary<string, MinMax>? ForcedLoot
public Dictionary<string, MinMaxInt>? ForcedLoot
{
get;
set;
@@ -251,7 +251,7 @@ public record AssaultToBossConversion
}
[JsonPropertyName("bossConvertMinMax")]
public Dictionary<string, MinMax> BossConvertMinMax
public Dictionary<string, MinMaxDouble> BossConvertMinMax
{
get;
set;
@@ -599,7 +599,7 @@ public record WalletLootSettings
}
[JsonPropertyName("itemCount")]
public MinMax ItemCount
public MinMaxDouble ItemCount
{
get;
set;
@@ -843,7 +843,7 @@ public record RandomisationDetails
/// Between what levels do these randomisation setting apply to
/// </summary>
[JsonPropertyName("levelRange")]
public MinMax LevelRange
public MinMaxDouble LevelRange
{
get;
set;
@@ -950,7 +950,7 @@ public record EquipmentFilterDetails
/// Between what levels do these equipment filter setting apply to
/// </summary>
[JsonPropertyName("levelRange")]
public MinMax LevelRange
public MinMaxDouble LevelRange
{
get;
set;
@@ -993,7 +993,7 @@ public record WeightingAdjustmentDetails
/// Between what levels do these weight settings apply to
/// </summary>
[JsonPropertyName("levelRange")]
public MinMax LevelRange
public MinMaxDouble LevelRange
{
get;
set;
@@ -1050,7 +1050,7 @@ public record AdjustmentDetails
public class ArmorPlateWeights
{
[JsonPropertyName("levelRange")]
public MinMax LevelRange
public MinMaxDouble LevelRange
{
get;
set;
@@ -127,7 +127,7 @@ public record CultistCircleSettings
}
[JsonPropertyName("rewardPriceMultiplerMinMax")]
public MinMax RewardPriceMultiplerMinMax
public MinMaxDouble 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, MinMax> DirectRewardStackSize
public Dictionary<string, MinMaxDouble> DirectRewardStackSize
{
get;
set;
@@ -238,14 +238,14 @@ public record CultistCircleSettings
}
[JsonPropertyName("currencyRewards")]
public Dictionary<string, MinMax> CurrencyRewards
public Dictionary<string, MinMaxDouble> CurrencyRewards
{
get;
set;
}
}
public record CraftTimeThreshold : MinMax
public record CraftTimeThreshold : MinMaxDouble
{
[JsonPropertyName("craftTimeSeconds")]
public int CraftTimeSeconds
@@ -132,14 +132,14 @@ public record SealedAirdropContainerSettings
}
[JsonPropertyName("weaponModRewardLimits")]
public Dictionary<string, MinMax> WeaponModRewardLimits
public Dictionary<string, MinMaxInt> WeaponModRewardLimits
{
get;
set;
}
[JsonPropertyName("rewardTypeLimits")]
public Dictionary<string, MinMax> RewardTypeLimits
public Dictionary<string, MinMaxInt> RewardTypeLimits
{
get;
set;
@@ -341,7 +341,7 @@ public record CustomWaves
}
}
public record BotTypeLimit : MinMax
public record BotTypeLimit : MinMaxDouble
{
[JsonPropertyName("type")]
public string Type
@@ -115,7 +115,7 @@ public record PmcConfig : BaseConfig
* MinMax count of weapons to have in backpack
*/
[JsonPropertyName("looseWeaponInBackpackLootMinMax")]
public MinMax LooseWeaponInBackpackLootMinMax
public MinMaxDouble 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, MinMax>> ConvertIntoPmcChance
public Dictionary<string, Dictionary<string, MinMaxDouble>> ConvertIntoPmcChance
{
get;
set;
@@ -251,7 +251,7 @@ public record PmcConfig : BaseConfig
}
[JsonPropertyName("locationSpecificPmcLevelOverride")]
public Dictionary<string, MinMax> LocationSpecificPmcLevelOverride
public Dictionary<string, MinMaxDouble> LocationSpecificPmcLevelOverride
{
get;
set;
@@ -383,7 +383,7 @@ public record SlotLootSettings
}
}
public record MinMaxLootValue : MinMax
public record MinMaxLootValue : MinMaxDouble
{
[JsonPropertyName("value")]
public double Value
@@ -393,24 +393,24 @@ public record MinMaxLootValue : MinMax
}
}
public record MinMaxLootItemValue : MinMax
public record MinMaxLootItemValue : MinMaxDouble
{
[JsonPropertyName("backpack")]
public MinMax Backpack
public MinMaxDouble Backpack
{
get;
set;
}
[JsonPropertyName("pocket")]
public MinMax Pocket
public MinMaxDouble Pocket
{
get;
set;
}
[JsonPropertyName("vest")]
public MinMax Vest
public MinMaxDouble Vest
{
get;
set;
@@ -596,7 +596,7 @@ public record PickupTypeWithMaxCount
public record EliminationConfig : BaseQuestConfig
{
[JsonPropertyName("levelRange")]
public MinMax? LevelRange
public MinMaxDouble? 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 MinMax Time
public MinMaxDouble Time
{
get;
set;
@@ -204,7 +204,7 @@ public record Dynamic
[JsonPropertyName("offerItemCount")]
/** How many offers should be listed */
public MinMax OfferItemCount
public MinMaxDouble OfferItemCount
{
get;
set;
@@ -235,7 +235,7 @@ public record Dynamic
}
[JsonPropertyName("endTimeSeconds")]
public MinMax EndTimeSeconds
public MinMaxDouble 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 MinMax StackablePercent
public MinMaxDouble 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 MinMax NonStackableCount
public MinMaxDouble NonStackableCount
{
get;
set;
@@ -267,7 +267,7 @@ public record Dynamic
[JsonPropertyName("rating")]
/** Range of rating offers for items being listed */
public MinMax Rating
public MinMaxDouble Rating
{
get;
set;
@@ -348,21 +348,21 @@ public record Dynamic
public record PriceRanges
{
[JsonPropertyName("default")]
public MinMax Default
public MinMaxDouble Default
{
get;
set;
}
[JsonPropertyName("preset")]
public MinMax Preset
public MinMaxDouble Preset
{
get;
set;
}
[JsonPropertyName("pack")]
public MinMax Pack
public MinMaxDouble Pack
{
get;
set;
@@ -541,14 +541,14 @@ public record Condition
}
[JsonPropertyName("current")]
public MinMax Current
public MinMaxDouble Current
{
get;
set;
}
[JsonPropertyName("max")]
public MinMax Max
public MinMaxDouble Max
{
get;
set;
@@ -219,7 +219,7 @@ public record BonusSettings
public record BonusValues
{
[JsonPropertyName("valuesMinMax")]
public MinMax ValuesMinMax
public MinMaxDouble ValuesMinMax
{
get;
set;
@@ -229,7 +229,7 @@ public record BonusValues
* What dura is buff active between (min max of current max)
*/
[JsonPropertyName("activeDurabilityPercentMinMax")]
public MinMax ActiveDurabilityPercentMinMax
public MinMaxDouble ActiveDurabilityPercentMinMax
{
get;
set;
@@ -13,7 +13,7 @@ public record ScavCaseConfig : BaseConfig
} = "spt-scavcase";
[JsonPropertyName("rewardItemValueRangeRub")]
public Dictionary<string, MinMax> RewardItemValueRangeRub
public Dictionary<string, MinMaxDouble> RewardItemValueRangeRub
{
get;
set;
@@ -110,21 +110,21 @@ public record MoneyRewards
public record MoneyLevels
{
[JsonPropertyName("common")]
public MinMax Common
public MinMaxDouble Common
{
get;
set;
}
[JsonPropertyName("rare")]
public MinMax Rare
public MinMaxDouble Rare
{
get;
set;
}
[JsonPropertyName("superrare")]
public MinMax SuperRare
public MinMaxDouble SuperRare
{
get;
set;
@@ -148,7 +148,7 @@ public record AmmoRewards
}
[JsonPropertyName("ammoRewardValueRangeRub")]
public Dictionary<string, MinMax> AmmoRewardValueRangeRub
public Dictionary<string, MinMaxDouble> AmmoRewardValueRangeRub
{
get;
set;
@@ -86,7 +86,7 @@ public record UpdateTime
* Seconds between trader resets
*/
[JsonPropertyName("seconds")]
public MinMax Seconds
public MinMaxDouble Seconds
{
get;
set;
@@ -124,14 +124,14 @@ public record FenceConfig
}
[JsonPropertyName("weaponPresetMinMax")]
public MinMax WeaponPresetMinMax
public MinMaxDouble WeaponPresetMinMax
{
get;
set;
}
[JsonPropertyName("equipmentPresetMinMax")]
public MinMax EquipmentPresetMinMax
public MinMaxDouble EquipmentPresetMinMax
{
get;
set;
@@ -179,7 +179,7 @@ public record FenceConfig
* Key: item tpl
*/
[JsonPropertyName("itemStackSizeOverrideMinMax")]
public Dictionary<string, MinMax?> ItemStackSizeOverrideMinMax
public Dictionary<string, MinMaxDouble?> ItemStackSizeOverrideMinMax
{
get;
set;
@@ -294,14 +294,14 @@ public record FenceConfig
public record ItemDurabilityCurrentMax
{
[JsonPropertyName("current")]
public MinMax Current
public MinMaxDouble Current
{
get;
set;
}
[JsonPropertyName("max")]
public MinMax Max
public MinMaxDouble Max
{
get;
set;
@@ -363,14 +363,14 @@ public record DiscountOptions
}
[JsonPropertyName("weaponPresetMinMax")]
public MinMax WeaponPresetMinMax
public MinMaxDouble WeaponPresetMinMax
{
get;
set;
}
[JsonPropertyName("equipmentPresetMinMax")]
public MinMax EquipmentPresetMinMax
public MinMaxDouble EquipmentPresetMinMax
{
get;
set;
@@ -146,7 +146,7 @@ public record SeasonalValues
}
[JsonPropertyName("windGustiness")]
public MinMax? WindGustiness
public MinMaxDouble? WindGustiness
{
get;
set;
@@ -160,7 +160,7 @@ public record SeasonalValues
}
[JsonPropertyName("rainIntensity")]
public MinMax? RainIntensity
public MinMaxDouble? RainIntensity
{
get;
set;
@@ -181,7 +181,7 @@ public record SeasonalValues
}
[JsonPropertyName("pressure")]
public MinMax? Pressure
public MinMaxDouble? Pressure
{
get;
set;
@@ -191,14 +191,14 @@ public record SeasonalValues
public record TempDayNight
{
[JsonPropertyName("day")]
public MinMax? Day
public MinMaxDouble? Day
{
get;
set;
}
[JsonPropertyName("night")]
public MinMax? Night
public MinMaxDouble? Night
{
get;
set;
@@ -10,7 +10,7 @@ public record LootRequest
/// Count of weapons to generate
/// </summary>
[JsonPropertyName("weaponPresetCount")]
public MinMax? WeaponPresetCount
public MinMaxInt? WeaponPresetCount
{
get;
set;
@@ -20,7 +20,7 @@ public record LootRequest
/// Count of armor to generate
/// </summary>
[JsonPropertyName("armorPresetCount")]
public MinMax? ArmorPresetCount
public MinMaxInt? ArmorPresetCount
{
get;
set;
@@ -30,7 +30,7 @@ public record LootRequest
/// Count of items to generate
/// </summary>
[JsonPropertyName("itemCount")]
public MinMax? ItemCount
public MinMaxInt? ItemCount
{
get;
set;
@@ -40,7 +40,7 @@ public record LootRequest
/// Count of sealed weapon crates to generate
/// </summary>
[JsonPropertyName("weaponCrateCount")]
public MinMax? WeaponCrateCount
public MinMaxInt? WeaponCrateCount
{
get;
set;
@@ -70,14 +70,14 @@ public record LootRequest
/// key: item base type: value: max count
/// </summary>
[JsonPropertyName("itemLimits")]
public Dictionary<string, double>? ItemLimits
public Dictionary<string, int>? ItemLimits
{
get;
set;
}
[JsonPropertyName("itemStackLimits")]
public Dictionary<string, MinMax>? ItemStackLimits
public Dictionary<string, MinMaxInt>? ItemStackLimits
{
get;
set;
@@ -127,7 +127,7 @@ public record LootRequest
/// Item tpls + count of items to force include
/// </summary>
[JsonPropertyName("forcedLoot")]
public Dictionary<string, MinMax>? ForcedLoot
public Dictionary<string, MinMaxInt>? ForcedLoot
{
get;
set;
+5 -5
View File
@@ -49,7 +49,7 @@ public class AirdropService(
/// <returns>List of LootItem objects</returns>
public GetAirdropLootResponse GenerateAirdropLoot(SptAirdropTypeEnum? forcedAirdropType = null)
{
var airdropType = forcedAirdropType != null ? forcedAirdropType : ChooseAirdropType();
var airdropType = forcedAirdropType ?? ChooseAirdropType();
if (_logger.IsLogEnabled(LogLevel.Debug))
{
_logger.Debug($"Chose: {airdropType} for airdrop loot");
@@ -64,12 +64,12 @@ public class AirdropService(
: _lootGenerator.CreateRandomLoot(airdropConfig);
// Create airdrop crate and add to result in first spot
var airdropCrateItem = GetAirdropCrateItem((SptAirdropTypeEnum) airdropType);
var airdropCrateItem = GetAirdropCrateItem(airdropType);
// Add crate to front of list
crateLoot.Insert(0, airdropCrateItem);
// Reparent loot items to crate we added above
// Re-parent loot items to crate we added above
foreach (var item in crateLoot)
{
if (item.Id == airdropCrateItem.Id)
@@ -78,7 +78,7 @@ public class AirdropService(
continue;
}
// no parentId = root item, make item have create as parent
// no parentId = root item, make item have crate as parent
if (item.ParentId is null)
{
item.ParentId = airdropCrateItem.Id;
@@ -103,7 +103,7 @@ public class AirdropService(
var airdropContainer = new Item
{
Id = _hashUtil.Generate(),
Template = "", // picked later
Template = string.Empty, // Picked later
Upd = new Upd
{
SpawnedInSession = true,
@@ -47,7 +47,7 @@ public class BotLootCacheService(
bool isPmc,
string lootType,
BotType botJsonTemplate,
MinMax? itemPriceMinMax = null)
MinMaxDouble? itemPriceMinMax = null)
{
lock (_lock)
{
+1 -1
View File
@@ -1336,7 +1336,7 @@ public class FenceService(
*/
protected int GetSingleItemStackCount(TemplateItem itemDbDetails)
{
MinMax? overrideValues;
MinMaxDouble? 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 MinMax GetOfferTypeRangeValues(bool isPreset, bool isPack)
protected MinMaxDouble GetOfferTypeRangeValues(bool isPreset, bool isPack)
{
// Use different min/max values if the item is a preset or pack
var priceRanges = _ragfairConfig.Dynamic.PriceRanges;
@@ -406,7 +406,7 @@ 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, MinMax rangeValues)
protected double RandomiseOfferPrice(double existingPrice, MinMaxDouble 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);