Add blacklist + include terragroup trial quests in it

This commit is contained in:
Chomp 2023-08-17 09:06:12 +01:00
parent 8e8d5f31ab
commit f21da306fb
3 changed files with 59 additions and 7 deletions

View File

@ -0,0 +1,21 @@
[
"64b90786bbf5bf2b460ad982",
"64b90792f43eebce7c01e7af",
"64b907978d327e5bf9085bd9",
"64b9079cdd13d43b9d01d6cd",
"64b907a49ff61a79b10fab9c",
"64b907a85e9b86ab7a08cf0d",
"64b907ad60d47bcb98044d10",
"64b907b205b23872610c0794",
"64b907b5b1548514f3015707",
"64b907bae1ed4f11f209e8de",
"64b907bd55f4156df8007d14",
"64b907c29bd0fad76c072e97",
"64b907c4e87866541c0d747e",
"64b907cabbf5bf2b460ad984",
"64b907cef43eebce7c01e7b1",
"64b907d18d327e5bf9085bdb",
"64b907d7dd13d43b9d01d6cf",
"64b907dc9ff61a79b10fab9e",
"64bd4f1d4c2e9f141400bf07"
]

View File

@ -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<QuestRoot>(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
/// <summary>
/// Loop over live quests and use if it exists, otherwise use existing data
/// </summary>
private static List<Quest> GetMissingQuestsNotInLiveFile(Dictionary<string, Quest> existingQuests, QuestRoot liveQuestData)
private static List<Quest> GetMissingQuestsNotInLiveFile(Dictionary<string, Quest> existingQuests, QuestRoot liveQuestData, List<string> blacklistedQuests)
{
var missingQuestsToReturn = new List<Quest>();
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");
}

View File

@ -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<QuestRoot> _liveQuestData;
private static Dictionary<string, QuestValidator.Models.Quest> _questData;
private static List<string> _questBlacklistData;
private static List<AssortUnlocks> _assortUnlocks;
public static Dictionary<string, QuestValidator.Models.Quest> GetQuestData(string filename = "quests")
@ -38,7 +40,7 @@ namespace AssortGenerator.Common.Helpers
/// </summary>
/// <param name="liveQuestDataFiles"></param>
/// <returns></returns>
public static QuestRoot MergeLiveQuestFiles(List<QuestRoot> liveQuestDataFiles)
public static QuestRoot MergeLiveQuestFiles(List<QuestRoot> liveQuestDataFiles, List<string> 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<string> 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<List<string>>(questBlacklistJson);
}
return _questBlacklistData;
}
}
}