Show better errors when there are multiple live assorts at the same trader level
This commit is contained in:
parent
2e7a4cf358
commit
c07d793458
@ -79,7 +79,7 @@ namespace AssortValidator
|
||||
}
|
||||
else
|
||||
{
|
||||
LoggingHelpers.LogError("no missing assorts found in offline when compared to live :)");
|
||||
LoggingHelpers.LogSuccess("no missing assorts found in offline when compared to live :)");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -107,7 +107,7 @@ namespace AssortValidator
|
||||
LoggingHelpers.LogInfo($"{trader.Key}: itemId: {assort._id} - tpId: {assort._tpl} ({itemName}) Level {assortLoyaltyLevel}");
|
||||
LogUnlockQuest(questAssortUnlocks, assort, assortLoyaltyLevel);
|
||||
|
||||
var liveAssort = GetLiveAssort(correspondingLiveTrader.items, assort._tpl, correspondingLiveTrader.loyal_level_items, assortLoyaltyLevel);
|
||||
var liveAssort = GetLiveAssort(correspondingLiveTrader, assort._tpl, assortLoyaltyLevel);
|
||||
if (liveAssort == null)
|
||||
{
|
||||
continue;
|
||||
@ -269,8 +269,11 @@ namespace AssortValidator
|
||||
ValueCheckerHelper.CheckValuesMatch(assort.upd.BuyRestrictionMax.GetValueOrDefault(0), correspondingLiveAssort.upd.BuyRestrictionMax.GetValueOrDefault(0), "BuyRestrictionMax does not match");
|
||||
}
|
||||
|
||||
private static LiveAssort.Item GetLiveAssort(List<LiveAssort.Item> liveAssorts, string templateId, Dictionary<string, int> loyaltyLevels, int expectedLoyaltyLevel)
|
||||
private static LiveAssort.Item GetLiveAssort(LiveAssort trader, string templateId, int expectedLoyaltyLevel)
|
||||
{
|
||||
var liveAssorts = trader.items;
|
||||
var liveLoyaltyLevels = trader.loyal_level_items;
|
||||
|
||||
var liveAssortsWithTemplateId = liveAssorts.Where(x => x._tpl == templateId).ToList();
|
||||
|
||||
if (liveAssortsWithTemplateId.Count == 0)
|
||||
@ -290,26 +293,33 @@ namespace AssortValidator
|
||||
// More than one assort found
|
||||
// Gather assort ids and use them to get loyalty level records
|
||||
var liveAssortsIds = liveAssortsWithTemplateId.Select(x => x._id);
|
||||
var liveloyaltyLevelsForTemplateId = loyaltyLevels.Where(x => liveAssortsIds.Contains(x.Key)).ToList();
|
||||
var liveLoyaltyLevelsForTemplateId = liveLoyaltyLevels.Where(x => liveAssortsIds.Contains(x.Key)).ToList();
|
||||
|
||||
if (liveloyaltyLevelsForTemplateId.All(x => x.Value == expectedLoyaltyLevel) && liveloyaltyLevelsForTemplateId.Count > 1)
|
||||
// Same loyalty level + multiple found
|
||||
if (liveLoyaltyLevelsForTemplateId.All(x => x.Value == expectedLoyaltyLevel) && liveLoyaltyLevelsForTemplateId.Count > 1)
|
||||
{
|
||||
// Both have same loyalty level, cant proceed;
|
||||
LoggingHelpers.LogError($"Unable to find live assort item: {templateId} ({ItemTemplateHelper.GetTemplateById(templateId)._name}) ");
|
||||
LoggingHelpers.LogError($"Multiple ({liveLoyaltyLevelsForTemplateId.Count}) live assorts for this tpId found at same Level ({expectedLoyaltyLevel}) - Unable to distinguish: {templateId} ({ItemTemplateHelper.GetTemplateById(templateId)._name}) ");
|
||||
|
||||
LoggingHelpers.LogNewLine();
|
||||
return null;
|
||||
}
|
||||
|
||||
IEnumerable<KeyValuePair<string, int>> loyaltyLevelItemThatMatches = liveloyaltyLevelsForTemplateId.Where(x => x.Value == expectedLoyaltyLevel);
|
||||
var loyaltyLevelItemThatMatches = liveLoyaltyLevelsForTemplateId.Where(x => x.Value == expectedLoyaltyLevel);
|
||||
if (loyaltyLevelItemThatMatches != null && loyaltyLevelItemThatMatches.Count() > 1)
|
||||
{
|
||||
LoggingHelpers.LogWarning($"({loyaltyLevelItemThatMatches.Count()}) live items found, choosing first one in list");
|
||||
}
|
||||
|
||||
if (loyaltyLevelItemThatMatches == null)
|
||||
{
|
||||
// Both have same loyalty level, cant proceed;
|
||||
LoggingHelpers.LogError($"Unable to find live assort item: {templateId} ({ItemTemplateHelper.GetTemplateById(templateId)._name})");
|
||||
LoggingHelpers.LogError($"No live assort for this tpId found at same level - Unable proceed: {templateId} ({ItemTemplateHelper.GetTemplateById(templateId)._name})");
|
||||
LoggingHelpers.LogNewLine();
|
||||
return null;
|
||||
}
|
||||
|
||||
return liveAssorts.FirstOrDefault(x => x._id == loyaltyLevelItemThatMatches.FirstOrDefault().Key);
|
||||
return liveAssorts.Find(x => x._id == loyaltyLevelItemThatMatches.FirstOrDefault().Key);
|
||||
}
|
||||
|
||||
private static int GetRoundedStackCount(int stackObjectsCount)
|
||||
|
Loading…
x
Reference in New Issue
Block a user