From 202abcf3a805039d712ddedf31909bdfabfb5b0b Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Mon, 15 Jul 2024 23:09:09 +0200 Subject: [PATCH] Add a (dev) option to not load certain quests --- QuestPathGenerator/QuestSourceGenerator.cs | 3 +++ QuestPaths/quest-v1.json | 3 +++ Questionable.Model/V1/QuestRoot.cs | 1 + Questionable/Controller/QuestRegistry.cs | 13 +++++++++++-- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/QuestPathGenerator/QuestSourceGenerator.cs b/QuestPathGenerator/QuestSourceGenerator.cs index de026fc0e..c58378854 100644 --- a/QuestPathGenerator/QuestSourceGenerator.cs +++ b/QuestPathGenerator/QuestSourceGenerator.cs @@ -79,6 +79,9 @@ public class QuestSourceGenerator : ISourceGenerator } var quest = questNode.Deserialize()!; + if (quest.Disabled) + continue; + quests.Add((id, quest)); } diff --git a/QuestPaths/quest-v1.json b/QuestPaths/quest-v1.json index 04b2a1fdd..d22e38bf5 100644 --- a/QuestPaths/quest-v1.json +++ b/QuestPaths/quest-v1.json @@ -19,6 +19,9 @@ "type": "string" } }, + "Disabled": { + "type": "boolean" + }, "Comment": { "type": "string" }, diff --git a/Questionable.Model/V1/QuestRoot.cs b/Questionable.Model/V1/QuestRoot.cs index 880e34ce2..60693898c 100644 --- a/Questionable.Model/V1/QuestRoot.cs +++ b/Questionable.Model/V1/QuestRoot.cs @@ -6,6 +6,7 @@ public sealed class QuestRoot { public string Author { get; set; } = null!; public List Contributors { get; set; } = new(); + public bool Disabled { get; set; } public string? Comment { get; set; } public List TerritoryBlacklist { get; set; } = new(); public List QuestSequence { get; set; } = new(); diff --git a/Questionable/Controller/QuestRegistry.cs b/Questionable/Controller/QuestRegistry.cs index dc656fbc6..96d5c8478 100644 --- a/Questionable/Controller/QuestRegistry.cs +++ b/Questionable/Controller/QuestRegistry.cs @@ -130,7 +130,8 @@ internal sealed class QuestRegistry var distinctSequenceCount = quest.Root.QuestSequence.Select(x => x.Sequence).Distinct().Count(); if (totalSequenceCount != distinctSequenceCount) { - _logger.LogWarning("Quest has duplicate sequence numbers: {QuestId} / {QuestName}", quest.QuestId, + _logger.LogWarning("Quest has duplicate sequence numbers: {QuestId} / {QuestName}", + quest.QuestId, quest.Info.Name); ++foundProblems; } @@ -196,7 +197,8 @@ internal sealed class QuestRegistry { _logger.LogWarning( "Quest step has duplicate completion flags: {QuestId} / {QuestName} → {Sequence} → {Flags}", - quest.QuestId, quest.Info.Name, sequence.Sequence, string.Join(", ", duplicate.First())); + quest.QuestId, quest.Info.Name, sequence.Sequence, + string.Join(", ", duplicate.First())); ++foundProblems; } } @@ -231,6 +233,13 @@ internal sealed class QuestRegistry Root = JsonSerializer.Deserialize(stream)!, Info = _questData.GetQuestInfo(questId.Value), }; + if (quest.Root.Disabled) + { + _logger.LogWarning("Quest {QuestId} / {QuestName} is disabled and won't be loaded", questId, + quest.Info.Name); + return; + } + _quests[questId.Value] = quest; }