chore: fix QuestDefinitionCatalogLoader analyzer warnings
parent
fbb248770f
commit
39805ef8e6
|
|
@ -260,33 +260,25 @@ public static class QuestDefinitionCatalogLoader
|
||||||
objectiveIdsSeen = new HashSet<string>(StringComparer.Ordinal);
|
objectiveIdsSeen = new HashSet<string>(StringComparer.Ordinal);
|
||||||
var parsedSteps = new List<QuestStepDefRow>();
|
var parsedSteps = new List<QuestStepDefRow>();
|
||||||
|
|
||||||
var stepsNode = rowObj["steps"] as JsonArray;
|
var stepsNode = rowObj["steps"];
|
||||||
if (stepsNode is null)
|
if (stepsNode is not JsonArray stepsArray)
|
||||||
{
|
{
|
||||||
steps = parsedSteps;
|
steps = parsedSteps;
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var si = 0; si < stepsNode.Count; si++)
|
for (var si = 0; si < stepsArray.Count; si++)
|
||||||
{
|
{
|
||||||
if (stepsNode[si] is not JsonObject stepObj)
|
if (stepsArray[si] is not JsonObject stepObj)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var sid = (stepObj["id"] as JsonValue)?.GetValue<string>();
|
var sid = (stepObj["id"] as JsonValue)?.GetValue<string>();
|
||||||
if (sid is not null)
|
if (sid is not null && !stepIdsSeen.Add(sid))
|
||||||
{
|
|
||||||
if (stepIdsSeen.Contains(sid))
|
|
||||||
{
|
{
|
||||||
errors.Add($"error: {path} quests[{questIndex}] steps[{si}]: duplicate step id '{sid}'");
|
errors.Add($"error: {path} quests[{questIndex}] steps[{si}]: duplicate step id '{sid}'");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
stepIdsSeen.Add(sid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var objectivesNode = stepObj["objectives"] as JsonArray;
|
if (stepObj["objectives"] is not JsonArray objectivesNode)
|
||||||
if (objectivesNode is null)
|
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (var oi = 0; oi < objectivesNode.Count; oi++)
|
for (var oi = 0; oi < objectivesNode.Count; oi++)
|
||||||
|
|
@ -295,25 +287,18 @@ public static class QuestDefinitionCatalogLoader
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var oid = (objObj["id"] as JsonValue)?.GetValue<string>();
|
var oid = (objObj["id"] as JsonValue)?.GetValue<string>();
|
||||||
if (oid is not null)
|
if (oid is not null && !objectiveIdsSeen.Add(oid))
|
||||||
{
|
|
||||||
if (objectiveIdsSeen.Contains(oid))
|
|
||||||
{
|
{
|
||||||
errors.Add(
|
errors.Add(
|
||||||
$"error: {path} quests[{questIndex}] steps[{si}] objectives[{oi}]: " +
|
$"error: {path} quests[{questIndex}] steps[{si}] objectives[{oi}]: " +
|
||||||
$"duplicate objective id '{oid}' within quest");
|
$"duplicate objective id '{oid}' within quest");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
objectiveIdsSeen.Add(oid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var si = 0; si < stepsNode.Count; si++)
|
for (var si = 0; si < stepsArray.Count; si++)
|
||||||
{
|
{
|
||||||
if (stepsNode[si] is JsonObject stepObj)
|
if (stepsArray[si] is JsonObject stepObj)
|
||||||
parsedSteps.Add(ParseStep(stepObj));
|
parsedSteps.Add(ParseStep(stepObj));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -331,7 +316,7 @@ public static class QuestDefinitionCatalogLoader
|
||||||
return new QuestDefRow(id, displayName, prerequisiteQuestIds, steps, completionRewardBundle, factionGateRules);
|
return new QuestDefRow(id, displayName, prerequisiteQuestIds, steps, completionRewardBundle, factionGateRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IReadOnlyList<FactionGateRuleRow> ParseFactionGateRules(JsonArray? array)
|
private static List<FactionGateRuleRow> ParseFactionGateRules(JsonArray? array)
|
||||||
{
|
{
|
||||||
if (array is null || array.Count == 0)
|
if (array is null || array.Count == 0)
|
||||||
return [];
|
return [];
|
||||||
|
|
@ -361,7 +346,7 @@ public static class QuestDefinitionCatalogLoader
|
||||||
return new QuestRewardBundleRow(itemGrants, skillXpGrants, reputationGrants);
|
return new QuestRewardBundleRow(itemGrants, skillXpGrants, reputationGrants);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IReadOnlyList<ReputationGrantRow> ParseReputationGrantRows(JsonArray? array)
|
private static List<ReputationGrantRow> ParseReputationGrantRows(JsonArray? array)
|
||||||
{
|
{
|
||||||
if (array is null || array.Count == 0)
|
if (array is null || array.Count == 0)
|
||||||
return [];
|
return [];
|
||||||
|
|
@ -380,7 +365,7 @@ public static class QuestDefinitionCatalogLoader
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IReadOnlyList<RewardGrantRow> ParseItemGrantRows(JsonArray? array)
|
private static List<RewardGrantRow> ParseItemGrantRows(JsonArray? array)
|
||||||
{
|
{
|
||||||
if (array is null || array.Count == 0)
|
if (array is null || array.Count == 0)
|
||||||
return [];
|
return [];
|
||||||
|
|
@ -399,7 +384,7 @@ public static class QuestDefinitionCatalogLoader
|
||||||
return rows;
|
return rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IReadOnlyList<QuestSkillXpGrantRow> ParseSkillXpGrantRows(JsonArray? array)
|
private static List<QuestSkillXpGrantRow> ParseSkillXpGrantRows(JsonArray? array)
|
||||||
{
|
{
|
||||||
if (array is null || array.Count == 0)
|
if (array is null || array.Count == 0)
|
||||||
return [];
|
return [];
|
||||||
|
|
@ -457,7 +442,7 @@ public static class QuestDefinitionCatalogLoader
|
||||||
return new QuestObjectiveDefRow(id, kind, itemId, quantity, recipeId, encounterId);
|
return new QuestObjectiveDefRow(id, kind, itemId, quantity, recipeId, encounterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IReadOnlyList<string> ParseStringArray(JsonArray? array)
|
private static List<string> ParseStringArray(JsonArray? array)
|
||||||
{
|
{
|
||||||
if (array is null)
|
if (array is null)
|
||||||
return [];
|
return [];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue