Update models to match new bsg structure

This commit is contained in:
Chomp 2023-12-27 18:00:29 +00:00
parent 2a10b22de4
commit 713f1ce51c
2 changed files with 86 additions and 76 deletions

View File

@ -125,25 +125,22 @@ namespace GenerateQuestFile
if (requirement.PreReqType == PreRequisiteType.Quest)
{
// Does quest have requirement
if (!quest.Value.conditions.AvailableForStart.Any(x => x._parent == "Quest"
&& x._props.target.ToString() == requirement.Quest.Id))
if (!quest.Value.conditions.AvailableForStart.Any(x => x.conditionType == "Quest"
&& x.target.ToString() == requirement.Quest.Id))
{
LoggingHelpers.LogSuccess($"{quest.Value.QuestName} needs a prereq of quest {requirement.Quest.Name}, adding.");
string hashData = quest.Value._id + requirement.Quest.Id;
quest.Value.conditions.AvailableForStart.Add(new AvailableFor
{
_parent = "Quest",
_props = new AvailableForProps
{
id = Sha256(hashData),
index = GetNextIndex(quest.Value.conditions.AvailableForStart.LastOrDefault()?._props?.index),
parentId = "",
status = GetQuestStatus(requirement.QuestStatus),
target = requirement.Quest.Id,
visibilityConditions = new List<object>(),
availableAfter = 0
}
conditionType = "Quest",
id = Sha256(hashData),
index = GetNextIndex(quest.Value.conditions.AvailableForStart.LastOrDefault()?.index),
parentId = "",
status = GetQuestStatus(requirement.QuestStatus),
target = requirement.Quest.Id,
visibilityConditions = new List<object>(),
availableAfter = 0
}
);
}
@ -159,7 +156,7 @@ namespace GenerateQuestFile
if (requirement.PreReqType == PreRequisiteType.RemoveQuest)
{
if (quest.Value.conditions.AvailableForStart.RemoveAll(x =>
x._parent == "Quest" && x._props.target.ToString() == requirement.Quest.Id) > 0)
x.conditionType == "Quest" && x.target.ToString() == requirement.Quest.Id) > 0)
{
LoggingHelpers.LogSuccess($"{quest.Value.QuestName} required {requirement.Quest.Name}, removing.");
}
@ -167,25 +164,22 @@ namespace GenerateQuestFile
if (requirement.PreReqType == PreRequisiteType.Level)
{
if (!quest.Value.conditions.AvailableForStart.Any(x => x._parent == "Level"
&& int.Parse(x._props.value.ToString()) == requirement.Level))
if (!quest.Value.conditions.AvailableForStart.Any(x => x.conditionType == "Level"
&& int.Parse(x.value.ToString()) == requirement.Level))
{
LoggingHelpers.LogSuccess($"{quest.Value.QuestName} needs a prereq of level {requirement.Level}, adding.");
string hashData = quest.Value._id + "Level";
quest.Value.conditions.AvailableForStart.Add(new AvailableFor
{
_parent = "Level",
_props = new AvailableForProps
{
id = Sha256(hashData),
index = GetNextIndex(quest.Value.conditions.AvailableForStart.LastOrDefault()?._props?.index),
parentId = "",
dynamicLocale = false,
value = requirement.Level,
compareMethod = ">=",
visibilityConditions = new List<object>()
}
conditionType = "Level",
id = Sha256(hashData),
index = GetNextIndex(quest.Value.conditions.AvailableForStart.LastOrDefault()?.index),
parentId = "",
dynamicLocale = false,
value = requirement.Level,
compareMethod = ">=",
visibilityConditions = new List<object>()
}
);
}
@ -193,7 +187,7 @@ namespace GenerateQuestFile
if (requirement.PreReqType == PreRequisiteType.RemoveLevel)
{
if (quest.Value.conditions.AvailableForStart.RemoveAll(x => x._parent == "Level") > 0)
if (quest.Value.conditions.AvailableForStart.RemoveAll(x => x.conditionType == "Level") > 0)
{
LoggingHelpers.LogSuccess($"{quest.Value.QuestName} required level {requirement.Level}, removing.");
}
@ -216,12 +210,12 @@ namespace GenerateQuestFile
var output = new List<string>();
foreach (var quest in quests)
{
var questConditions = quest.conditions.AvailableForStart.Where(x => x._parent == "Quest");
var questConditions = quest.conditions.AvailableForStart.Where(x => x.conditionType == "Quest");
if (questConditions != null)
{
foreach (var questCondition in questConditions)
{
var x = questCondition._props.target.ToString();
var x = questCondition.target.ToString();
Console.WriteLine($"{QuestHelper.GetQuestNameById(quest._id)} needs {QuestHelper.GetQuestNameById(x)}");
}
}
@ -235,12 +229,12 @@ namespace GenerateQuestFile
var output = new List<string>();
foreach (var quest in quests)
{
var questConditions = quest.Value.conditions.AvailableForStart.Where(x => x._parent == "Quest");
var questConditions = quest.Value.conditions.AvailableForStart.Where(x => x.conditionType == "Quest");
if (questConditions != null)
{
foreach (var questCondition in questConditions)
{
var x = questCondition._props.target.ToString();
var x = questCondition.target.ToString();
Console.WriteLine($"{QuestHelper.GetQuestNameById(quest.Value._id)} needs {QuestHelper.GetQuestNameById(x)}");
}
}
@ -376,19 +370,19 @@ namespace GenerateQuestFile
foreach (var condition in conditions)
{
var originalCondition = originalConditions.FirstOrDefault(
x => x._parent == condition._parent &&
x._props.index == condition._props.index &&
StripAllWhitespace(x._props.target?.ToString()) == StripAllWhitespace(condition._props.target?.ToString()) &&
x._props.counter?.id == condition._props.counter?.id
x => x.conditionType == condition.conditionType &&
x.index == condition.index &&
StripAllWhitespace(x.target?.ToString()) == StripAllWhitespace(condition.target?.ToString()) &&
x.counter?.id == condition.counter?.id
);
if (originalCondition == null)
{
LoggingHelpers.LogWarning($"Unable to find matching original condition for {condition._parent}-{StripAllWhitespace(condition._props.target?.ToString())}. Skipping.");
LoggingHelpers.LogWarning($"Unable to find matching original condition for {condition.conditionType}-{StripAllWhitespace(condition.target?.ToString())}. Skipping.");
continue;
}
condition._props.id = originalCondition._props.id;
condition.id = originalCondition.id;
}
}
@ -411,33 +405,33 @@ namespace GenerateQuestFile
// continue;
//}
if (questToUpdate.Value.conditions.AvailableForStart.Any(x => string.Equals(x._parent, "quest", StringComparison.CurrentCultureIgnoreCase)))
if (questToUpdate.Value.conditions.AvailableForStart.Any(x => string.Equals(x.conditionType, "quest", StringComparison.CurrentCultureIgnoreCase)))
{
continue;
}
if (questRequirementToAdd._parent == "Quest")
if (questRequirementToAdd.conditionType == "Quest")
{
LoggingHelpers.LogInfo($"Quest {questToUpdate.Value.QuestName} missing AvailableForStart quest requirement, adding prereq of {questRequirementToAdd._props.target} {QuestHelper.GetQuestNameById(questRequirementToAdd._props.target?.ToString())}");
LoggingHelpers.LogInfo($"Quest {questToUpdate.Value.QuestName} missing AvailableForStart quest requirement, adding prereq of {questRequirementToAdd.target} {QuestHelper.GetQuestNameById(questRequirementToAdd.target?.ToString())}");
if (!questRequirementToAdd._props.availableAfter.HasValue)
if (!questRequirementToAdd.availableAfter.HasValue)
{
questRequirementToAdd._props.availableAfter = 0;
questRequirementToAdd.availableAfter = 0;
}
if (questRequirementToAdd._props.visibilityConditions == null || !questRequirementToAdd._props.visibilityConditions.Any())
if (questRequirementToAdd.visibilityConditions == null || !questRequirementToAdd.visibilityConditions.Any())
{
questRequirementToAdd._props.visibilityConditions = new List<object>();
questRequirementToAdd.visibilityConditions = new List<object>();
}
questRequirementToAdd._props.index = GetNextIndex(questToUpdate.Value.conditions.AvailableForStart.LastOrDefault()?._props?.index);
questRequirementToAdd.index = GetNextIndex(questToUpdate.Value.conditions.AvailableForStart.LastOrDefault()?.index);
}
// Already exists, skip
if (questToUpdate.Value.conditions.AvailableForStart
.Any(x => x._props.target?.ToString() == questRequirementToAdd._props.target?.ToString()
&& x._parent == questRequirementToAdd._parent))
.Any(x => x.target?.ToString() == questRequirementToAdd.target?.ToString()
&& x.conditionType == questRequirementToAdd.conditionType))
{
continue;
}
@ -445,9 +439,9 @@ namespace GenerateQuestFile
questToUpdate.Value.conditions.AvailableForStart.Add(questRequirementToAdd);
}
if (questToUpdate.Value.conditions.AvailableForStart.Count(x => x._parent == "Quest") > 1)
if (questToUpdate.Value.conditions.AvailableForStart.Count(x => x.conditionType == "Quest") > 1)
{
LoggingHelpers.LogWarning($"Quest {questToUpdate.Value.QuestName} has {questToUpdate.Value.conditions.AvailableForStart.Count(x => x._parent == "Quest")} quest prereqs, is this correct?");
LoggingHelpers.LogWarning($"Quest {questToUpdate.Value.QuestName} has {questToUpdate.Value.conditions.AvailableForStart.Count(x => x.conditionType == "Quest")} quest prereqs, is this correct?");
}
}

