diff --git a/AssortUpdater/AssortMerger.cs b/AssortUpdater/AssortMerger.cs index ff1faef..1e5cfbb 100644 --- a/AssortUpdater/AssortMerger.cs +++ b/AssortUpdater/AssortMerger.cs @@ -9,7 +9,7 @@ namespace AssortUpdater { var completeAssorts = new List(); - // 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 completeAssorts) { - IEnumerable? existingAssort = GetAssortByItemIdAndLevel(assortToFind, completeAssorts); + IEnumerable? 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 GetAssortByItemId(FlatAssort assortToFind, List completeAssorts) + { + return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId); + } + private static IEnumerable GetAssortByItemIdAndLevel(FlatAssort assortToFind, List completeAssorts) { return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId