Check for single item with same itemId prior to inserting item from existing assort file into merged file

This commit is contained in:
Chomp 2022-01-15 15:00:21 +00:00
parent 2fa1e95281
commit 6b86c6c29a

View File

@ -9,7 +9,7 @@ namespace AssortUpdater
{
var completeAssorts = new List<FlatAssort>();
// Add live assorts
// Add live assorts to merged list
foreach (var liveAssort in flattenedLiveAssorts)
{
completeAssorts.Add(liveAssort);
@ -41,7 +41,14 @@ namespace AssortUpdater
private static FlatAssort? GetMatchingAssortFromCompleteList(string traderName, FlatAssort assortToFind, List<FlatAssort> completeAssorts)
{
IEnumerable<FlatAssort>? existingAssort = GetAssortByItemIdAndLevel(assortToFind, completeAssorts);
IEnumerable<FlatAssort>? existingAssort = GetAssortByItemId(assortToFind, completeAssorts);
if (existingAssort.Any() && existingAssort.Count() == 1)
{
// one match found by id, dont add
return existingAssort.First();
}
existingAssort = GetAssortByItemIdAndLevel(assortToFind, completeAssorts);
if (SingleAssortFound(existingAssort))
{
@ -101,6 +108,11 @@ namespace AssortUpdater
&& x.BarterDetails[0].count == assortToFind.BarterDetails[0].count);
}
private static IEnumerable<FlatAssort> GetAssortByItemId(FlatAssort assortToFind, List<FlatAssort> completeAssorts)
{
return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId);
}
private static IEnumerable<FlatAssort> GetAssortByItemIdAndLevel(FlatAssort assortToFind, List<FlatAssort> completeAssorts)
{
return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId