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; }