From f21da306fbdbdaa264d95e59a2c841f63da15585 Mon Sep 17 00:00:00 2001 From: Chomp Date: Thu, 17 Aug 2023 09:06:12 +0100 Subject: [PATCH] Add blacklist + include terragroup trial quests in it --- GenerateQuestFile/Examples/blacklist.json | 21 +++++++++++++ GenerateQuestFile/Program.cs | 12 +++++-- QuestValidator.Common/Helpers/QuestHelper.cs | 33 +++++++++++++++++--- 3 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 GenerateQuestFile/Examples/blacklist.json diff --git a/GenerateQuestFile/Examples/blacklist.json b/GenerateQuestFile/Examples/blacklist.json new file mode 100644 index 0000000..44bfc01 --- /dev/null +++ b/GenerateQuestFile/Examples/blacklist.json @@ -0,0 +1,21 @@ +[ + "64b90786bbf5bf2b460ad982", + "64b90792f43eebce7c01e7af", + "64b907978d327e5bf9085bd9", + "64b9079cdd13d43b9d01d6cd", + "64b907a49ff61a79b10fab9c", + "64b907a85e9b86ab7a08cf0d", + "64b907ad60d47bcb98044d10", + "64b907b205b23872610c0794", + "64b907b5b1548514f3015707", + "64b907bae1ed4f11f209e8de", + "64b907bd55f4156df8007d14", + "64b907c29bd0fad76c072e97", + "64b907c4e87866541c0d747e", + "64b907cabbf5bf2b460ad984", + "64b907cef43eebce7c01e7b1", + "64b907d18d327e5bf9085bdb", + "64b907d7dd13d43b9d01d6cf", + "64b907dc9ff61a79b10fab9e", + "64bd4f1d4c2e9f141400bf07" +] \ No newline at end of file diff --git a/GenerateQuestFile/Program.cs b/GenerateQuestFile/Program.cs index cb6ab8c..5a6b6dd 100644 --- a/GenerateQuestFile/Program.cs +++ b/GenerateQuestFile/Program.cs @@ -28,17 +28,18 @@ namespace GenerateQuestFile InputFileHelper.SetInputFiles(inputPath); // Read in quest files + var questBlacklist = QuestHelper.GetQuestBlacklist(); var existingQuestData = QuestHelper.GetQuestData(); var liveQuestData = QuestHelper.GetLiveQuestData(); - var mergedLiveData = QuestHelper.MergeLiveQuestFiles(liveQuestData); + var mergedLiveData = QuestHelper.MergeLiveQuestFiles(liveQuestData, questBlacklist); OutputQuestRequirementsToConsole(mergedLiveData.data); JsonWriter.WriteJson(mergedLiveData, "output", Directory.GetCurrentDirectory(), "mergedlivejson"); // Find the quests that are missing from the live file from existing quest data - var missingQuests = GetMissingQuestsNotInLiveFile(existingQuestData, mergedLiveData); + var missingQuests = GetMissingQuestsNotInLiveFile(existingQuestData, mergedLiveData, questBlacklist); // Create a list of quests to output // Use all quests in live file @@ -475,7 +476,7 @@ namespace GenerateQuestFile /// /// Loop over live quests and use if it exists, otherwise use existing data /// - private static List GetMissingQuestsNotInLiveFile(Dictionary existingQuests, QuestRoot liveQuestData) + private static List GetMissingQuestsNotInLiveFile(Dictionary existingQuests, QuestRoot liveQuestData, List blacklistedQuests) { var missingQuestsToReturn = new List(); foreach (var quest in existingQuests.Values) @@ -483,6 +484,11 @@ namespace GenerateQuestFile var liveQuest = liveQuestData.data.Find(x => x._id == quest._id); if (liveQuest is null) { + if (blacklistedQuests.Contains(quest._id)) + { + continue; + } + missingQuestsToReturn.Add(quest); LoggingHelpers.LogError($"ERROR Quest {quest._id} {QuestHelper.GetQuestNameById(quest._id)} missing in live file. Will use fallback quests.json"); } diff --git a/QuestValidator.Common/Helpers/QuestHelper.cs b/QuestValidator.Common/Helpers/QuestHelper.cs index 3cc1729..bb7358e 100644 --- a/QuestValidator.Common/Helpers/QuestHelper.cs +++ b/QuestValidator.Common/Helpers/QuestHelper.cs @@ -1,6 +1,7 @@ using QuestValidator.Common.Helpers; using QuestValidator.Models; using QuestValidator.Models.Other; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -14,6 +15,7 @@ namespace AssortGenerator.Common.Helpers private static List _liveQuestData; private static Dictionary _questData; + private static List _questBlacklistData; private static List _assortUnlocks; public static Dictionary GetQuestData(string filename = "quests") @@ -38,7 +40,7 @@ namespace AssortGenerator.Common.Helpers /// /// /// - public static QuestRoot MergeLiveQuestFiles(List liveQuestDataFiles) + public static QuestRoot MergeLiveQuestFiles(List liveQuestDataFiles, List questBlacklist) { QuestRoot mergedResult = null; foreach (var liveQuestDataFile in liveQuestDataFiles) @@ -48,8 +50,14 @@ namespace AssortGenerator.Common.Helpers foreach (var quest in liveQuestDataFile.data) { - // Already has quest - var mergedExistingQuest = mergedResult.data.Find(x => x._id == quest._id); + // Skip quests on blacklist + if (questBlacklist.Contains(quest._id)) + { + continue; + } + + // Already has quest, skip + var mergedExistingQuest = mergedResult.data.FirstOrDefault(x => x._id == quest._id); if (mergedExistingQuest != null) { // new quest has more avail for start conditions, use instead @@ -60,7 +68,7 @@ namespace AssortGenerator.Common.Helpers continue; } - LoggingHelpers.LogWarning($"missing quest {quest._id} {QuestNames.GetNameById(quest._id)} found in subsequent live quest dump"); + LoggingHelpers.LogWarning($"Missing quest {quest._id} {QuestNames.GetNameById(quest._id)} found in subsequent live quest dump"); mergedResult.data.Add(quest); } } @@ -131,5 +139,22 @@ namespace AssortGenerator.Common.Helpers var filesInPath = Directory.GetFiles(iconPath); return filesInPath.Any(x => x.Contains(imageId)); } + + public static List GetQuestBlacklist() + { + if (_questBlacklistData is null) + { + var questBlacklistPath = InputFileHelper.GetInputFilePaths().FirstOrDefault(x => x.Contains("blacklist")); + if (questBlacklistPath is null) + { + return null; + } + + var questBlacklistJson = File.ReadAllText(questBlacklistPath); + _questBlacklistData = JsonSerializer.Deserialize>(questBlacklistJson); + } + + return _questBlacklistData; + } } }