269 lines
12 KiB
C#
269 lines
12 KiB
C#
using AssortGenerator.Common.Helpers;
|
|
using QuestValidator.Common;
|
|
using QuestValidator.Common.Helpers;
|
|
using QuestValidator.Helpers;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace QuestValidator
|
|
{
|
|
class Program
|
|
{
|
|
static void Main(string[] args)
|
|
{
|
|
var inputPath = CreateWorkingFolders();
|
|
InputFileHelper.SetInputFiles(inputPath);
|
|
|
|
//read in quest file
|
|
var questData = QuestHelper.GetQuestData();
|
|
var liveQuestData = QuestHelper.GetLiveQuestData();
|
|
|
|
CheckForMissingQuestsInAkiFile(liveQuestData, questData);
|
|
|
|
foreach (var item in questData)
|
|
{
|
|
var quest = item.Value;
|
|
LogQuestDetails(quest);
|
|
|
|
// get live quest
|
|
var relatedLiveQuest = liveQuestData.data.FirstOrDefault(x => x._id == quest._id);
|
|
if (!ItemExists(relatedLiveQuest, "live quest. Live dump too old ?", 0))
|
|
{
|
|
LoggingHelpers.LogInfo("");
|
|
continue;
|
|
}
|
|
|
|
CheckRootItemValues(quest, relatedLiveQuest);
|
|
|
|
CheckSuccessRewardItems(quest, relatedLiveQuest);
|
|
|
|
CheckAvailableForFinishConditionItems(quest, relatedLiveQuest);
|
|
|
|
LoggingHelpers.LogInfo("");
|
|
LoggingHelpers.LogInfo("-----");
|
|
LoggingHelpers.LogInfo("");
|
|
}
|
|
}
|
|
|
|
private static void CheckAvailableForFinishConditionItems(Models.Quest quest, Models.Quest relatedLiveQuest)
|
|
{
|
|
foreach (var availableForFinishItem in quest.conditions.AvailableForFinish)
|
|
{
|
|
Models.AvailableFor liveFinishItem = relatedLiveQuest.conditions.AvailableForFinish.Find(x => x._props.id == availableForFinishItem._props.id);
|
|
if (!ItemExists(liveFinishItem, "AvailableForFinish item", availableForFinishItem._props.index.Value))
|
|
{
|
|
continue;
|
|
}
|
|
CheckValuesMatch(availableForFinishItem._props.parentId, liveFinishItem._props.parentId, "AvailableForFinish parentId mismatch", availableForFinishItem._props.id);
|
|
|
|
// check reset on session end
|
|
CheckValuesMatch(availableForFinishItem._props.resetOnSessionEnd, liveFinishItem._props.resetOnSessionEnd, "AvailableForFinish resetOnSessionEnd value mismatch", availableForFinishItem._props.id);
|
|
|
|
}
|
|
}
|
|
|
|
private static void CheckSuccessRewardItems(Models.Quest quest, Models.Quest relatedLiveQuest)
|
|
{
|
|
var liveQuestSuccessRewardItems = relatedLiveQuest.rewards.Success;
|
|
|
|
foreach (var questSuccessRewardItem in quest.rewards.Success.Where(x => x.type == "Item"))
|
|
{
|
|
var errorMessage = string.Empty;
|
|
// Get live reward item by index and type
|
|
var relatedLiveRewardItem = liveQuestSuccessRewardItems.Find(x => x.index == questSuccessRewardItem.index && x.type == "Item");
|
|
if (relatedLiveRewardItem == null)
|
|
{
|
|
// Get live reward item by templateId and type as we cant find it by index
|
|
relatedLiveRewardItem = liveQuestSuccessRewardItems.Find(x => x.items != null && x.items[0]?._tpl == questSuccessRewardItem.items[0]?._tpl && x.type == "Item");
|
|
if (relatedLiveRewardItem == null)
|
|
{
|
|
LoggingHelpers.LogError($"ERROR unable to find success reward item in live quest data by index: ({questSuccessRewardItem.index}) OR template id: {questSuccessRewardItem.items[0]._tpl}");
|
|
LoggingHelpers.LogError($"ERROR Skipping quest success item: {questSuccessRewardItem.id}");
|
|
continue;
|
|
}
|
|
}
|
|
//LoggingHelpers.LogInfo($"INFO Found live success reward item: {relatedLiveRewardItem.id}");
|
|
|
|
// Ensure target matches the objects items[0].id value
|
|
if (questSuccessRewardItem.items[0]?._id != questSuccessRewardItem.target)
|
|
{
|
|
LoggingHelpers.LogWarning($"WARNING target does not match first item: {questSuccessRewardItem.target}, expected {questSuccessRewardItem.items[0]?._id}");
|
|
}
|
|
|
|
// Check template ids match
|
|
CheckValuesMatch(questSuccessRewardItem.items[0]._tpl, relatedLiveRewardItem.items[0]._tpl, "mismatch for template id", questSuccessRewardItem.items[0]._id, true);
|
|
|
|
// Check value values match
|
|
CheckValuesMatch(questSuccessRewardItem.value, relatedLiveRewardItem.value, "mismatch for success item reward value", questSuccessRewardItem.id);
|
|
|
|
// Check item stack count
|
|
if (questSuccessRewardItem.items[0] != null && questSuccessRewardItem.items[0].upd != null)
|
|
{
|
|
CheckValuesMatch(questSuccessRewardItem.items[0].upd.StackObjectsCount, relatedLiveRewardItem.items[0].upd.StackObjectsCount, "mismatch for StackObjectsCount", questSuccessRewardItem.items[0]._id);
|
|
}
|
|
}
|
|
|
|
foreach (var questSuccessRewardItem in quest.rewards.Success.Where(x => x.type == "Experience"))
|
|
{
|
|
var relatedLiveRewardItem = liveQuestSuccessRewardItems.FirstOrDefault(x => x.type == "Experience");
|
|
if (!ItemExists(relatedLiveRewardItem, "experience success reward item", questSuccessRewardItem.index))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// check experience value matches
|
|
CheckValuesMatch(questSuccessRewardItem.value, relatedLiveRewardItem.value, "experience value mismatch");
|
|
}
|
|
|
|
foreach (var questSuccessRewardItem in quest.rewards.Success.Where(x => x.type == "TraderStanding"))
|
|
{
|
|
var relatedLiveRewardItem = liveQuestSuccessRewardItems.FirstOrDefault(x => x.target == questSuccessRewardItem.target && x.type == "TraderStanding");
|
|
if (!ItemExists(relatedLiveRewardItem, "TraderStanding success reward item", questSuccessRewardItem.index))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
// check standing value matches
|
|
CheckValuesMatch(questSuccessRewardItem.value, relatedLiveRewardItem.value, "trader standing value mismatch");
|
|
|
|
// check target value matches
|
|
CheckValuesMatch(questSuccessRewardItem.target, relatedLiveRewardItem.target, "trader target value mismatch");
|
|
}
|
|
}
|
|
|
|
private static void CheckRootItemValues(Models.Quest quest, Models.Quest relatedLiveQuest)
|
|
{
|
|
// Check image id matches
|
|
CheckValuesMatch(quest.image.Substring(0, quest.image.Length - 3), relatedLiveQuest?.image.Substring(0, relatedLiveQuest.image.Length - 3), "item path mismatch");
|
|
|
|
// Check started reward count matches
|
|
CheckValuesMatch(quest.rewards.Started.Count, relatedLiveQuest.rewards.Started.Count, "Started item count mismatch");
|
|
|
|
// Check success reward count matches
|
|
CheckValuesMatch(quest.rewards.Success.Count, relatedLiveQuest.rewards.Success.Count, "success item count mismatch");
|
|
|
|
// Check Fail reward count matches
|
|
CheckValuesMatch(quest.rewards.Fail.Count, relatedLiveQuest.rewards.Fail.Count, "fail item count mismatch");
|
|
|
|
// Check min level matches
|
|
CheckValuesMatch(quest.min_level, relatedLiveQuest.min_level, "min level value mismatch");
|
|
|
|
// Check location matches
|
|
CheckValuesMatch(quest.location, relatedLiveQuest.location, "location value mismatch");
|
|
|
|
// Check traderid matches
|
|
CheckValuesMatch(quest.traderId, relatedLiveQuest.traderId, "traderid value mismatch");
|
|
|
|
// Check type matches
|
|
CheckValuesMatch(quest.type, relatedLiveQuest.type, "quest type value mismatch");
|
|
}
|
|
|
|
private static void LogQuestDetails(Models.Quest quest)
|
|
{
|
|
var questName = QuestHelper.GetQuestNameById(quest._id);
|
|
LoggingHelpers.LogInfo($"### Quest name: {questName} ({quest._id})");
|
|
LoggingHelpers.LogInfo($"Wiki: https://escapefromtarkov.fandom.com/wiki/{questName.Replace(' ', '_')}");
|
|
}
|
|
|
|
private static bool ItemExists(object itemToCheck, string message, int index = -1)
|
|
{
|
|
if (itemToCheck == null)
|
|
{
|
|
if (index == -1)
|
|
{
|
|
LoggingHelpers.LogError($"ERROR no match found for {message}");
|
|
}
|
|
else
|
|
{
|
|
LoggingHelpers.LogError($"ERROR no match found for {message} at index: {index}");
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private static void CheckValuesMatch(int firstValue, int secondValue, string message, string associatedId = "")
|
|
{
|
|
if (firstValue != secondValue)
|
|
{
|
|
if (associatedId == string.Empty)
|
|
{
|
|
LoggingHelpers.LogWarning($"WARNING {message}: '{firstValue}', expected '{secondValue}'");
|
|
}
|
|
else
|
|
{
|
|
LoggingHelpers.LogWarning($"WARNING {associatedId} {message}: '{firstValue}', expected '{secondValue}'");
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void CheckValuesMatch(string firstValue, string secondValue, string message, string associatedId = "", bool performTemplateIdLookup = false)
|
|
{
|
|
if (firstValue != secondValue)
|
|
{
|
|
if (performTemplateIdLookup)
|
|
{
|
|
firstValue = $"{firstValue} ({ItemTemplateHelper.GetTemplateById(firstValue)._name})";
|
|
secondValue = $"{secondValue} ({ItemTemplateHelper.GetTemplateById(secondValue)._name})";
|
|
}
|
|
if (associatedId == string.Empty)
|
|
{
|
|
LoggingHelpers.LogWarning($"WARNING {message}: '{firstValue}', expected '{secondValue}'");
|
|
}
|
|
else
|
|
{
|
|
LoggingHelpers.LogWarning($"WARNING {associatedId} {message}: '{firstValue}', expected '{secondValue}'");
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void CheckValuesMatch(bool firstValue, bool secondValue, string message, string associatedId = "")
|
|
{
|
|
if (firstValue != secondValue)
|
|
{
|
|
if (associatedId == string.Empty)
|
|
{
|
|
LoggingHelpers.LogWarning($"WARNING {message}: '{firstValue}', expected '{secondValue}'");
|
|
}
|
|
else
|
|
{
|
|
LoggingHelpers.LogWarning($"WARNING {associatedId} {message}: '{firstValue}', expected '{secondValue}'");
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void CheckForMissingQuestsInAkiFile(Models.QuestRoot liveQuestData, Dictionary<string, Models.Quest> akiQuestData)
|
|
{
|
|
var missingQuests = new List<string>();
|
|
foreach (var liveQuest in liveQuestData.data)
|
|
{
|
|
if (!akiQuestData.ContainsKey(liveQuest._id))
|
|
{
|
|
missingQuests.Add($"{liveQuest._id} {QuestHelper.GetQuestNameById(liveQuest._id)}");
|
|
}
|
|
}
|
|
if (missingQuests.Count > 0)
|
|
{
|
|
LoggingHelpers.LogWarning($"WARNING aki quest list is missing quests:");
|
|
foreach (var item in missingQuests)
|
|
{
|
|
LoggingHelpers.LogWarning(item);
|
|
}
|
|
}
|
|
}
|
|
|
|
private static string CreateWorkingFolders()
|
|
{
|
|
var workingPath = Directory.GetCurrentDirectory();
|
|
// create input folder
|
|
var inputPath = $"{workingPath}//input";
|
|
DiskHelpers.CreateDirIfDoesntExist(inputPath);
|
|
|
|
return inputPath;
|
|
}
|
|
}
|
|
}
|