From cf2a2ae899cab07272fee383eb5cbd9ca1286aad Mon Sep 17 00:00:00 2001 From: Chomp Date: Thu, 17 Aug 2023 09:24:49 +0100 Subject: [PATCH] Fix blacklisted quests getting into output file --- GenerateQuestFile/Program.cs | 8 ++++---- QuestValidator.Common/Helpers/QuestHelper.cs | 11 +++++------ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/GenerateQuestFile/Program.cs b/GenerateQuestFile/Program.cs index 5a6b6dd..d08e0ef 100644 --- a/GenerateQuestFile/Program.cs +++ b/GenerateQuestFile/Program.cs @@ -36,17 +36,16 @@ namespace GenerateQuestFile OutputQuestRequirementsToConsole(mergedLiveData.data); - JsonWriter.WriteJson(mergedLiveData, "output", Directory.GetCurrentDirectory(), "mergedlivejson"); + JsonWriter.WriteJson(mergedLiveData, "output", Directory.GetCurrentDirectory(), "mergedlivejson"); - // Find the quests that are missing from the live file from existing quest data + // Find the quests that are missing from the live file from existing quests.json var missingQuests = GetMissingQuestsNotInLiveFile(existingQuestData, mergedLiveData, questBlacklist); // Create a list of quests to output // Use all quests in live file // Use quests from quests.json to fill in missing quests - var questsToOutputToFile = new Dictionary(); - // Add live quests to collection to return later + var questsToOutputToFile = new Dictionary(); foreach (var liveQuest in mergedLiveData.data) { questsToOutputToFile.Add(liveQuest._id, liveQuest); @@ -486,6 +485,7 @@ namespace GenerateQuestFile { if (blacklistedQuests.Contains(quest._id)) { + LoggingHelpers.LogInfo($"Skipping quest: {quest.QuestName}"); continue; } diff --git a/QuestValidator.Common/Helpers/QuestHelper.cs b/QuestValidator.Common/Helpers/QuestHelper.cs index bb7358e..e05f772 100644 --- a/QuestValidator.Common/Helpers/QuestHelper.cs +++ b/QuestValidator.Common/Helpers/QuestHelper.cs @@ -42,12 +42,12 @@ namespace AssortGenerator.Common.Helpers /// public static QuestRoot MergeLiveQuestFiles(List liveQuestDataFiles, List questBlacklist) { - QuestRoot mergedResult = null; + QuestRoot mergedResult = new QuestRoot + { + data = new List() + }; foreach (var liveQuestDataFile in liveQuestDataFiles) { - // If null, use whole file - mergedResult ??= liveQuestDataFile; - foreach (var quest in liveQuestDataFile.data) { // Skip quests on blacklist @@ -60,7 +60,7 @@ namespace AssortGenerator.Common.Helpers var mergedExistingQuest = mergedResult.data.FirstOrDefault(x => x._id == quest._id); if (mergedExistingQuest != null) { - // new quest has more avail for start conditions, use instead + // new quest has more `avail for start` conditions, use instead if (mergedExistingQuest.conditions.AvailableForStart.Count < quest.conditions.AvailableForStart.Count) { mergedExistingQuest = quest; @@ -68,7 +68,6 @@ namespace AssortGenerator.Common.Helpers continue; } - LoggingHelpers.LogWarning($"Missing quest {quest._id} {QuestNames.GetNameById(quest._id)} found in subsequent live quest dump"); mergedResult.data.Add(quest); } }