- Add a few missing properties in QuestRewardUpd
- Make quest diffs more deterministic by copying IDs from previous quest.json files where possible, and generating deterministic random IDs when we need new ones
This commit is contained in:
parent
7ab86d43be
commit
d259bf3fb9
@ -103,6 +103,9 @@ namespace GenerateQuestFile
|
|||||||
{
|
{
|
||||||
AddMissingFailRewards(originalQuest, quest);
|
AddMissingFailRewards(originalQuest, quest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To make diffs more sane, copy the random IDs from the existing quests.json if possible
|
||||||
|
CopyExistingRandomIds(originalQuest, quest.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over quest objects a final time and add hard coded quest requirements if they dont already exist
|
// Iterate over quest objects a final time and add hard coded quest requirements if they dont already exist
|
||||||
@ -125,12 +128,14 @@ namespace GenerateQuestFile
|
|||||||
&& x._props.target.ToString() == requirement.Quest.Id))
|
&& x._props.target.ToString() == requirement.Quest.Id))
|
||||||
{
|
{
|
||||||
LoggingHelpers.LogSuccess($"{quest.Value.QuestName} needs a prereq of quest {requirement.Quest.Name}, adding.");
|
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
|
quest.Value.conditions.AvailableForStart.Add(new AvailableFor
|
||||||
{
|
{
|
||||||
_parent = "Quest",
|
_parent = "Quest",
|
||||||
_props = new AvailableForProps
|
_props = new AvailableForProps
|
||||||
{
|
{
|
||||||
id = Sha256(new DateTime().ToString()),
|
id = Sha256(hashData),
|
||||||
index = quest.Value.conditions.AvailableForStart.Count,
|
index = quest.Value.conditions.AvailableForStart.Count,
|
||||||
parentId = "",
|
parentId = "",
|
||||||
status = GetQuestStatus(requirement.QuestStatus),
|
status = GetQuestStatus(requirement.QuestStatus),
|
||||||
@ -165,12 +170,14 @@ namespace GenerateQuestFile
|
|||||||
&& int.Parse(x._props.value.ToString()) == requirement.Level))
|
&& int.Parse(x._props.value.ToString()) == requirement.Level))
|
||||||
{
|
{
|
||||||
LoggingHelpers.LogSuccess($"{quest.Value.QuestName} needs a prereq of level {requirement.Level}, adding.");
|
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
|
quest.Value.conditions.AvailableForStart.Add(new AvailableFor
|
||||||
{
|
{
|
||||||
_parent = "Level",
|
_parent = "Level",
|
||||||
_props = new AvailableForProps
|
_props = new AvailableForProps
|
||||||
{
|
{
|
||||||
id = Sha256(new DateTime().ToString()),
|
id = Sha256(hashData),
|
||||||
index = quest.Value.conditions.AvailableForStart.Count,
|
index = quest.Value.conditions.AvailableForStart.Count,
|
||||||
parentId = "",
|
parentId = "",
|
||||||
dynamicLocale = false,
|
dynamicLocale = false,
|
||||||
@ -191,6 +198,13 @@ namespace GenerateQuestFile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To make diffs more sane, copy the random IDs from the existing quests.json if possible
|
||||||
|
var originalQuest = existingQuestData.FirstOrDefault(x => x.Key == quest.Key).Value;
|
||||||
|
if (originalQuest != null)
|
||||||
|
{
|
||||||
|
CopyExistingRandomIds(originalQuest, quest.Value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
OutputQuestRequirementsToConsole2(questsToOutputToFile);
|
OutputQuestRequirementsToConsole2(questsToOutputToFile);
|
||||||
JsonWriter.WriteJson(questsToOutputToFile, "output", Directory.GetCurrentDirectory(), "quests");
|
JsonWriter.WriteJson(questsToOutputToFile, "output", Directory.GetCurrentDirectory(), "quests");
|
||||||
@ -298,6 +312,79 @@ namespace GenerateQuestFile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void CopyExistingRandomIds(Quest originalQuest, Quest quest)
|
||||||
|
{
|
||||||
|
CopyRewardRandomIds(originalQuest.rewards.Started, quest.rewards.Started);
|
||||||
|
CopyRewardRandomIds(originalQuest.rewards.Success, quest.rewards.Success);
|
||||||
|
CopyRewardRandomIds(originalQuest.rewards.Fail, quest.rewards.Fail);
|
||||||
|
|
||||||
|
CopyConditionRandomIds(originalQuest.conditions.AvailableForStart, quest.conditions.AvailableForStart);
|
||||||
|
CopyConditionRandomIds(originalQuest.conditions.AvailableForFinish, quest.conditions.AvailableForFinish);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CopyRewardRandomIds(List<RewardStatus> originalRewards, List<RewardStatus> rewards)
|
||||||
|
{
|
||||||
|
foreach (var reward in rewards)
|
||||||
|
{
|
||||||
|
var originalReward = originalRewards.FirstOrDefault(x => x.id == reward.id);
|
||||||
|
if (originalReward == null)
|
||||||
|
{
|
||||||
|
LoggingHelpers.LogWarning($"Unable to find matching original reward for {reward.id}. Skipping.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
reward.target = originalReward.target;
|
||||||
|
|
||||||
|
if (reward.items != null)
|
||||||
|
{
|
||||||
|
foreach (var item in reward.items)
|
||||||
|
{
|
||||||
|
QuestRewardItem originalItem = originalReward.items.FirstOrDefault(x => x._tpl == item._tpl && x.slotId == item.slotId);
|
||||||
|
if (originalItem == null)
|
||||||
|
{
|
||||||
|
LoggingHelpers.LogWarning($"Unable to find matching original reward item for {reward.id}-{item._tpl}. Skipping");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
item._id = originalItem._id;
|
||||||
|
item.parentId = originalItem.parentId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allow stripping all whitespace in a string, used for comparing _props.target, which may have differing whitespace but still match
|
||||||
|
private static readonly Regex whitespace = new Regex(@"\s+");
|
||||||
|
private static string StripAllWhitespace(string input)
|
||||||
|
{
|
||||||
|
if (input == null)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return whitespace.Replace(input, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CopyConditionRandomIds(List<AvailableFor> originalConditions, List<AvailableFor> conditions)
|
||||||
|
{
|
||||||
|
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())
|
||||||
|
);
|
||||||
|
|
||||||
|
if (originalCondition == null)
|
||||||
|
{
|
||||||
|
LoggingHelpers.LogWarning($"Unable to find matching original condition for {condition._parent}-{StripAllWhitespace(condition._props.target?.ToString())}. Skipping.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
condition._props.id = originalCondition._props.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check original quest for start conditions and if missing from new quest, add them
|
/// Check original quest for start conditions and if missing from new quest, add them
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -325,7 +412,6 @@ namespace GenerateQuestFile
|
|||||||
if (questRequirementToAdd._parent == "Quest")
|
if (questRequirementToAdd._parent == "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._props.target} {QuestHelper.GetQuestNameById(questRequirementToAdd._props.target?.ToString())}");
|
||||||
questRequirementToAdd._props.id = Sha256(new DateTime().ToString());
|
|
||||||
|
|
||||||
if (!questRequirementToAdd._props.availableAfter.HasValue)
|
if (!questRequirementToAdd._props.availableAfter.HasValue)
|
||||||
{
|
{
|
||||||
|
@ -160,6 +160,8 @@ namespace QuestValidator.Models
|
|||||||
public int? StackObjectsCount { get; set; }
|
public int? StackObjectsCount { get; set; }
|
||||||
public FireModeReward FireMode { get; set; }
|
public FireModeReward FireMode { get; set; }
|
||||||
public FoldeableReward Foldable { get; set; }
|
public FoldeableReward Foldable { get; set; }
|
||||||
|
public bool? SpawnedInSession { get; set; }
|
||||||
|
public object? Repairable { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FireModeReward
|
public class FireModeReward
|
||||||
|
Loading…
x
Reference in New Issue
Block a user