2021-09-07 17:45:49 +01:00
using AssortGenerator.Common.Helpers ;
using QuestValidator.Common ;
using QuestValidator.Common.Helpers ;
using QuestValidator.Helpers ;
2021-09-10 14:26:43 +01:00
using QuestValidator.Models ;
2021-09-07 19:31:38 +01:00
using System ;
2021-09-07 17:45:49 +01:00
using System.Collections.Generic ;
using System.Linq ;
namespace QuestValidator
{
class Program
{
static void Main ( string [ ] args )
{
2021-09-10 12:42:30 +01:00
var inputPath = DiskHelpers . CreateWorkingFolders ( ) ;
2021-09-07 17:45:49 +01:00
InputFileHelper . SetInputFiles ( inputPath ) ;
//read in quest file
var questData = QuestHelper . GetQuestData ( ) ;
var liveQuestData = QuestHelper . GetLiveQuestData ( ) ;
2022-01-09 20:35:43 +00:00
if ( questData is null | | liveQuestData is null )
2021-09-10 13:25:26 +01:00
{
LoggingHelpers . LogError ( "Unable to read quest data. Are you sure the both quest files are in 'QuestValidator//bin//Debug//netcoreapp3.1//input'" ) ;
return ;
}
2021-09-14 19:52:11 +01:00
ListMissingQuestsInLive ( questData , liveQuestData ) ;
2021-09-07 17:45:49 +01:00
CheckForMissingQuestsInAkiFile ( liveQuestData , questData ) ;
2021-09-07 19:53:02 +01:00
2021-09-18 22:30:16 +01:00
CheckForMissingQuestIcons ( questData ) ;
2021-09-07 17:45:49 +01:00
foreach ( var item in questData )
{
var quest = item . Value ;
LogQuestDetails ( quest ) ;
2021-09-07 19:31:38 +01:00
// Get live quest
2021-09-07 17:45:49 +01:00
var relatedLiveQuest = liveQuestData . data . FirstOrDefault ( x = > x . _id = = quest . _id ) ;
2021-09-07 19:31:38 +01:00
if ( ! ItemExists ( relatedLiveQuest , "live quest. Live dump too old ?" ) )
2021-09-07 17:45:49 +01:00
{
LoggingHelpers . LogInfo ( "" ) ;
continue ;
}
CheckRootItemValues ( quest , relatedLiveQuest ) ;
CheckSuccessRewardItems ( quest , relatedLiveQuest ) ;
2021-09-07 19:31:38 +01:00
CheckStartedRewardItems ( quest , relatedLiveQuest ) ;
2021-09-07 17:45:49 +01:00
CheckAvailableForFinishConditionItems ( quest , relatedLiveQuest ) ;
2021-09-14 19:52:11 +01:00
CheckAvailableForStartConditionItems ( quest , relatedLiveQuest ) ;
CheckFailConditionItems ( quest , relatedLiveQuest ) ;
2021-09-07 19:53:02 +01:00
2021-09-07 17:45:49 +01:00
LoggingHelpers . LogInfo ( "" ) ;
LoggingHelpers . LogInfo ( "-----" ) ;
LoggingHelpers . LogInfo ( "" ) ;
}
}
2021-09-18 22:30:16 +01:00
private static void CheckForMissingQuestIcons ( Dictionary < string , Quest > questData )
{
string iconPath = "TODO add path here Server\\project\\assets\\images\\quests" ;
if ( iconPath . Contains ( "TODO add path here" ) )
{
throw new Exception ( "Add the correct icon path to Program.cs" ) ;
}
foreach ( var quest in questData )
{
var imageId = quest . Value . image . Split ( "/" ) [ 4 ] . Split ( "." ) [ 0 ] ;
if ( ! QuestHelper . DoesIconExist ( iconPath , imageId ) )
{
LoggingHelpers . LogError ( $"ERROR - Quest {quest.Value.QuestName} is missing an icon file, add {imageId}.png" ) ;
}
}
}
2021-09-14 19:52:11 +01:00
private static void ListMissingQuestsInLive ( Dictionary < string , Quest > questData , QuestRoot liveQuestData )
{
var missingQuests = new List < Quest > ( ) ;
foreach ( var quest in questData . Values )
{
var liveQuest = liveQuestData . data . FirstOrDefault ( x = > x . _id = = quest . _id ) ;
2022-01-09 20:35:43 +00:00
if ( liveQuest is null )
2021-09-14 19:52:11 +01:00
{
missingQuests . Add ( quest ) ;
LoggingHelpers . LogError ( $"ERROR Quest {quest._id} {QuestHelper.GetQuestNameById(quest._id)} missing in live" ) ;
}
}
}
private static void CheckFailConditionItems ( Quest quest , Quest relatedLiveQuest )
{
var liveFailConditions = relatedLiveQuest . conditions . Fail ;
// Check count
CheckValuesMatch ( quest . conditions . Fail . Count , liveFailConditions . Count , "FailCondition mismatch" ) ;
foreach ( var failItem in quest . conditions . Fail )
{
var liveFailItem = liveFailConditions . FirstOrDefault ( x = > x . _props . id = = failItem . _props . id ) ;
if ( ! ItemExists ( liveFailItem , "condition fail item" , failItem . _props . index . Value ) )
{
continue ;
}
// Check parentId
CheckValuesMatch ( failItem . _props . parentId , liveFailItem . _props . parentId , "AvailableForFinish parentId mismatch" , failItem . _props . id ) ;
}
}
private static void CheckAvailableForStartConditionItems ( Quest quest , Quest relatedLiveQuest )
{
var liveStartConditions = relatedLiveQuest . conditions . AvailableForStart ;
// Check count
CheckValuesMatch ( quest . conditions . AvailableForStart . Count , liveStartConditions . Count , "AvailableForStartCondition mismtch" ) ;
foreach ( var availableForStartItem in quest . conditions . AvailableForStart )
{
var liveStartItem = liveStartConditions . FirstOrDefault ( x = > x . _props . id = = availableForStartItem . _props . id ) ;
if ( ! ItemExists ( liveStartItem , "AvailableForStart item" , availableForStartItem . _props . index . Value ) )
{
continue ;
}
// Check parentId
CheckValuesMatch ( availableForStartItem . _props . parentId , liveStartItem . _props . parentId , "AvailableForFinish parentId mismatch" , availableForStartItem . _props . id ) ;
}
}
2021-09-10 14:26:43 +01:00
private static void LogQuestDetails ( Quest quest )
2021-09-07 19:53:02 +01:00
{
var questName = QuestHelper . GetQuestNameById ( quest . _id ) ;
2021-09-11 14:07:20 +01:00
var trader = TraderHelper . GetTraderTypeById ( quest . traderId ) ;
LoggingHelpers . LogInfo ( $"### Quest name: {questName} ({quest._id}) ({trader})" ) ;
2021-09-07 19:53:02 +01:00
LoggingHelpers . LogInfo ( $"Wiki: https://escapefromtarkov.fandom.com/wiki/{questName.Replace(' ', '_')}" ) ;
}
2021-09-10 14:26:43 +01:00
private static void CheckRootItemValues ( Quest quest , Quest relatedLiveQuest )
2021-09-07 17:45:49 +01:00
{
2021-09-07 19:31:38 +01:00
// Check image id matches
2021-09-10 14:26:43 +01:00
CheckValuesMatch ( quest . image . Substring ( 0 , quest . image . Length - 4 ) , relatedLiveQuest ? . image . Substring ( 0 , relatedLiveQuest . image . Length - 4 ) , "item path mismatch" ) ;
2021-09-07 17:45:49 +01:00
2021-09-12 15:41:15 +01:00
//Check image id contains quest id
if ( ! quest . image . Contains ( quest . _id ) )
{
2021-09-14 19:52:11 +01:00
LoggingHelpers . LogInfo ( $"INFO Quest image path does not contain quest id" ) ;
2021-09-12 15:41:15 +01:00
}
2021-09-07 19:31:38 +01:00
// Check started reward count matches
CheckValuesMatch ( quest . rewards . Started . Count , relatedLiveQuest . rewards . Started . Count , "Started item count mismatch" ) ;
2021-09-07 17:45:49 +01:00
2021-09-07 19:31:38 +01:00
// 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 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" ) ;
2021-09-07 17:45:49 +01:00
}
2021-09-10 14:26:43 +01:00
private static void CheckSuccessRewardItems ( Quest quest , Quest relatedLiveQuest )
2021-09-07 17:45:49 +01:00
{
var liveQuestSuccessRewardItems = relatedLiveQuest . rewards . Success ;
2021-09-10 14:26:43 +01:00
foreach ( RewardStatus questSuccessRewardItem in quest . rewards . Success . Where ( x = > x . type = = "Item" ) )
2021-09-07 17:45:49 +01:00
{
// Get live reward item by index and type
2021-09-10 14:26:43 +01:00
var relatedLiveRewardItem = GetLiveRewardItem ( questSuccessRewardItem , liveQuestSuccessRewardItems ) ;
2022-01-09 20:35:43 +00:00
if ( relatedLiveRewardItem is null )
2021-09-07 17:45:49 +01:00
{
2021-09-12 15:41:15 +01:00
LogUnableToFindSuccessItemInLiveData ( questSuccessRewardItem , relatedLiveRewardItem ) ;
2021-09-10 14:26:43 +01:00
continue ;
2021-09-07 17:45:49 +01:00
}
// 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
2022-06-08 16:41:30 +01:00
CheckValuesMatch ( questSuccessRewardItem . value . ToString ( ) , relatedLiveRewardItem . value . ToString ( ) , "mismatch for success item reward value" , questSuccessRewardItem . id ) ;
2021-09-07 17:45:49 +01:00
// Check item stack count
2021-09-11 14:07:34 +01:00
if ( questSuccessRewardItem . items [ 0 ] ? . upd ! = null & & relatedLiveRewardItem . items [ 0 ] ? . upd ! = null )
2021-09-07 17:45:49 +01:00
{
2021-09-14 19:52:11 +01:00
CheckValuesMatch ( questSuccessRewardItem . items [ 0 ] . upd . StackObjectsCount . Value , relatedLiveRewardItem . items [ 0 ] . upd . StackObjectsCount . Value , "mismatch for success item StackObjectsCount" , questSuccessRewardItem . items [ 0 ] . _id ) ;
2021-09-07 17:45:49 +01:00
}
2021-09-08 20:14:39 +01:00
// check sub items match
2021-09-10 14:26:43 +01:00
CheckSubItemsMatch ( questSuccessRewardItem , relatedLiveRewardItem ) ;
2021-09-07 17:45:49 +01:00
}
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" ) ;
}
2021-09-07 19:31:38 +01:00
foreach ( var questSuccessRewardItem in quest . rewards . Success . Where ( x = > x . type = = "AssortmentUnlock" ) )
{
2021-09-12 15:41:15 +01:00
// Find the assort unlock item in the list of success rewards
var possibleLiveRewardItems = liveQuestSuccessRewardItems . Where ( x = > x . id = = questSuccessRewardItem . id & & x . type = = "AssortmentUnlock" ) ;
RewardStatus relatedLiveRewardItem = null ;
// we found the one we want
if ( possibleLiveRewardItems ? . Count ( ) = = 1 )
{
relatedLiveRewardItem = possibleLiveRewardItems . First ( ) ;
}
// multiple found
if ( possibleLiveRewardItems ? . Count ( ) > 1 )
{
// be more specific, get my index
relatedLiveRewardItem = possibleLiveRewardItems . FirstOrDefault ( x = > x . index = = questSuccessRewardItem . index ) ;
// nothing found by index, try by
2022-01-09 20:35:43 +00:00
if ( relatedLiveRewardItem is null )
2021-09-12 15:41:15 +01:00
{
relatedLiveRewardItem = possibleLiveRewardItems . FirstOrDefault ( x = > x . traderId = = questSuccessRewardItem . traderId ) ;
}
}
2022-01-09 20:35:43 +00:00
if ( relatedLiveRewardItem is null )
2021-09-07 19:53:02 +01:00
{
relatedLiveRewardItem = liveQuestSuccessRewardItems . Find ( x = > x . traderId = = questSuccessRewardItem . traderId
& & x . index = = questSuccessRewardItem . index
& & x . type = = "AssortmentUnlock"
& & x . items [ 0 ] . _tpl = = questSuccessRewardItem . items [ 0 ] . _tpl ) ;
}
if ( ! ItemExists ( relatedLiveRewardItem , "AssortmentUnlock success reward item" , questSuccessRewardItem . index ) )
2021-09-07 19:31:38 +01:00
{
continue ;
}
// Check loyalty level
CheckValuesMatch ( questSuccessRewardItem . loyaltyLevel . Value , relatedLiveRewardItem . loyaltyLevel . Value , "loyalty level value mismatch" , questSuccessRewardItem . id ) ;
// Check traderId
CheckValuesMatch ( questSuccessRewardItem . traderId , relatedLiveRewardItem . traderId , "traderId value mismatch" , questSuccessRewardItem . id ) ;
// check target equals items[0].id
2021-09-07 19:53:02 +01:00
CheckValuesMatch ( questSuccessRewardItem . target , questSuccessRewardItem . items [ 0 ] . _id , "target value does not match items[0].id mismatch" , questSuccessRewardItem . id ) ;
2021-09-07 19:31:38 +01:00
}
2021-09-07 17:45:49 +01:00
}
2021-09-10 14:26:43 +01:00
private static void CheckSubItemsMatch ( RewardStatus questSuccessRewardItem , RewardStatus relatedLiveRewardItem )
{
foreach ( var subItem in questSuccessRewardItem . items . Where ( x = > ! string . IsNullOrEmpty ( x . slotId ) ) )
{
2021-09-12 15:41:15 +01:00
// find live item by slotid
2021-09-11 14:08:22 +01:00
var liveCounterpart = relatedLiveRewardItem . items . Where ( x = > x . slotId = = subItem . slotId ) ;
2022-01-09 20:35:43 +00:00
if ( liveCounterpart is null | | liveCounterpart . Count ( ) = = 0 )
2021-09-10 14:26:43 +01:00
{
2021-09-12 15:41:15 +01:00
// Look for live item by template id
liveCounterpart = relatedLiveRewardItem . items . Where ( x = > x . _tpl = = subItem . _tpl ) ;
2022-01-09 20:35:43 +00:00
if ( liveCounterpart is null | | liveCounterpart . Count ( ) = = 0 )
2021-09-12 15:41:15 +01:00
{
LoggingHelpers . LogWarning ( $"a live counterpart for the subItem {subItem.slotId} could not be found by slotid or tpId, skipping subItem check" ) ;
continue ;
}
2021-09-10 14:26:43 +01:00
}
2021-09-11 14:08:22 +01:00
if ( liveCounterpart . Count ( ) > 1 )
{
LoggingHelpers . LogWarning ( $"Multiple live counterparts for the subItem {subItem.slotId} found, skipping subItem check" ) ;
continue ;
}
2021-09-10 14:26:43 +01:00
2021-09-11 14:08:22 +01:00
var firstLiveItem = liveCounterpart . FirstOrDefault ( ) ;
CheckValuesMatch ( subItem . _tpl , firstLiveItem . _tpl , $"mismatch for success subItem({subItem.slotId}) reward templateId" , subItem . _id ) ;
2021-09-10 14:26:43 +01:00
}
}
private static void LogUnableToFindSuccessItemInLiveData ( RewardStatus questSuccessRewardItem , RewardStatus relatedLiveRewardItem )
{
2022-01-09 20:35:43 +00:00
if ( relatedLiveRewardItem is null )
2021-09-10 14:26:43 +01:00
{
LoggingHelpers . LogError ( $"ERROR unable to find success reward item in live quest data by index: ({questSuccessRewardItem.index}) OR template id: {questSuccessRewardItem.items[0]._tpl} ({ItemTemplateHelper.GetTemplateById(questSuccessRewardItem.items[0]._tpl)._name})" ) ;
LoggingHelpers . LogError ( "Existing items:" ) ;
LogSuccessItems ( questSuccessRewardItem ) ;
LoggingHelpers . LogError ( $"ERROR Skipping quest success item. id: {questSuccessRewardItem.id}" ) ;
}
}
private static void LogSuccessItems ( RewardStatus rewardItem )
{
foreach ( var item in rewardItem . items )
{
LoggingHelpers . LogInfo ( $"{item._tpl} ({ItemTemplateHelper.GetTemplateById(item._tpl)._name})" ) ;
}
}
/// <summary>
/// Find live success item reward by index
/// If item at index does not match templateId to desired item
/// get live success item reward by template id
/// </summary>
/// <param name="questSuccessRewardItem"></param>
/// <param name="liveQuestSuccessRewardItems"></param>
/// <returns></returns>
private static RewardStatus GetLiveRewardItem ( RewardStatus questSuccessRewardItem , List < RewardStatus > liveQuestSuccessRewardItems )
{
var LiveItemRewards = liveQuestSuccessRewardItems . Where ( x = > x . type = = "Item" ) ;
var liveRewardItemByIndex = LiveItemRewards . FirstOrDefault ( x = > x . index = = questSuccessRewardItem . index ) ;
2021-09-12 15:41:15 +01:00
// no item found by index, find by template id
2022-01-09 20:35:43 +00:00
if ( liveRewardItemByIndex is null )
2021-09-12 15:41:15 +01:00
{
foreach ( var liveItem in LiveItemRewards
. SelectMany ( liveItem = > liveItem . items
. Where ( subItem = > subItem . _tpl = = questSuccessRewardItem . items [ 0 ] . _tpl )
. Select ( subItem = > liveItem ) ) )
{
return liveItem ;
}
}
2021-09-10 14:26:43 +01:00
// item found by index but template id didnt match
if ( liveRewardItemByIndex ! = null & & liveRewardItemByIndex . items [ 0 ] . _tpl ! = questSuccessRewardItem . items [ 0 ] . _tpl )
{
return LiveItemRewards . FirstOrDefault ( x = > x . items [ 0 ] . _tpl = = questSuccessRewardItem . items [ 0 ] . _tpl ) ;
}
return liveRewardItemByIndex ;
}
private static void CheckStartedRewardItems ( Quest quest , Quest relatedLiveQuest )
2021-09-07 17:45:49 +01:00
{
2021-09-07 19:31:38 +01:00
var liveQuestStartedRewardItems = relatedLiveQuest . rewards . Started ;
2021-09-07 17:45:49 +01:00
2021-09-07 19:53:02 +01:00
foreach ( var questStartedRewardItem in quest . rewards . Started . Where ( x = > x . type = = "Item" ) )
2021-09-07 19:31:38 +01:00
{
var errorMessage = string . Empty ;
// Get live reward item by index and type
2021-09-07 19:53:02 +01:00
var relatedLiveRewardItem = liveQuestStartedRewardItems . Find ( x = > x . index = = questStartedRewardItem . index & & x . type = = "Item" ) ;
2022-01-09 20:35:43 +00:00
if ( relatedLiveRewardItem is null )
2021-09-07 19:31:38 +01:00
{
// Get live reward item by templateId and type as we cant find it by index
2021-09-07 19:53:02 +01:00
relatedLiveRewardItem = liveQuestStartedRewardItems . Find ( x = > x . items ! = null & & x . items [ 0 ] ? . _tpl = = questStartedRewardItem . items [ 0 ] ? . _tpl & & x . type = = "Item" ) ;
2022-01-09 20:35:43 +00:00
if ( relatedLiveRewardItem is null )
2021-09-07 19:31:38 +01:00
{
2021-09-07 19:53:02 +01:00
LoggingHelpers . LogError ( $"ERROR unable to find started reward item in live quest data by index: ({questStartedRewardItem.index}) OR template id: {questStartedRewardItem.items[0]._tpl}" ) ;
LoggingHelpers . LogError ( $"ERROR Skipping quest started item: {questStartedRewardItem.id}" ) ;
2021-09-07 19:31:38 +01:00
continue ;
}
}
2021-09-07 17:45:49 +01:00
2021-09-07 19:31:38 +01:00
// Ensure target matches the objects items[0].id value
2021-09-07 19:53:02 +01:00
if ( questStartedRewardItem . items [ 0 ] ? . _id ! = questStartedRewardItem . target )
2021-09-07 19:31:38 +01:00
{
2021-09-07 19:53:02 +01:00
LoggingHelpers . LogWarning ( $"WARNING target does not match first item: {questStartedRewardItem.target}, expected {questStartedRewardItem.items[0]?._id}" ) ;
2021-09-07 19:31:38 +01:00
}
2021-09-07 17:45:49 +01:00
2021-09-07 19:31:38 +01:00
// Check template ids match
2021-09-07 19:53:02 +01:00
CheckValuesMatch ( questStartedRewardItem . items [ 0 ] . _tpl , relatedLiveRewardItem . items [ 0 ] . _tpl , "mismatch for template id" , questStartedRewardItem . items [ 0 ] . _id , true ) ;
2021-09-07 17:45:49 +01:00
2021-09-11 14:08:22 +01:00
// Check 'value' values match
2021-09-07 19:53:02 +01:00
CheckValuesMatch ( questStartedRewardItem . value , relatedLiveRewardItem . value , "mismatch for success item reward value" , questStartedRewardItem . id ) ;
2021-09-07 17:45:49 +01:00
2021-09-07 19:31:38 +01:00
// Check item stack count
2021-09-07 19:53:02 +01:00
if ( questStartedRewardItem . items [ 0 ] ! = null & & questStartedRewardItem . items [ 0 ] . upd ! = null )
2021-09-07 19:31:38 +01:00
{
2021-09-14 19:52:11 +01:00
CheckValuesMatch ( questStartedRewardItem . items [ 0 ] . upd . StackObjectsCount . Value , relatedLiveRewardItem . items [ 0 ] . upd . StackObjectsCount . Value , "mismatch for started item StackObjectsCount" , questStartedRewardItem . items [ 0 ] . _id ) ;
2021-09-07 19:31:38 +01:00
}
}
2021-09-07 19:53:02 +01:00
foreach ( var questStartedRewardItem in quest . rewards . Started . Where ( x = > x . type = = "AssortmentUnlock" ) )
{
// Get live reward item by id
var relatedLiveRewardItem = liveQuestStartedRewardItems . FirstOrDefault ( x = > x . id = = questStartedRewardItem . id & & x . type = = "AssortmentUnlock" ) ;
2022-01-09 20:35:43 +00:00
if ( relatedLiveRewardItem is null )
2021-09-07 19:53:02 +01:00
{
// Cant find live reward item by id, get my template id inside items[0]
relatedLiveRewardItem = liveQuestStartedRewardItems . Find ( x = > x . traderId = = questStartedRewardItem . traderId
& & x . index = = questStartedRewardItem . index
& & x . type = = "AssortmentUnlock"
& & x . items [ 0 ] . _tpl = = questStartedRewardItem . items [ 0 ] . _tpl ) ;
}
if ( ! ItemExists ( relatedLiveRewardItem , "AssortmentUnlock started reward item" , questStartedRewardItem . index ) )
{
continue ;
}
// Check loyalty level
CheckValuesMatch ( questStartedRewardItem . loyaltyLevel . Value , relatedLiveRewardItem . loyaltyLevel . Value , "loyalty level value mismatch" , questStartedRewardItem . id ) ;
// Check traderId
CheckValuesMatch ( questStartedRewardItem . traderId , relatedLiveRewardItem . traderId , "traderId value mismatch" , questStartedRewardItem . id ) ;
2021-09-07 18:03:18 +01:00
2021-09-07 19:53:02 +01:00
// check target equals items[0].id
CheckValuesMatch ( questStartedRewardItem . target , questStartedRewardItem . items [ 0 ] . _id , "target value does not match items[0].id mismatch" , questStartedRewardItem . id ) ;
}
2021-09-07 19:31:38 +01:00
}
2021-09-07 18:03:18 +01:00
2021-09-10 14:26:43 +01:00
private static void CheckAvailableForFinishConditionItems ( Quest quest , Quest relatedLiveQuest )
2021-09-07 19:31:38 +01:00
{
2021-09-14 19:52:11 +01:00
// Check count
CheckValuesMatch ( quest . conditions . AvailableForFinish . Count , relatedLiveQuest . conditions . AvailableForFinish . Count , "AvailableForFinish mismtch" ) ;
2021-09-07 19:31:38 +01:00
foreach ( var availableForFinishItem in quest . conditions . AvailableForFinish )
{
2021-09-10 14:26:43 +01:00
AvailableFor liveFinishItem = relatedLiveQuest . conditions . AvailableForFinish . Find ( x = > x . _props . id = = availableForFinishItem . _props . id ) ;
2021-09-07 19:31:38 +01:00
if ( ! ItemExists ( liveFinishItem , "AvailableForFinish item" , availableForFinishItem . _props . index . Value ) )
{
continue ;
}
// Check parentId
CheckValuesMatch ( availableForFinishItem . _props . parentId , liveFinishItem . _props . parentId , "AvailableForFinish parentId mismatch" , availableForFinishItem . _props . id ) ;
// check AvailableForFinish resetOnSessionEnd
2021-09-18 22:30:32 +01:00
if ( availableForFinishItem . _props . resetOnSessionEnd . HasValue & & liveFinishItem . _props . resetOnSessionEnd . HasValue )
{
2021-09-18 22:30:16 +01:00
CheckValuesMatch ( availableForFinishItem . _props . resetOnSessionEnd . Value , liveFinishItem . _props . resetOnSessionEnd . Value , "AvailableForFinish resetOnSessionEnd value mismatch" , availableForFinishItem . _props . id ) ;
2021-09-18 22:30:32 +01:00
}
2021-09-07 19:31:38 +01:00
// check AvailableForFinish target
CheckValuesMatch ( Convert . ToString ( availableForFinishItem . _props . target ) , Convert . ToString ( liveFinishItem . _props . target ) , "AvailableForFinish target value mismatch" , availableForFinishItem . _props . id ) ;
2021-09-08 20:14:39 +01:00
// check weapons allowed match
//CheckValuesMatch(availableForFinishItem._props.weapon.Count, liveFinishItem._props.counter.conditions), "AvailableForFinish target value mismatch", availableForFinishItem._props.id);
2021-09-07 19:31:38 +01:00
}
2021-09-07 17:45:49 +01:00
}
private static bool ItemExists ( object itemToCheck , string message , int index = - 1 )
{
2022-01-09 20:35:43 +00:00
if ( itemToCheck is null )
2021-09-07 17:45:49 +01:00
{
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}'" ) ;
}
}
}
2021-09-10 14:26:43 +01:00
private static void CheckValuesMatch < T > ( T firstValue , T secondValue , string message , string associatedId = "" ) where T : struct
{
if ( firstValue . Equals ( 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 )
2021-09-07 17:45:49 +01:00
{
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}'" ) ;
}
}
}
2021-09-10 14:26:43 +01:00
private static void CheckForMissingQuestsInAkiFile ( QuestRoot liveQuestData , Dictionary < string , Quest > akiQuestData )
2021-09-07 17:45:49 +01:00
{
2021-09-10 14:26:43 +01:00
// iterate over live quests and look for quests that exist in live but not in aki
2021-09-07 17:45:49 +01:00
var missingQuests = new List < string > ( ) ;
foreach ( var liveQuest in liveQuestData . data )
{
if ( ! akiQuestData . ContainsKey ( liveQuest . _id ) )
{
missingQuests . Add ( $"{liveQuest._id} {QuestHelper.GetQuestNameById(liveQuest._id)}" ) ;
}
}
2021-09-10 14:26:43 +01:00
// Quests in live but not in aki were found, log it
2021-09-07 17:45:49 +01:00
if ( missingQuests . Count > 0 )
{
LoggingHelpers . LogWarning ( $"WARNING aki quest list is missing quests:" ) ;
foreach ( var item in missingQuests )
{
LoggingHelpers . LogWarning ( item ) ;
}
}
}
}
}