more null guards, make params null by default

This commit is contained in:
CWX
2025-01-17 14:01:35 +00:00
parent 408dffbf13
commit 897be34ea9
3 changed files with 114 additions and 113 deletions
+102 -101
View File
@@ -12,254 +12,255 @@ public class QuestConfig : BaseConfig
// Hours to get/redeem items from quest mail keyed by profile type
[JsonPropertyName("mailRedeemTimeHours")]
public Dictionary<string, double> MailRedeemTimeHours { get; set; }
public Dictionary<string, double?>? MailRedeemTimeHours { get; set; }
[JsonPropertyName("questTemplateIds")]
public PlayerTypeQuestIds QuestTemplateIds { get; set; }
public PlayerTypeQuestIds? QuestTemplateIds { get; set; }
/** Show non-seasonal quests be shown to player */
[JsonPropertyName("showNonSeasonalEventQuests")]
public bool ShowNonSeasonalEventQuests { get; set; }
public bool? ShowNonSeasonalEventQuests { get; set; }
[JsonPropertyName("eventQuests")]
public Dictionary<string, EventQuestData> EventQuests { get; set; }
public Dictionary<string, EventQuestData>? EventQuests { get; set; }
[JsonPropertyName("repeatableQuests")]
public List<RepeatableQuestConfig> RepeatableQuests { get; set; }
public List<RepeatableQuestConfig>? RepeatableQuests { get; set; }
[JsonPropertyName("locationIdMap")]
public Dictionary<string, string> LocationIdMap { get; set; }
public Dictionary<string, string>? LocationIdMap { get; set; }
[JsonPropertyName("bearOnlyQuests")]
public List<string> BearOnlyQuests { get; set; }
public List<string>? BearOnlyQuests { get; set; }
[JsonPropertyName("usecOnlyQuests")]
public List<string> UsecOnlyQuests { get; set; }
public List<string>? UsecOnlyQuests { get; set; }
/** Quests that the keyed game version do not see/access */
[JsonPropertyName("profileBlacklist")]
public Dictionary<string, List<string>> ProfileBlacklist { get; set; }
public Dictionary<string, List<string>>? ProfileBlacklist { get; set; }
/** key=questid, gameversions that can see/access quest */
[JsonPropertyName("profileWhitelist")]
public Dictionary<string, List<string>> ProfileWhitelist { get; set; }
public Dictionary<string, List<string>>? ProfileWhitelist { get; set; }
}
public class PlayerTypeQuestIds
{
[JsonPropertyName("pmc")]
public QuestTypeIds Pmc { get; set; }
public QuestTypeIds? Pmc { get; set; }
[JsonPropertyName("scav")]
public QuestTypeIds Scav { get; set; }
public QuestTypeIds? Scav { get; set; }
}
public class QuestTypeIds
{
[JsonPropertyName("elimination")]
public string Elimination { get; set; }
public string? Elimination { get; set; }
[JsonPropertyName("completion")]
public string Completion { get; set; }
public string? Completion { get; set; }
[JsonPropertyName("exploration")]
public string Exploration { get; set; }
public string? Exploration { get; set; }
[JsonPropertyName("pickup")]
public string Pickup { get; set; }
public string? Pickup { get; set; }
}
public class EventQuestData
{
[JsonPropertyName("name")]
public string Name { get; set; }
public string? Name { get; set; }
[JsonPropertyName("season")]
public SeasonalEventType Season { get; set; }
public SeasonalEventType? Season { get; set; }
[JsonPropertyName("startTimestamp")]
public long StartTimestamp { get; set; }
public long? StartTimestamp { get; set; }
[JsonPropertyName("endTimestamp")]
[JsonConverter(typeof(StringToNumberFactoryConverter))]
public long? EndTimestamp { get; set; }
[JsonPropertyName("yearly")]
public bool Yearly { get; set; }
public bool? Yearly { get; set; }
}
public class RepeatableQuestConfig
{
[JsonPropertyName("id")]
public string Id { get; set; }
public string? Id { get; set; }
[JsonPropertyName("name")]
public string Name { get; set; }
public string? Name { get; set; }
[JsonPropertyName("side")]
public string Side { get; set; }
public string? Side { get; set; }
[JsonPropertyName("types")]
public List<string> Types { get; set; }
public List<string>? Types { get; set; }
[JsonPropertyName("resetTime")]
public long ResetTime { get; set; }
public long? ResetTime { get; set; }
[JsonPropertyName("numQuests")]
public int NumQuests { get; set; }
public int? NumQuests { get; set; }
[JsonPropertyName("minPlayerLevel")]
public int MinPlayerLevel { get; set; }
public int? MinPlayerLevel { get; set; }
[JsonPropertyName("rewardScaling")]
public RewardScaling RewardScaling { get; set; }
public RewardScaling? RewardScaling { get; set; }
[JsonPropertyName("locations")]
public Dictionary<ELocationName, List<string>> Locations { get; set; }
public Dictionary<ELocationName, List<string>>? Locations { get; set; }
[JsonPropertyName("traderWhitelist")]
public List<TraderWhitelist> TraderWhitelist { get; set; }
public List<TraderWhitelist>? TraderWhitelist { get; set; }
[JsonPropertyName("questConfig")]
public RepeatableQuestTypesConfig QuestConfig { get; set; }
public RepeatableQuestTypesConfig? QuestConfig { get; set; }
/** Item base types to block when generating rewards */
[JsonPropertyName("rewardBaseTypeBlacklist")]
public List<string> RewardBaseTypeBlacklist { get; set; }
public List<string>? RewardBaseTypeBlacklist { get; set; }
/** Item tplIds to ignore when generating rewards */
[JsonPropertyName("rewardBlacklist")]
public List<string> RewardBlacklist { get; set; }
public List<string>? RewardBlacklist { get; set; }
[JsonPropertyName("rewardAmmoStackMinSize")]
public int RewardAmmoStackMinSize { get; set; }
public int? RewardAmmoStackMinSize { get; set; }
[JsonPropertyName("freeChangesAvailable")]
public int FreeChangesAvailable { get; set; }
public int? FreeChangesAvailable { get; set; }
[JsonPropertyName("freeChanges")]
public int FreeChanges { get; set; }
public int? FreeChanges { get; set; }
[JsonPropertyName("keepDailyQuestTypeOnReplacement")]
public bool KeepDailyQuestTypeOnReplacement { get; set; }
public bool? KeepDailyQuestTypeOnReplacement { get; set; }
}
public class RewardScaling
{
[JsonPropertyName("levels")]
public List<int> Levels { get; set; }
public List<int>? Levels { get; set; }
[JsonPropertyName("experience")]
public List<int> Experience { get; set; }
public List<int>? Experience { get; set; }
[JsonPropertyName("roubles")]
public List<int> Roubles { get; set; }
public List<int>? Roubles { get; set; }
[JsonPropertyName("gpCoins")]
public List<int> GpCoins { get; set; }
public List<int>? GpCoins { get; set; }
[JsonPropertyName("items")]
public List<int> Items { get; set; }
public List<int>? Items { get; set; }
[JsonPropertyName("reputation")]
public List<double> Reputation { get; set; }
public List<double>? Reputation { get; set; }
[JsonPropertyName("rewardSpread")]
public double RewardSpread { get; set; }
public double? RewardSpread { get; set; }
[JsonPropertyName("skillRewardChance")]
public List<double> SkillRewardChance { get; set; }
public List<double>? SkillRewardChance { get; set; }
[JsonPropertyName("skillPointReward")]
public List<int> SkillPointReward { get; set; }
public List<int>? SkillPointReward { get; set; }
}
public class TraderWhitelist
{
[JsonPropertyName("name")]
public string Name { get; set; }
public string? Name { get; set; }
[JsonPropertyName("traderId")]
public string TraderId { get; set; }
public string? TraderId { get; set; }
[JsonPropertyName("questTypes")]
public List<string> QuestTypes { get; set; }
public List<string>? QuestTypes { get; set; }
[JsonPropertyName("rewardBaseWhitelist")]
public List<string> RewardBaseWhitelist { get; set; }
public List<string>? RewardBaseWhitelist { get; set; }
[JsonPropertyName("rewardCanBeWeapon")]
public bool RewardCanBeWeapon { get; set; }
public bool? RewardCanBeWeapon { get; set; }
[JsonPropertyName("weaponRewardChancePercent")]
public double WeaponRewardChancePercent { get; set; }
public double? WeaponRewardChancePercent { get; set; }
}
public class RepeatableQuestTypesConfig
{
[JsonPropertyName("Exploration")]
public Exploration Exploration { get; set; }
public Exploration? Exploration { get; set; }
[JsonPropertyName("Completion")]
public Completion Completion { get; set; }
public Completion? Completion { get; set; }
[JsonPropertyName("Pickup")]
public Pickup Pickup { get; set; }
public Pickup? Pickup { get; set; }
[JsonPropertyName("Elimination")]
public List<EliminationConfig> Elimination { get; set; }
public List<EliminationConfig>? Elimination { get; set; }
}
public class Exploration : BaseQuestConfig
{
[JsonPropertyName("maxExtracts")]
public int MaximumExtracts { get; set; }
public int? MaximumExtracts { get; set; }
[JsonPropertyName("maxExtractsWithSpecificExit")]
public int MaximumExtractsWithSpecificExit { get; set; }
public int? MaximumExtractsWithSpecificExit { get; set; }
[JsonPropertyName("specificExits")]
public SpecificExits SpecificExits { get; set; }
public SpecificExits? SpecificExits { get; set; }
}
public class SpecificExits
{
[JsonPropertyName("probability")]
public double Probability { get; set; }
public double? Probability { get; set; }
[JsonPropertyName("passageRequirementWhitelist")]
public List<string> PassageRequirementWhitelist { get; set; }
public List<string>? PassageRequirementWhitelist { get; set; }
}
public class Completion : BaseQuestConfig
{
[JsonPropertyName("minRequestedAmount")]
public int MinimumRequestedAmount { get; set; }
public int? MinimumRequestedAmount { get; set; }
[JsonPropertyName("maxRequestedAmount")]
public int MaximumRequestedAmount { get; set; }
public int? MaximumRequestedAmount { get; set; }
[JsonPropertyName("uniqueItemCount")]
public int UniqueItemCount { get; set; }
public int? UniqueItemCount { get; set; }
[JsonPropertyName("minRequestedBulletAmount")]
public int MinimumRequestedBulletAmount { get; set; }
public int? MinimumRequestedBulletAmount { get; set; }
[JsonPropertyName("maxRequestedBulletAmount")]
public int MaximumRequestedBulletAmount { get; set; }
public int? MaximumRequestedBulletAmount { get; set; }
[JsonPropertyName("useWhitelist")]
public bool UseWhitelist { get; set; }
public bool? UseWhitelist { get; set; }
[JsonPropertyName("useBlacklist")]
public bool UseBlacklist { get; set; }
public bool? UseBlacklist { get; set; }
}
public class Pickup : BaseQuestConfig
{
[JsonPropertyName("ItemTypeToFetchWithMaxCount")]
public List<PickupTypeWithMaxCount> ItemTypeToFetchWithMaxCount { get; set; }
public List<PickupTypeWithMaxCount>? ItemTypeToFetchWithMaxCount { get; set; }
public List<string> ItemTypesToFetch { get; set; }
public List<string>? ItemTypesToFetch { get; set; }
[JsonPropertyName("maxItemFetchCount")]
public int? MaxItemFetchCount { get; set; }
@@ -268,116 +269,116 @@ public class Pickup : BaseQuestConfig
public class PickupTypeWithMaxCount
{
[JsonPropertyName("itemType")]
public string ItemType { get; set; }
public string? ItemType { get; set; }
[JsonPropertyName("maxPickupCount")]
public int MaximumPickupCount { get; set; }
public int? MaximumPickupCount { get; set; }
[JsonPropertyName("minPickupCount")]
public int MinimumPickupCount { get; set; }
public int? MinimumPickupCount { get; set; }
}
public class EliminationConfig : BaseQuestConfig
{
[JsonPropertyName("levelRange")]
public MinMax LevelRange { get; set; }
public MinMax? LevelRange { get; set; }
[JsonPropertyName("targets")]
public List<Target> Targets { get; set; }
public List<Target>? Targets { get; set; }
[JsonPropertyName("bodyPartProb")]
public double BodyPartProbability { get; set; }
public double? BodyPartProbability { get; set; }
[JsonPropertyName("bodyParts")]
public List<BodyPart> BodyParts { get; set; }
public List<BodyPart>? BodyParts { get; set; }
[JsonPropertyName("specificLocationProb")]
public double SpecificLocationProbability { get; set; }
public double? SpecificLocationProbability { get; set; }
[JsonPropertyName("distLocationBlacklist")]
public List<string> DistLocationBlacklist { get; set; }
public List<string>? DistLocationBlacklist { get; set; }
[JsonPropertyName("distProb")]
public double DistanceProbability { get; set; }
public double? DistanceProbability { get; set; }
[JsonPropertyName("maxDist")]
public double MaxDistance { get; set; }
public double? MaxDistance { get; set; }
[JsonPropertyName("minDist")]
public double MinDistance { get; set; }
public double? MinDistance { get; set; }
[JsonPropertyName("maxKills")]
public int MaxKills { get; set; }
public int? MaxKills { get; set; }
[JsonPropertyName("minKills")]
public int MinKills { get; set; }
public int? MinKills { get; set; }
[JsonPropertyName("minBossKills")]
public int MinBossKills { get; set; }
public int? MinBossKills { get; set; }
[JsonPropertyName("maxBossKills")]
public int MaxBossKills { get; set; }
public int? MaxBossKills { get; set; }
[JsonPropertyName("minPmcKills")]
public int MinPmcKills { get; set; }
public int? MinPmcKills { get; set; }
[JsonPropertyName("maxPmcKills")]
public int MaxPmcKills { get; set; }
public int? MaxPmcKills { get; set; }
[JsonPropertyName("weaponCategoryRequirementProb")]
public double WeaponCategoryRequirementProbability { get; set; }
public double? WeaponCategoryRequirementProbability { get; set; }
[JsonPropertyName("weaponCategoryRequirements")]
public List<WeaponRequirement> WeaponCategoryRequirements { get; set; }
public List<WeaponRequirement>? WeaponCategoryRequirements { get; set; }
[JsonPropertyName("weaponRequirementProb")]
public double WeaponRequirementProbability { get; set; }
public double? WeaponRequirementProbability { get; set; }
[JsonPropertyName("weaponRequirements")]
public List<WeaponRequirement> WeaponRequirements { get; set; }
public List<WeaponRequirement>? WeaponRequirements { get; set; }
}
public class BaseQuestConfig
{
[JsonPropertyName("possibleSkillRewards")]
public List<string> PossibleSkillRewards { get; set; }
public List<string>? PossibleSkillRewards { get; set; }
}
public class Target : ProbabilityObject
{
[JsonPropertyName("data")]
public BossInfo Data { get; set; }
public BossInfo? Data { get; set; }
}
public class BossInfo
{
[JsonPropertyName("isBoss")]
public bool IsBoss { get; set; }
public bool? IsBoss { get; set; }
[JsonPropertyName("isPmc")]
public bool IsPmc { get; set; }
public bool? IsPmc { get; set; }
}
public class BodyPart : ProbabilityObject
{
[JsonPropertyName("data")]
public string[] Data { get; set; }
public List<string>? Data { get; set; }
}
public class WeaponRequirement : ProbabilityObject
{
[JsonPropertyName("data")]
public string[] Data { get; set; }
public List<string>? Data { get; set; }
}
public class ProbabilityObject
{
[JsonPropertyName("key")]
public string Key { get; set; }
public string? Key { get; set; }
[JsonPropertyName("relativeProbability")]
public double RelativeProbability { get; set; }
public double? RelativeProbability { get; set; }
[JsonPropertyName("data")]
public object Data { get; set; }
public object? Data { get; set; }
}
+10 -10
View File
@@ -236,8 +236,8 @@ public class BotLootCacheService
// Assign whitelisted special items to bot if any exist
var specialLootItems =
botJsonTemplate.BotGeneration.Items.SpecialItems.Whitelist.Count > 0
? botJsonTemplate.BotGeneration.Items.SpecialItems.Whitelist
botJsonTemplate.BotGeneration?.Items?.SpecialItems?.Whitelist?.Count > 0
? botJsonTemplate.BotGeneration?.Items?.SpecialItems?.Whitelist
: new Dictionary<string, double>();
// no whitelist, find and assign from combined item pool
@@ -256,8 +256,8 @@ public class BotLootCacheService
// Assign whitelisted healing items to bot if any exist
var healingItems =
botJsonTemplate.BotGeneration.Items.Healing.Whitelist.Count > 0
? botJsonTemplate.BotGeneration.Items.Healing.Whitelist
botJsonTemplate.BotGeneration?.Items?.Healing?.Whitelist?.Count > 0
? botJsonTemplate.BotGeneration?.Items?.Healing?.Whitelist
: new Dictionary<string, double>();
// No whitelist, find and assign from combined item pool
@@ -279,7 +279,7 @@ public class BotLootCacheService
}
// Assign whitelisted drugs to bot if any exist
var drugItems = botJsonTemplate.BotGeneration.Items.Drugs.Whitelist ?? new Dictionary<string, double>();
var drugItems = botJsonTemplate.BotGeneration?.Items?.Drugs?.Whitelist ?? new Dictionary<string, double>();
// no drugs whitelist, find and assign from combined item pool
if (!drugItems.Any())
{
@@ -294,7 +294,7 @@ public class BotLootCacheService
}
// Assign whitelisted food to bot if any exist
var foodItems = botJsonTemplate.BotGeneration.Items.Food.Whitelist ?? new Dictionary<string, double>();
var foodItems = botJsonTemplate.BotGeneration?.Items?.Food?.Whitelist ?? new Dictionary<string, double>();
// No food whitelist, find and assign from combined item pool
if (!foodItems.Any())
{
@@ -309,7 +309,7 @@ public class BotLootCacheService
}
// Assign whitelisted drink to bot if any exist
var drinkItems = botJsonTemplate.BotGeneration.Items.Food.Whitelist ?? new Dictionary<string, double>();
var drinkItems = botJsonTemplate.BotGeneration?.Items?.Food?.Whitelist ?? new Dictionary<string, double>();
// No drink whitelist, find and assign from combined item pool
if (!drinkItems.Any())
{
@@ -324,7 +324,7 @@ public class BotLootCacheService
}
// Assign whitelisted currency to bot if any exist
var currencyItems = botJsonTemplate.BotGeneration.Items.Currency.Whitelist ?? new Dictionary<string, double>();
var currencyItems = botJsonTemplate.BotGeneration?.Items?.Currency?.Whitelist ?? new Dictionary<string, double>();
// No currency whitelist, find and assign from combined item pool
if (!currencyItems.Any())
{
@@ -339,7 +339,7 @@ public class BotLootCacheService
}
// Assign whitelisted stims to bot if any exist
var stimItems = botJsonTemplate.BotGeneration.Items.Stims.Whitelist ?? new Dictionary<string, double>();
var stimItems = botJsonTemplate.BotGeneration?.Items?.Stims?.Whitelist ?? new Dictionary<string, double>();
// No whitelist, find and assign from combined item pool
if (!stimItems.Any())
{
@@ -354,7 +354,7 @@ public class BotLootCacheService
}
// Assign whitelisted grenades to bot if any exist
var grenadeItems = botJsonTemplate.BotGeneration.Items.Grenades.Whitelist ?? new Dictionary<string, double>();
var grenadeItems = botJsonTemplate.BotGeneration?.Items?.Grenades?.Whitelist ?? new Dictionary<string, double>();
// no whitelist, find and assign from combined item pool
if (!grenadeItems.Any())
{
+2 -2
View File
@@ -130,8 +130,8 @@ public class MailSendService
string messageLocaleId,
List<Item>? items,
long? maxStorageTimeSeconds,
SystemData? systemData,
MessageContentRagfair? ragfair
SystemData? systemData = null,
MessageContentRagfair? ragfair = null
)
{
if (trader is null)