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

@ -84,7 +84,7 @@ namespace GenerateQuestFile
AddQuestName(quest);
var originalQuest = existingQuestData.FirstOrDefault(x => x.Key == quest.Key).Value;
if (originalQuest is null)
{
LoggingHelpers.LogWarning($"Cant check for original start conditions. Unable to find original quest {quest.Key} {QuestHelper.GetQuestNameById(quest.Key)}, skipping.");
@ -112,37 +112,65 @@ namespace GenerateQuestFile
if (questRequirements is null || questRequirements.Count == 0)
{
LoggingHelpers.LogWarning($"Quest requirement not found for : {quest.Value.QuestName}, skipping.");
continue;
}
foreach (var requirement in questRequirements)
{
// Does quest have requirement
if (!quest.Value.conditions.AvailableForStart.Any(x => x._parent == "Quest"
&& x._props.target.ToString() == requirement.Quest.Id))
if (requirement.PreReqType == PreRequisiteType.Quest)
{
LoggingHelpers.LogSuccess($"{quest.Value.QuestName} needs a prereq of quest {requirement.Quest.Name}, adding.");
quest.Value.conditions.AvailableForStart.Add(new AvailableFor
// Does quest have requirement
if (!quest.Value.conditions.AvailableForStart.Any(x => x._parent == "Quest"
&& x._props.target.ToString() == requirement.Quest.Id))
{
_parent = "Quest",
_props = new AvailableForProps
LoggingHelpers.LogSuccess($"{quest.Value.QuestName} needs a prereq of quest {requirement.Quest.Name}, adding.");
quest.Value.conditions.AvailableForStart.Add(new AvailableFor
{
id = Sha256(new DateTime().ToString()),
index = quest.Value.conditions.AvailableForStart.Count,
parentId = "",
status = GetQuestStatus(requirement.QuestStatus),
target = requirement.Quest.Id,
visibilityConditions = new List<object>(),
availableAfter = 0
_parent = "Quest",
_props = new AvailableForProps
{
id = Sha256(new DateTime().ToString()),
index = quest.Value.conditions.AvailableForStart.Count,
parentId = "",
status = GetQuestStatus(requirement.QuestStatus),
target = requirement.Quest.Id,
visibilityConditions = new List<object>(),
availableAfter = 0
}
}
);
}
else
{
if (questRequirements != null)
{
LoggingHelpers.LogInfo($"{quest.Value.QuestName} already has prereq of quest {requirement.Quest.Name}, skipping.");
}
}
);
}
else
if (requirement.PreReqType == PreRequisiteType.Level)
{
if (questRequirements != null)
if (!quest.Value.conditions.AvailableForStart.Any(x => x._parent == "Level"
&& int.Parse((string)x._props.value) == requirement.Level))
{
LoggingHelpers.LogInfo($"{quest.Value.QuestName} already has prereq of quest {requirement.Quest.Name}, skipping.");
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>()
}
}
);
}
}
}
@ -166,8 +194,8 @@ namespace GenerateQuestFile
}
}
}
// JsonWriter.WriteJson<QuestRoot>(output, "output", Directory.GetCurrentDirectory(), "questRequirements");
// JsonWriter.WriteJson<QuestRoot>(output, "output", Directory.GetCurrentDirectory(), "questRequirements");
}
private static void OutputQuestRequirementsToConsole2(Dictionary<string, Quest> quests)
@ -230,7 +258,7 @@ namespace GenerateQuestFile
// findInRaid
foreach (var success in quest.Value.rewards.Success)
{
if (string.Equals(success.type, "item", StringComparison.OrdinalIgnoreCase)
if (string.Equals(success.type, "item", StringComparison.OrdinalIgnoreCase)
&& success.findInRaid == null)
{
success.findInRaid = true;
@ -286,18 +314,18 @@ namespace GenerateQuestFile
{
questRequirementToAdd._props.availableAfter = 0;
}
if (questRequirementToAdd._props.visibilityConditions == null || !questRequirementToAdd._props.visibilityConditions.Any())
{
questRequirementToAdd._props.visibilityConditions = new List<object>();
}
questRequirementToAdd._props.index = questToUpdate.Value.conditions.AvailableForStart.Count;
}
// Already exists, skip
if(questToUpdate.Value.conditions.AvailableForStart
if (questToUpdate.Value.conditions.AvailableForStart
.Any(x => x._props.target?.ToString() == questRequirementToAdd._props.target?.ToString()
&& x._parent == questRequirementToAdd._parent))
{

View File

@ -15,7 +15,16 @@ namespace QuestValidator.Common.Helpers
{
// 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;
}
@ -23,8 +32,10 @@ namespace QuestValidator.Common.Helpers
public class PreRequisite
{
public PreRequisiteType PreReqType { get; set; }
public QuestStatus QuestStatus { get; set; }
public QuestData Quest { get; set; }
public int Level { get; set; }
}
private static readonly Dictionary<Quest, QuestData> questWithPreceedingQuestDict = new Dictionary<Quest, QuestData>
@ -359,7 +370,8 @@ namespace QuestValidator.Common.Helpers
.AddPrerequisiteQuest(Quest.ShakingUpTeller, QuestStatus.Success) },
{ Quest.Import, GetQuestData(Quest.Import)
.AddPrerequisiteQuest(Quest.FarmingP4, QuestStatus.Success) },
{ Quest.Collector, GetQuestData(Quest.Collector) },
{ Quest.Collector, GetQuestData(Quest.Collector)
.AddPrerequisiteLevel(50)},
{ Quest.Introduction, GetQuestData(Quest.Introduction)
.AddPrerequisiteQuest(Quest.GunsmithP1, QuestStatus.Started)},
{ Quest.Acquaintance, GetQuestData(Quest.Acquaintance)
@ -687,7 +699,7 @@ namespace QuestValidator.Common.Helpers
// .AddPrerequisiteQuest(Quest., QuestStatus.Success)}
};
private static QuestData GetQuestData(Quest quest)
private static QuestData GetQuestData(Quest quest)
{
return new QuestData
{