Add blacklist to fix bug with quests that unlock multiple items with the same template id (jaeger has quest that unlocks 4 remington 700 presets)
Fix bug; assort id is the key, not quest id
This commit is contained in:
parent
c5ad3efe42
commit
9931ff01ad
@ -127,7 +127,7 @@ namespace AssortGenerator
|
|||||||
|
|
||||||
// Find assortunlocks
|
// Find assortunlocks
|
||||||
List<AssortUnlocks> assortUnlocks = QuestHelper.GetAssortUnlocks();
|
List<AssortUnlocks> assortUnlocks = QuestHelper.GetAssortUnlocks();
|
||||||
|
List<string> assortItemsThatMatchBlackList = new List<string>(); // store items already matched here
|
||||||
// TODO: find out how the fuck the assort unlock is associated to the quest
|
// TODO: find out how the fuck the assort unlock is associated to the quest
|
||||||
foreach (var assortUnlock in assortUnlocks.Where(x => x.TraderType == trader))
|
foreach (var assortUnlock in assortUnlocks.Where(x => x.TraderType == trader))
|
||||||
{
|
{
|
||||||
@ -142,7 +142,7 @@ namespace AssortGenerator
|
|||||||
if (assortUnlock.Criteria == "Success")
|
if (assortUnlock.Criteria == "Success")
|
||||||
{
|
{
|
||||||
//Find assorts that match the quest unlocks item template
|
//Find assorts that match the quest unlocks item template
|
||||||
var assortItemsThatMatch = assortRoot.items.Where(x => x._tpl == assortUnlock.ItemUnlockedTemplateId).ToList();
|
List<Item> assortItemsThatMatch = assortRoot.items.Where(x => x._tpl == assortUnlock.ItemUnlockedTemplateId).ToList();
|
||||||
|
|
||||||
// no assort found for this unlock, log and skip it
|
// no assort found for this unlock, log and skip it
|
||||||
if (assortItemsThatMatch == null || assortItemsThatMatch.Count == 0)
|
if (assortItemsThatMatch == null || assortItemsThatMatch.Count == 0)
|
||||||
@ -151,38 +151,54 @@ namespace AssortGenerator
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate over assorts that match. goal is to find which assort fits the best (traders assort has same loyalty level unlock as quest expects)
|
// Iterate over assorts that match. goal is to find assort that fits the best (traders assort has same loyalty level unlock as quest expects)
|
||||||
string assortIdUnlockedByQuest = string.Empty;
|
string assortIdUnlockedByQuest = string.Empty;
|
||||||
foreach (var match in assortItemsThatMatch)
|
foreach (var match in assortItemsThatMatch)
|
||||||
{
|
{
|
||||||
// Look up item in Loyalty Level array
|
// Look up item in Loyalty Level array
|
||||||
|
|
||||||
var associatedLoyaltyLevelItem = assortRoot.loyal_level_items.FirstOrDefault(x => x.Key == match._id);
|
var associatedLoyaltyLevelItem = assortRoot.loyal_level_items.FirstOrDefault(x => x.Key == match._id);
|
||||||
if (associatedLoyaltyLevelItem.Key == null)
|
if (associatedLoyaltyLevelItem.Key == null)
|
||||||
{
|
{
|
||||||
// end loop if no record found
|
// end loop if no record found in loyalty level array
|
||||||
LoggingHelpers.LogError($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId}. questId: {assortUnlock.QuestId}. no loyalty record found. ({assortItemName})");
|
LoggingHelpers.LogError($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId}. questId: {assortUnlock.QuestId}. no loyalty record found. ({assortItemName})");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (associatedLoyaltyLevelItem.Value != assortUnlock.LoyaltyLevel)
|
if (associatedLoyaltyLevelItem.Value != assortUnlock.LoyaltyLevel)
|
||||||
{
|
{
|
||||||
// loyalty level is different to what was expected, skip
|
// loyalty level is different to what was expected, skip and try next
|
||||||
LoggingHelpers.LogWarning($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId}. questId: {assortUnlock.QuestId}. no match found in LL array. LL{associatedLoyaltyLevelItem.Value}. questListLevel: {assortUnlock.LoyaltyLevel}. ({assortItemName})");
|
LoggingHelpers.LogWarning($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId}. questId: {assortUnlock.QuestId}. no match found in LL array. expected LL{associatedLoyaltyLevelItem.Value}. found: LL{assortUnlock.LoyaltyLevel}. ({assortItemName})");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoggingHelpers.LogInfo($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} {assortItemName}. MATCH FOUND. LL{assortUnlock.LoyaltyLevel}");
|
// LoggingHelpers.LogInfo($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId} {assortItemName}. MATCH FOUND. LL{assortUnlock.LoyaltyLevel}");
|
||||||
assortIdUnlockedByQuest = associatedLoyaltyLevelItem.Key;
|
if (assortItemsThatMatchBlackList.Contains(associatedLoyaltyLevelItem.Key))
|
||||||
|
{
|
||||||
|
// Not the item we want, its already been matched
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
if (result.success.ContainsKey(assortUnlock.QuestId))
|
|
||||||
|
// 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}. questId: {assortUnlock.QuestId}. ALREADY EXISTS. SKIPPING. ({assortItemName})");
|
LoggingHelpers.LogWarning($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId}. questId: {assortUnlock.QuestId}. ALREADY EXISTS. SKIPPING. ({assortItemName})");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (assortIdUnlockedByQuest == string.Empty)
|
||||||
|
{
|
||||||
|
LoggingHelpers.LogError($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId}. questId: {assortUnlock.QuestId}. no assortId found. ({assortItemName})");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
LoggingHelpers.LogSuccess($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId}. questId: {assortUnlock.QuestId}. ADDING TO QUEST-ASSORT. ({assortItemName})");
|
LoggingHelpers.LogSuccess($"{trader} item templateId: {assortUnlock.ItemUnlockedTemplateId}. questId: {assortUnlock.QuestId}. ADDING TO QUEST-ASSORT. ({assortItemName})");
|
||||||
result.success.Add(assortUnlock.QuestId, assortIdUnlockedByQuest);
|
result.success.Add(assortIdUnlockedByQuest, assortUnlock.QuestId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user