- 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
This commit is contained in:
DrakiaXYZ 2023-05-10 21:20:12 -07:00
parent d259bf3fb9
commit 71d3768749
2 changed files with 17 additions and 5 deletions

View File

@ -136,7 +136,7 @@ namespace GenerateQuestFile
_props = new AvailableForProps _props = new AvailableForProps
{ {
id = Sha256(hashData), id = Sha256(hashData),
index = quest.Value.conditions.AvailableForStart.Count, index = GetNextIndex(quest.Value.conditions.AvailableForStart.LastOrDefault()?._props?.index),
parentId = "", parentId = "",
status = GetQuestStatus(requirement.QuestStatus), status = GetQuestStatus(requirement.QuestStatus),
target = requirement.Quest.Id, target = requirement.Quest.Id,
@ -178,7 +178,7 @@ namespace GenerateQuestFile
_props = new AvailableForProps _props = new AvailableForProps
{ {
id = Sha256(hashData), id = Sha256(hashData),
index = quest.Value.conditions.AvailableForStart.Count, index = GetNextIndex(quest.Value.conditions.AvailableForStart.LastOrDefault()?._props?.index),
parentId = "", parentId = "",
dynamicLocale = false, dynamicLocale = false,
value = requirement.Level, value = requirement.Level,
@ -372,7 +372,8 @@ namespace GenerateQuestFile
var originalCondition = originalConditions.FirstOrDefault( var originalCondition = originalConditions.FirstOrDefault(
x => x._parent == condition._parent && x => x._parent == condition._parent &&
x._props.index == condition._props.index && 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) if (originalCondition == null)
@ -423,7 +424,7 @@ namespace GenerateQuestFile
questRequirementToAdd._props.visibilityConditions = new List<object>(); questRequirementToAdd._props.visibilityConditions = new List<object>();
} }
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; return missingQuestsToReturn;
} }
private static int GetNextIndex(int? previousIndex)
{
if (previousIndex == null)
{
return 0;
}
return previousIndex.Value + 1;
}
} }
} }

View File

@ -68,6 +68,7 @@ namespace QuestValidator.Models
public class Counter public class Counter
{ {
public string id { get; set; } public string id { get; set; }
public object conditions { get; set; }
} }
public class AvailableFor public class AvailableFor
@ -79,7 +80,7 @@ namespace QuestValidator.Models
public class AvailableForProps public class AvailableForProps
{ {
public object counter { get; set;} public Counter counter { get; set;}
public int? dogtagLevel { get; set; } public int? dogtagLevel { get; set; }
public string id { get; set; } public string id { get; set; }
public int? index { get; set; } public int? index { get; set; }