diff --git a/Core/Generators/RepeatableQuestGenerator.cs b/Core/Generators/RepeatableQuestGenerator.cs index bf567386..c690ad82 100644 --- a/Core/Generators/RepeatableQuestGenerator.cs +++ b/Core/Generators/RepeatableQuestGenerator.cs @@ -13,6 +13,7 @@ using System.Collections.Generic; using Core.Helpers; using Core.Services; using Core.Utils.Collections; +using Core.Utils.Extensions; using BodyPart = Core.Models.Spt.Config.BodyPart; namespace Core.Generators; @@ -145,8 +146,8 @@ public class RepeatableQuestGenerator var maxKillDifficulty = eliminationConfig.MaxKills; - targetsConfig = targetsConfig.Where((x) => questTypePool.Pool.Elimination.Targets.Contains(x.Key)); - if (targetsConfig.Count == 0 || targetsConfig.All((x) => x.Data.IsBoss)) + targetsConfig = (ProbabilityObjectArray)targetsConfig.Where((x) => questTypePool.Pool.Elimination.Targets.Contains(x.Key)); + if (targetsConfig.Count == 0 || targetsConfig.All((x) => x.Data.IsBoss.GetValueOrDefault(false))) { // There are no more targets left for elimination; delete it as a possible quest type // also if only bosses are left we need to leave otherwise it's a guaranteed boss elimination diff --git a/Core/Models/Spt/Repeatable/QuestTypePool.cs b/Core/Models/Spt/Repeatable/QuestTypePool.cs index 760e57f3..25a34a87 100644 --- a/Core/Models/Spt/Repeatable/QuestTypePool.cs +++ b/Core/Models/Spt/Repeatable/QuestTypePool.cs @@ -1,6 +1,8 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Text.Json.Serialization; +using Core.Models.Eft.Common.Tables; using Core.Models.Enums; +using Core.Utils.Extensions; namespace Core.Models.Spt.Repeatable; @@ -71,6 +73,14 @@ public record EliminationTargetPool [JsonPropertyName("bossBoarSniper")] public TargetLocation? BossBoarSniper { get; set; } + + public EliminationTargetPool this[string toLower] + { + get + { + return (EliminationTargetPool?)GetType().GetProperties().SingleOrDefault(p => p.GetJsonName() == toLower)?.GetValue(this); + } + } } public record TargetLocation diff --git a/Core/Utils/Extensions/ObjectExtensions.cs b/Core/Utils/Extensions/ObjectExtensions.cs new file mode 100644 index 00000000..b3b1d961 --- /dev/null +++ b/Core/Utils/Extensions/ObjectExtensions.cs @@ -0,0 +1,10 @@ +namespace Core.Utils.Extensions +{ + public static class ObjectExtensions + { + public static bool Contains(this object obj, T key) + { + return obj.GetType().GetProperties().Any(x => x.Name == key.ToString()); + } + } +}