diff --git a/AssortGenerator.Common/Helpers/QuestHelper.cs b/AssortGenerator.Common/Helpers/QuestHelper.cs index 1524e23..4bb0283 100644 --- a/AssortGenerator.Common/Helpers/QuestHelper.cs +++ b/AssortGenerator.Common/Helpers/QuestHelper.cs @@ -63,7 +63,7 @@ namespace AssortGenerator.Common.Helpers QuestRewardId = reward.id, TraderId = reward.traderId, TraderType = TraderHelper.GetTraderTypeById(reward.traderId), - Criteria = "Success" + Criteria = "Started" } ); } diff --git a/AssortGenerator/Program.cs b/AssortGenerator/Program.cs index cc17b6b..5900698 100644 --- a/AssortGenerator/Program.cs +++ b/AssortGenerator/Program.cs @@ -26,7 +26,7 @@ namespace AssortGenerator { // Get relevant trader dump var assortDumpPath = traderAssortFilePaths.Find(x => x.Contains($"getTraderAssort.{trader.Value}")); - if (assortDumpPath == null) + if (assortDumpPath == null) { assortDumpPath = traderAssortFilePaths.Find(x => x.Contains($"{trader.Value}") && x.Contains("getTraderAssort")); } @@ -207,99 +207,112 @@ namespace AssortGenerator // Find assort unlocks List assortUnlocks = QuestHelper.GetAssortUnlocks(); var assortItemsThatMatchBlackList = new List(); // store items already matched here - // TODO: find out how the fuck the assort unlock is associated to the quest foreach (var assortUnlock in assortUnlocks.Where(x => x.TraderType == trader)) { - if (assortUnlock.AssortUnlockId == "5ac653ed86f77405d4729344") + if (assortUnlock.ItemUnlockedTemplateId == "62a0a043cf4a99369e2624a5") { var x = 2; } // Get unlock items name var assortItemName = ItemTemplateHelper.Items - .FirstOrDefault(x=> x.Key == assortUnlock.ItemUnlockedTemplateId).Value._name; + .FirstOrDefault(x => x.Key == assortUnlock.ItemUnlockedTemplateId).Value._name; // TODO: handle started // TODO: handle fail // Handle quest success for now - if (assortUnlock.Criteria.ToLower() == "success") + //if (assortUnlock.Criteria.ToLower() == "success") + //{ + //Find assorts that match the quest unlocks item template + List assortItemsThatMatch = assortRoot.items + .Where(x => x._tpl == assortUnlock.ItemUnlockedTemplateId && x.slotId == "hideout") + .ToList(); + + // No assort found for this unlock, log and skip it + if (assortItemsThatMatch == null || assortItemsThatMatch.Count == 0) { - //Find assorts that match the quest unlocks item template - List assortItemsThatMatch = assortRoot.items - .Where(x => x._tpl == assortUnlock.ItemUnlockedTemplateId && x.slotId == "hideout") - .ToList(); + LoggingHelpers.LogError($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId}. questId: {assortUnlock.QuestId}. no assort item found. ({assortItemName})"); + continue; + } - // No assort found for this unlock, log and skip it - if (assortItemsThatMatch == null || assortItemsThatMatch.Count == 0) + // Iterate over assorts that match. goal is to find assort that fits the best + // (assort has same loyalty level unlock as quest expects) + string assortIdUnlockedByQuest = string.Empty; + foreach (var match in assortItemsThatMatch) + { + // Look up item in Loyalty Level array + var associatedLoyaltyLevelItem = assortRoot.loyal_level_items + .FirstOrDefault(x => x.Key == match._id); + + if (associatedLoyaltyLevelItem.Key == null) { - LoggingHelpers.LogError($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId}. questId: {assortUnlock.QuestId}. no assort item found. ({assortItemName})"); + // Skip item if no record found in loyalty level array + LoggingHelpers.LogError($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({assortItemName}). questId: {assortUnlock.QuestId}. no loyalty record found. "); continue; } - // Iterate over assorts that match. goal is to find assort that fits the best - // (assort has same loyalty level unlock as quest expects) - string assortIdUnlockedByQuest = string.Empty; - foreach (var match in assortItemsThatMatch) + if (associatedLoyaltyLevelItem.Value != assortUnlock.LoyaltyLevel) { - // Look up item in Loyalty Level array - var associatedLoyaltyLevelItem = assortRoot.loyal_level_items - .FirstOrDefault(x => x.Key == match._id); - - if (associatedLoyaltyLevelItem.Key == null) - { - // Skip item if no record found in loyalty level array - LoggingHelpers.LogError($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({assortItemName}). questId: {assortUnlock.QuestId}. no loyalty record found. "); - continue; - } - - if (associatedLoyaltyLevelItem.Value != assortUnlock.LoyaltyLevel) - { - // Loyalty level is different to what was expected, skip and try next - LoggingHelpers.LogWarning($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({assortItemName}). questId: {assortUnlock.QuestId}. no match found in LL array. expected LL{associatedLoyaltyLevelItem.Value}. found: LL{assortUnlock.LoyaltyLevel}"); - continue; - } - - // LoggingHelpers.LogInfo($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} {assortItemName}. MATCH FOUND. LL{assortUnlock.LoyaltyLevel}"); - if (assortItemsThatMatchBlackList.Contains(associatedLoyaltyLevelItem.Key)) - { - // Not the item we want, its already been matched - continue; - } - - // Add assort item id to blacklist so it wont be matched again - assortItemsThatMatchBlackList.Add(associatedLoyaltyLevelItem.Key); - - // assign id and break out of loop, We found the one we want - assortIdUnlockedByQuest = associatedLoyaltyLevelItem.Key; - break; - } - - if (result.success.ContainsKey(assortIdUnlockedByQuest)) - { - LoggingHelpers.LogWarning($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({assortItemName}). questId: {assortUnlock.QuestId}. ALREADY EXISTS. SKIPPING"); + // Loyalty level is different to what was expected, skip and try next + LoggingHelpers.LogWarning($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({assortItemName}). questId: {assortUnlock.QuestId}. no match found in LL array. expected LL{associatedLoyaltyLevelItem.Value}. found: LL{assortUnlock.LoyaltyLevel}"); continue; } - if (assortIdUnlockedByQuest.Length == 0) + // LoggingHelpers.LogInfo($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} {assortItemName}. MATCH FOUND. LL{assortUnlock.LoyaltyLevel}"); + if (assortItemsThatMatchBlackList.Contains(associatedLoyaltyLevelItem.Key)) { - LoggingHelpers.LogError($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({assortItemName}). questId: {assortUnlock.QuestId}. no assortId found"); + // Not the item we want, its already been matched continue; } - LoggingHelpers.LogSuccess($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({assortItemName}). questId: {assortUnlock.QuestId}. ADDING TO QUEST-ASSORT"); + // Add assort item id to blacklist so it wont be matched again + assortItemsThatMatchBlackList.Add(associatedLoyaltyLevelItem.Key); + + // assign id and break out of loop, We found the one we want + assortIdUnlockedByQuest = associatedLoyaltyLevelItem.Key; + break; + } + + if (result.success.ContainsKey(assortIdUnlockedByQuest)) + { + LoggingHelpers.LogWarning($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({assortItemName}). questId: {assortUnlock.QuestId}. ALREADY EXISTS. SKIPPING"); + continue; + } + + if (assortIdUnlockedByQuest.Length == 0) + { + LoggingHelpers.LogError($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({assortItemName}). questId: {assortUnlock.QuestId}. no assortId found"); + continue; + } + + LoggingHelpers.LogSuccess($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} ({assortItemName}). questId: {assortUnlock.QuestId}. ADDING TO QUEST-ASSORT"); + + if (assortUnlock.Criteria == "Success") + { result.success.Add(assortIdUnlockedByQuest, assortUnlock.QuestId); } - - if (assortUnlock.Criteria.ToLower() == "fail") + else if (assortUnlock.Criteria == "Started") { - LoggingHelpers.LogError("Fail quest criteria not handled"); + result.started.Add(assortIdUnlockedByQuest, assortUnlock.QuestId); + } + else + { + LoggingHelpers.LogError($"{assortUnlock.Criteria} quest criteria not handled"); } - if (assortUnlock.Criteria.ToLower() == "started") - { - LoggingHelpers.LogError("started quest criteria not handled"); - } + + //} + + //if (assortUnlock.Criteria.ToLower() == "fail") + //{ + // LoggingHelpers.LogError("Fail quest criteria not handled"); + //} + + //if (assortUnlock.Criteria.ToLower() == "started") + //{ + // LoggingHelpers.LogError("started quest criteria not handled"); + //} } return result;