From 060b25222f2b68f72acfaed3f0b97e628b30e436 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 17 Jan 2025 21:23:17 +0000 Subject: [PATCH] help --- Core/Generators/RepeatableQuestGenerator.cs | 13 +++---- Core/Helpers/RepeatableQuestHelper.cs | 10 +++--- Core/Models/Spt/Config/QuestConfig.cs | 10 +++--- .../Collections/ProbabilityObjectArray.cs | 34 ++++--------------- 4 files changed, 24 insertions(+), 43 deletions(-) diff --git a/Core/Generators/RepeatableQuestGenerator.cs b/Core/Generators/RepeatableQuestGenerator.cs index 3176ff09..098cdfe2 100644 --- a/Core/Generators/RepeatableQuestGenerator.cs +++ b/Core/Generators/RepeatableQuestGenerator.cs @@ -1,4 +1,4 @@ -using Core.Annotations; +using Core.Annotations; using Core.Models.Eft.Common; using Core.Models.Eft.Common.Tables; using Core.Models.Eft.Health; @@ -12,6 +12,8 @@ using static System.Runtime.InteropServices.JavaScript.JSType; using System.Collections.Generic; using Core.Helpers; using Core.Services; +using Core.Utils.Collections; +using BodyPart = Core.Models.Spt.Config.BodyPart; namespace Core.Generators; @@ -104,11 +106,10 @@ public class RepeatableQuestGenerator { var eliminationConfig = _repeatableQuestHelper.GetEliminationConfigByPmcLevel(pmcLevel, repeatableConfig); var locationsConfig = repeatableConfig.Locations; - var targetsConfig = _repeatableQuestHelper.ProbabilityObjectArray(eliminationConfig.Targets); - var bodypartsConfig = _repeatableQuestHelper.ProbabilityObjectArray>(eliminationConfig.BodyParts); - var weaponCategoryRequirementConfig = _repeatableQuestHelper.ProbabilityObjectArray>( - eliminationConfig.WeaponCategoryRequirements); - var weaponRequirementConfig = _repeatableQuestHelper.ProbabilityObjectArray>(eliminationConfig.WeaponRequirements); + var targetsConfig = _repeatableQuestHelper.ProbabilityObjectArray(eliminationConfig.Targets); + var bodypartsConfig = _repeatableQuestHelper.ProbabilityObjectArray>(eliminationConfig.BodyParts); + var weaponCategoryRequirementConfig = _repeatableQuestHelper.ProbabilityObjectArray>(eliminationConfig.WeaponCategoryRequirements); + var weaponRequirementConfig = _repeatableQuestHelper.ProbabilityObjectArray>(eliminationConfig.WeaponRequirements); // the difficulty of the quest varies in difficulty depending on the condition // possible conditions are diff --git a/Core/Helpers/RepeatableQuestHelper.cs b/Core/Helpers/RepeatableQuestHelper.cs index 9192d919..8e99551f 100644 --- a/Core/Helpers/RepeatableQuestHelper.cs +++ b/Core/Helpers/RepeatableQuestHelper.cs @@ -38,13 +38,13 @@ public class RepeatableQuestHelper ); } - public ProbabilityObjectArray - ProbabilityObjectArray( - List>? configArrayInput - ) + public ProbabilityObjectArray + ProbabilityObjectArray( + List? configArrayInput + ) where T : ProbabilityObject { var configArray = _cloner.Clone(configArrayInput); - var probabilityArray = new ProbabilityObjectArray(_mathUtil, _cloner, configArray); + var probabilityArray = new ProbabilityObjectArray(_mathUtil, _cloner, configArray); return probabilityArray; } } diff --git a/Core/Models/Spt/Config/QuestConfig.cs b/Core/Models/Spt/Config/QuestConfig.cs index c2bc7732..068426fe 100644 --- a/Core/Models/Spt/Config/QuestConfig.cs +++ b/Core/Models/Spt/Config/QuestConfig.cs @@ -1,4 +1,4 @@ -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; using Core.Models.Common; using Core.Models.Enums; using Core.Utils.Collections; @@ -65,7 +65,7 @@ public record QuestTypeIds [JsonPropertyName("exploration")] public string? Exploration { get; set; } - + [JsonPropertyName("pickup")] public string? Pickup { get; set; } } @@ -179,7 +179,7 @@ public record TraderWhitelist { [JsonPropertyName("name")] public string? Name { get; set; } - + [JsonPropertyName("traderId")] public string? TraderId { get; set; } @@ -260,9 +260,9 @@ public record Pickup : BaseQuestConfig { [JsonPropertyName("ItemTypeToFetchWithMaxCount")] public List? ItemTypeToFetchWithMaxCount { get; set; } - + public List? ItemTypesToFetch { get; set; } - + [JsonPropertyName("maxItemFetchCount")] public int? MaxItemFetchCount { get; set; } } diff --git a/Core/Utils/Collections/ProbabilityObjectArray.cs b/Core/Utils/Collections/ProbabilityObjectArray.cs index b6b60411..3972a11c 100644 --- a/Core/Utils/Collections/ProbabilityObjectArray.cs +++ b/Core/Utils/Collections/ProbabilityObjectArray.cs @@ -18,7 +18,7 @@ namespace Core.Utils.Collections; * // count the elements which should be distributed according to the relative probabilities * res.filter(x => x==="b").reduce((sum, x) => sum + 1 , 0) */ -public class ProbabilityObjectArray : List> +public class ProbabilityObjectArray : List> where T : ProbabilityObject { private MathUtil _mathUtil; private ICloner _cloner; @@ -26,27 +26,7 @@ public class ProbabilityObjectArray : List> public ProbabilityObjectArray( MathUtil mathUtil, ICloner cloner, - ProbabilityObject[] items - ) : base(items) - { - _mathUtil = mathUtil; - _cloner = cloner; - } - - public ProbabilityObjectArray( - MathUtil mathUtil, - ICloner cloner, - List> items - ) : base(items) - { - _mathUtil = mathUtil; - _cloner = cloner; - } - - public ProbabilityObjectArray( - MathUtil mathUtil, - ICloner cloner, - ICollection> items + ICollection items ) : base(items) { _mathUtil = mathUtil; @@ -70,13 +50,13 @@ public class ProbabilityObjectArray : List> * Clone this ProbabilitObjectArray * @returns {ProbabilityObjectArray} Deep Copy of this ProbabilityObjectArray */ - public ProbabilityObjectArray Clone() + public ProbabilityObjectArray Clone() { var clone = _cloner.Clone(this); - var probabliltyObjects = new ProbabilityObjectArray( + var probabliltyObjects = new ProbabilityObjectArray( _mathUtil, _cloner, - new List>() + new List() ); probabliltyObjects.AddRange(clone); return probabliltyObjects; @@ -88,9 +68,9 @@ public class ProbabilityObjectArray : List> * @param {string} key The key of the element to drop * @returns {ProbabilityObjectArray} ProbabilityObjectArray without the dropped element */ - public ProbabilityObjectArray Drop(K key) + public ProbabilityObjectArray Drop(K key) { - return (ProbabilityObjectArray)this.Where((r) => !r.Key?.Equals(key) ?? false); + return (ProbabilityObjectArray)this.Where((r) => !r.Key?.Equals(key) ?? false); } /**