From cb1f23c8f61cf2876b43b767c992e2ea1264ffde Mon Sep 17 00:00:00 2001 From: Chomp Date: Sat, 15 Jan 2022 17:21:24 +0000 Subject: [PATCH] i have no idea, stuff i guess --- AssortUpdater/AssortMerger.cs | 46 +++++++++++++++---- .../Helpers/AssortHelper.cs | 2 +- AssortValidator.Common/Helpers/QuestHelper.cs | 6 +++ 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/AssortUpdater/AssortMerger.cs b/AssortUpdater/AssortMerger.cs index 063645a..82f6dc5 100644 --- a/AssortUpdater/AssortMerger.cs +++ b/AssortUpdater/AssortMerger.cs @@ -12,6 +12,18 @@ namespace AssortUpdater // Add live assorts to merged list foreach (var liveAssort in flattenedLiveAssorts) { + if (liveAssort.AssortId == "61e0a2a8033bdc459438d31f") + { + var x = 1; + } + if (liveAssort.RawItem.upd.StackObjectsCount == 0) + { + var newStackCount = liveAssort.RawItem.upd.BuyRestrictionMax.HasValue + ? (liveAssort.RawItem.upd.BuyRestrictionMax.Value * 10) + : 1000; + liveAssort.RawItem.upd.StackObjectsCount = newStackCount; + LoggingHelpers.LogWarning($"live assort: {liveAssort.ItemName} level: {liveAssort.Level} has a stack of 0, adding a new value of {newStackCount}"); + } completeAssorts.Add(liveAssort); } LoggingHelpers.LogSuccess($"{trader} Added {flattenedLiveAssorts.Count} items from live"); @@ -83,6 +95,15 @@ namespace AssortUpdater return existingAssort.First(); } + existingAssort = GetAssortByItemIdIsMoneyAndSubItemCount(assortToFind, completeAssorts); + if (MultipleAssortsFound(existingAssort)) + { + throw new Exception("oh shit"); + } + if (SingleAssortFound(existingAssort)) + { + return existingAssort.First(); + } //LoggingHelpers.LogError($"{traderName} No match found for item: {assortToFind.ItemId} {assortToFind.ItemName} Level: {assortToFind.Level}"); // No matches found, probably doesnt exist @@ -102,28 +123,37 @@ namespace AssortUpdater private static IEnumerable GetAssortByItemIdLevelMoneySubItemCountAndCostItemCount(FlatAssort assortToFind, List completeAssorts) { return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId - && x.Level == assortToFind.Level - && x.IsMoney == assortToFind.IsMoney - && x.SubItems.Count == assortToFind.SubItems.Count - && x.BarterDetails[0].count == assortToFind.BarterDetails[0].count); + && x.Level == assortToFind.Level + && x.IsMoney == assortToFind.IsMoney + && x.SubItems.Count == assortToFind.SubItems.Count + && x.BarterDetails[0].count == assortToFind.BarterDetails[0].count); } private static IEnumerable GetAssortByItemId(FlatAssort assortToFind, List completeAssorts) { - return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId); + return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId + && x.AssortId != assortToFind.AssortId); } private static IEnumerable GetAssortByItemIdAndLevel(FlatAssort assortToFind, List completeAssorts) { return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId - && x.Level == assortToFind.Level); + && x.Level == assortToFind.Level); } private static IEnumerable GetAssortByItemIdLevelAndMoney(FlatAssort assortToFind, List completeAssorts) { return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId - && x.Level == assortToFind.Level - && x.IsMoney == assortToFind.IsMoney); + && x.Level == assortToFind.Level + && x.IsMoney == assortToFind.IsMoney); + } + + private static IEnumerable? GetAssortByItemIdIsMoneyAndSubItemCount(FlatAssort assortToFind, List completeAssorts) + { + return completeAssorts.Where(x => x.ItemId == assortToFind.ItemId + && x.IsMoney == assortToFind.IsMoney + && x.SubItems.Count == assortToFind.SubItems.Count + && x.BarterDetails.Count == assortToFind.BarterDetails.Count); } private static IEnumerable? GetAssortByBarterCostAndCount(FlatAssort assortToFind, List completeAssorts) diff --git a/AssortValidator.Common/Helpers/AssortHelper.cs b/AssortValidator.Common/Helpers/AssortHelper.cs index ac566e0..a2600b1 100644 --- a/AssortValidator.Common/Helpers/AssortHelper.cs +++ b/AssortValidator.Common/Helpers/AssortHelper.cs @@ -109,7 +109,7 @@ namespace AssortValidator.Common.Helpers if (traderType != Trader.Unknown) { _assortLiveDataCache.Add(traderType, parsedAssorts.data); - } + } } } diff --git a/AssortValidator.Common/Helpers/QuestHelper.cs b/AssortValidator.Common/Helpers/QuestHelper.cs index 04d70d7..bcf413e 100644 --- a/AssortValidator.Common/Helpers/QuestHelper.cs +++ b/AssortValidator.Common/Helpers/QuestHelper.cs @@ -259,6 +259,12 @@ namespace AssortValidator.Common.Helpers { "6179afd0bca27a099552e040", "Lost Contact"}, { "613708a7f8333a5d15594368", "Action Test"} }; + + public static Quest GetQuestById(string questId) + { + return _liveQuestData[questId]; + } + private static Dictionary _liveQuestData; public static Dictionary GetQuestDataFromDump(string filename = "resp.client.quest.list")