From 71d376874968815e2a3b58b7b4083927ac51765e Mon Sep 17 00:00:00 2001 From: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Date: Wed, 10 May 2023 21:20:12 -0700 Subject: [PATCH] - Get the next index for quest props based on the previous index, instead of the count, to avoid duplicate indexes - Include counter ID comparison for condition copy, so we don't copy the wrong ID for counters --- GenerateQuestFile/Program.cs | 19 +++++++++++++++---- QuestValidator.Models/Input/Quest.cs | 3 ++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/GenerateQuestFile/Program.cs b/GenerateQuestFile/Program.cs index 595a737..7f4f97d 100644 --- a/GenerateQuestFile/Program.cs +++ b/GenerateQuestFile/Program.cs @@ -136,7 +136,7 @@ namespace GenerateQuestFile _props = new AvailableForProps { id = Sha256(hashData), - index = quest.Value.conditions.AvailableForStart.Count, + index = GetNextIndex(quest.Value.conditions.AvailableForStart.LastOrDefault()?._props?.index), parentId = "", status = GetQuestStatus(requirement.QuestStatus), target = requirement.Quest.Id, @@ -178,7 +178,7 @@ namespace GenerateQuestFile _props = new AvailableForProps { id = Sha256(hashData), - index = quest.Value.conditions.AvailableForStart.Count, + index = GetNextIndex(quest.Value.conditions.AvailableForStart.LastOrDefault()?._props?.index), parentId = "", dynamicLocale = false, value = requirement.Level, @@ -372,7 +372,8 @@ namespace GenerateQuestFile var originalCondition = originalConditions.FirstOrDefault( x => x._parent == condition._parent && x._props.index == condition._props.index && - StripAllWhitespace(x._props.target?.ToString()) == StripAllWhitespace(condition._props.target?.ToString()) + StripAllWhitespace(x._props.target?.ToString()) == StripAllWhitespace(condition._props.target?.ToString()) && + x._props.counter?.id == condition._props.counter?.id ); if (originalCondition == null) @@ -423,7 +424,7 @@ namespace GenerateQuestFile questRequirementToAdd._props.visibilityConditions = new List(); } - questRequirementToAdd._props.index = questToUpdate.Value.conditions.AvailableForStart.Count; + questRequirementToAdd._props.index = GetNextIndex(questToUpdate.Value.conditions.AvailableForStart.LastOrDefault()?._props?.index); } @@ -494,5 +495,15 @@ namespace GenerateQuestFile return missingQuestsToReturn; } + + private static int GetNextIndex(int? previousIndex) + { + if (previousIndex == null) + { + return 0; + } + + return previousIndex.Value + 1; + } } } diff --git a/QuestValidator.Models/Input/Quest.cs b/QuestValidator.Models/Input/Quest.cs index f39247a..5c43eba 100644 --- a/QuestValidator.Models/Input/Quest.cs +++ b/QuestValidator.Models/Input/Quest.cs @@ -68,6 +68,7 @@ namespace QuestValidator.Models public class Counter { public string id { get; set; } + public object conditions { get; set; } } public class AvailableFor @@ -79,7 +80,7 @@ namespace QuestValidator.Models public class AvailableForProps { - public object counter { get; set;} + public Counter counter { get; set;} public int? dogtagLevel { get; set; } public string id { get; set; } public int? index { get; set; }