Add ability to insert level prereqs to quest + add prereq of level 50 to Collector

This commit is contained in:
Chomp 2023-01-24 09:59:24 +00:00
parent 016a2343fa
commit ed81b572f8
2 changed files with 68 additions and 28 deletions

View File

@ -112,10 +112,13 @@ namespace GenerateQuestFile
if (questRequirements is null || questRequirements.Count == 0) if (questRequirements is null || questRequirements.Count == 0)
{ {
LoggingHelpers.LogWarning($"Quest requirement not found for : {quest.Value.QuestName}, skipping."); LoggingHelpers.LogWarning($"Quest requirement not found for : {quest.Value.QuestName}, skipping.");
continue; continue;
} }
foreach (var requirement in questRequirements) foreach (var requirement in questRequirements)
{
if (requirement.PreReqType == PreRequisiteType.Quest)
{ {
// Does quest have requirement // Does quest have requirement
if (!quest.Value.conditions.AvailableForStart.Any(x => x._parent == "Quest" if (!quest.Value.conditions.AvailableForStart.Any(x => x._parent == "Quest"
@ -146,6 +149,31 @@ namespace GenerateQuestFile
} }
} }
} }
if (requirement.PreReqType == PreRequisiteType.Level)
{
if (!quest.Value.conditions.AvailableForStart.Any(x => x._parent == "Level"
&& int.Parse((string)x._props.value) == requirement.Level))
{
LoggingHelpers.LogSuccess($"{quest.Value.QuestName} needs a prereq of level {requirement.Level}, adding.");
quest.Value.conditions.AvailableForStart.Add(new AvailableFor
{
_parent = "Level",
_props = new AvailableForProps
{
id = Sha256(new DateTime().ToString()),
index = quest.Value.conditions.AvailableForStart.Count,
parentId = "",
dynamicLocale = false,
value = requirement.Level,
compareMethod = ">=",
visibilityConditions = new List<object>()
}
}
);
}
}
}
} }
OutputQuestRequirementsToConsole2(questsToOutputToFile); OutputQuestRequirementsToConsole2(questsToOutputToFile);
JsonWriter.WriteJson(questsToOutputToFile, "output", Directory.GetCurrentDirectory(), "quests"); JsonWriter.WriteJson(questsToOutputToFile, "output", Directory.GetCurrentDirectory(), "quests");

View File

@ -15,7 +15,16 @@ namespace QuestValidator.Common.Helpers
{ {
// TODO: add check if desired prereq is same id as quest, prevent it // TODO: add check if desired prereq is same id as quest, prevent it
(PreRequisites ??= new List<PreRequisite>()).Add(new PreRequisite { Quest = GetQuestData(quest), QuestStatus = status }); (PreRequisites ??= new List<PreRequisite>()).Add(new PreRequisite { PreReqType = PreRequisiteType.Quest, Quest = GetQuestData(quest), QuestStatus = status });
return this;
}
public QuestData AddPrerequisiteLevel(int level)
{
// TODO: add check if level prereq exits already, dont add
(PreRequisites ??= new List<PreRequisite>()).Add(new PreRequisite { PreReqType = PreRequisiteType.Level, Level = level });
return this; return this;
} }
@ -23,8 +32,10 @@ namespace QuestValidator.Common.Helpers
public class PreRequisite public class PreRequisite
{ {
public PreRequisiteType PreReqType { get; set; }
public QuestStatus QuestStatus { get; set; } public QuestStatus QuestStatus { get; set; }
public QuestData Quest { get; set; } public QuestData Quest { get; set; }
public int Level { get; set; }
} }
private static readonly Dictionary<Quest, QuestData> questWithPreceedingQuestDict = new Dictionary<Quest, QuestData> private static readonly Dictionary<Quest, QuestData> questWithPreceedingQuestDict = new Dictionary<Quest, QuestData>
@ -359,7 +370,8 @@ namespace QuestValidator.Common.Helpers
.AddPrerequisiteQuest(Quest.ShakingUpTeller, QuestStatus.Success) }, .AddPrerequisiteQuest(Quest.ShakingUpTeller, QuestStatus.Success) },
{ Quest.Import, GetQuestData(Quest.Import) { Quest.Import, GetQuestData(Quest.Import)
.AddPrerequisiteQuest(Quest.FarmingP4, QuestStatus.Success) }, .AddPrerequisiteQuest(Quest.FarmingP4, QuestStatus.Success) },
{ Quest.Collector, GetQuestData(Quest.Collector) }, { Quest.Collector, GetQuestData(Quest.Collector)
.AddPrerequisiteLevel(50)},
{ Quest.Introduction, GetQuestData(Quest.Introduction) { Quest.Introduction, GetQuestData(Quest.Introduction)
.AddPrerequisiteQuest(Quest.GunsmithP1, QuestStatus.Started)}, .AddPrerequisiteQuest(Quest.GunsmithP1, QuestStatus.Started)},
{ Quest.Acquaintance, GetQuestData(Quest.Acquaintance) { Quest.Acquaintance, GetQuestData(Quest.Acquaintance)