View File

@ -17,7 +17,7 @@ namespace QuestValidator.Models
public string acceptPlayerMessage { get;set;}
public string changeQuestMessageText { get;set;}
public string completePlayerMessage { get; set; }
public Conditions conditions { get; set; }
public QuestConditions conditions { get; set; }
public string description { get;set;}
public string failMessageText { get; set; }
public string name { get; set; }
@ -35,36 +35,16 @@ namespace QuestValidator.Models
public string successMessageText { get; set; }
public string templateId { get; set; }
public Rewards rewards { get; set; }
public string? side { get; set; }
}
public class Conditions
public class QuestConditions
{
public string _parent { get; set; }
public ConditionProps _props { get; set; }
public List<AvailableFor> AvailableForFinish { get; set; }
public List<AvailableFor> AvailableForStart { get; set; }
public List<AvailableFor> Fail { get; set; }
}
public class ConditionProps
{
public string compareMethod { get; set; }
public string id { get; set; }
public object target { get; set; }
public string value { get; set; }
public Counter counter { get; set; }
public int index { get; set; }
public string parentId { get; set; }
public string type { get; set; }
public int? dogtagLevel { get; set; }
public object maxDurability { get; set; }
public int? minDurability { get; set; }
public List<object> visibilityConditions { get; set; }
public List<int> status { get; set; }
}
public class Counter
{
public string id { get; set; }
@ -73,15 +53,51 @@ namespace QuestValidator.Models
public class AvailableFor
{
public string _parent { get; set; }
public AvailableForProps _props { get; set; }
public bool dynamicLocale { get;set;}
public string conditionType { get; set; }
public Counter counter { get; set; }
public object dogtagLevel { get; set; }
public string id { get; set; }
public int? index { get; set; }
public object maxDurability { get; set; }
public object minDurability { get; set; }
public string parentId { get; set; }
public bool? resetOnSessionEnd { get; set; }
public bool? isEncoded { get; set; }
public bool? onlyFoundInRaid { get; set; }
public bool? oneSessionOnly { get; set; }
public bool dynamicLocale { get; set; }
public object? plantTime { get; set; }
public string zoneId { get; set; }
public object target { get; set; }
public string type { get; set; }
public bool? countInRaid { get; set; }
public object status { get; set; }
public bool? unknown { get; set; }
public bool? doNotResetIfCounterCompleted { get; set; }
public object value { get; set; }
public int? availableAfter { get; set; }
public int? dispersion { get; set; }
public string compareMethod { get; set; }
public List<object> visibilityConditions { get; set; }
public SkillCondition baseAccuracy { get; set; }
public SkillCondition durability { get; set; }
public SkillCondition effectiveDistance { get; set; }
public SkillCondition emptyTacticalSlot { get; set; }
public SkillCondition ergonomics { get; set; }
public SkillCondition height { get; set; }
public SkillCondition magazineCapacity { get; set; }
public SkillCondition muzzleVelocity { get; set; }
public SkillCondition recoil { get; set; }
public SkillCondition weight { get; set; }
public SkillCondition width { get; set; }
public object containsItems { get; set; }
public object hasItemFromCategory { get; set; }
}
public class AvailableForProps
{
public Counter counter { get; set;}
public int? dogtagLevel { get; set; }
public object dogtagLevel { get; set; }
public string id { get; set; }
public int? index { get; set; }
public object maxDurability { get; set; }