Improve handling of finding assort unlock reward items

This commit is contained in:
Chomp 2021-09-12 15:41:15 +01:00
parent 076b0d23c5
commit 3255f7df93

View File

@ -68,6 +68,12 @@ namespace QuestValidator
// Check image id matches // Check image id matches
CheckValuesMatch(quest.image.Substring(0, quest.image.Length - 4), relatedLiveQuest?.image.Substring(0, relatedLiveQuest.image.Length - 4), "item path mismatch"); CheckValuesMatch(quest.image.Substring(0, quest.image.Length - 4), relatedLiveQuest?.image.Substring(0, relatedLiveQuest.image.Length - 4), "item path mismatch");
//Check image id contains quest id
if (!quest.image.Contains(quest._id))
{
LoggingHelpers.LogWarning($"WARNING Quest image path does not contain quest id");
}
// Check started reward count matches // Check started reward count matches
CheckValuesMatch(quest.rewards.Started.Count, relatedLiveQuest.rewards.Started.Count, "Started item count mismatch"); CheckValuesMatch(quest.rewards.Started.Count, relatedLiveQuest.rewards.Started.Count, "Started item count mismatch");
@ -99,9 +105,9 @@ namespace QuestValidator
// Get live reward item by index and type // Get live reward item by index and type
var relatedLiveRewardItem = GetLiveRewardItem(questSuccessRewardItem, liveQuestSuccessRewardItems); var relatedLiveRewardItem = GetLiveRewardItem(questSuccessRewardItem, liveQuestSuccessRewardItems);
LogUnableToFindSuccessItemInLiveData(questSuccessRewardItem, relatedLiveRewardItem);
if (relatedLiveRewardItem == null) if (relatedLiveRewardItem == null)
{ {
LogUnableToFindSuccessItemInLiveData(questSuccessRewardItem, relatedLiveRewardItem);
continue; continue;
} }
@ -156,7 +162,29 @@ namespace QuestValidator
foreach (var questSuccessRewardItem in quest.rewards.Success.Where(x => x.type == "AssortmentUnlock")) foreach (var questSuccessRewardItem in quest.rewards.Success.Where(x => x.type == "AssortmentUnlock"))
{ {
var relatedLiveRewardItem = liveQuestSuccessRewardItems.Find(x => x.id == questSuccessRewardItem.id && x.type == "AssortmentUnlock"); // 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
if (relatedLiveRewardItem == null)
{
relatedLiveRewardItem = possibleLiveRewardItems.FirstOrDefault(x => x.traderId == questSuccessRewardItem.traderId);
}
}
if (relatedLiveRewardItem == null) if (relatedLiveRewardItem == null)
{ {
relatedLiveRewardItem = liveQuestSuccessRewardItems.Find(x => x.traderId == questSuccessRewardItem.traderId relatedLiveRewardItem = liveQuestSuccessRewardItems.Find(x => x.traderId == questSuccessRewardItem.traderId
@ -185,13 +213,18 @@ namespace QuestValidator
{ {
foreach (var subItem in questSuccessRewardItem.items.Where(x => !string.IsNullOrEmpty(x.slotId))) foreach (var subItem in questSuccessRewardItem.items.Where(x => !string.IsNullOrEmpty(x.slotId)))
{ {
// find matching live counterpart by slotid // find live item by slotid
var liveCounterpart = relatedLiveRewardItem.items.Where(x => x.slotId == subItem.slotId); var liveCounterpart = relatedLiveRewardItem.items.Where(x => x.slotId == subItem.slotId);
if (liveCounterpart == null || liveCounterpart.Count() == 0) if (liveCounterpart == null || liveCounterpart.Count() == 0)
{ {
LoggingHelpers.LogWarning($"a live counterpart for the subItem {subItem.slotId} could not be found, skipping subItem check"); // Look for live item by template id
liveCounterpart = relatedLiveRewardItem.items.Where(x => x._tpl == subItem._tpl);
if (liveCounterpart == null || liveCounterpart.Count() == 0)
{
LoggingHelpers.LogWarning($"a live counterpart for the subItem {subItem.slotId} could not be found by slotid or tpId, skipping subItem check");
continue; continue;
} }
}
if (liveCounterpart.Count() > 1) if (liveCounterpart.Count() > 1)
{ {
LoggingHelpers.LogWarning($"Multiple live counterparts for the subItem {subItem.slotId} found, skipping subItem check"); LoggingHelpers.LogWarning($"Multiple live counterparts for the subItem {subItem.slotId} found, skipping subItem check");
@ -237,6 +270,18 @@ namespace QuestValidator
var LiveItemRewards = liveQuestSuccessRewardItems.Where(x => x.type == "Item"); var LiveItemRewards = liveQuestSuccessRewardItems.Where(x => x.type == "Item");
var liveRewardItemByIndex = LiveItemRewards.FirstOrDefault(x => x.index == questSuccessRewardItem.index); var liveRewardItemByIndex = LiveItemRewards.FirstOrDefault(x => x.index == questSuccessRewardItem.index);
// no item found by index, find by template id
if (liveRewardItemByIndex == null)
{
foreach (var liveItem in LiveItemRewards
.SelectMany(liveItem => liveItem.items
.Where(subItem => subItem._tpl == questSuccessRewardItem.items[0]._tpl)
.Select(subItem => liveItem)))
{
return liveItem;
}
}
// item found by index but template id didnt match // item found by index but template id didnt match
if (liveRewardItemByIndex != null && liveRewardItemByIndex.items[0]._tpl != questSuccessRewardItem.items[0]._tpl) if (liveRewardItemByIndex != null && liveRewardItemByIndex.items[0]._tpl != questSuccessRewardItem.items[0]._tpl)
{ {