diff --git a/Classes/RecipeData.lua b/Classes/RecipeData.lua index a39c0485..782deeac 100644 --- a/Classes/RecipeData.lua +++ b/Classes/RecipeData.lua @@ -479,6 +479,8 @@ end --- also sets a requiredSelectionReagent if not yet set function CraftSim.RecipeData:SetNonQualityReagentsMax() + local print = CraftSim.DEBUG:RegisterDebugID("Classes.RecipeData.SetNonQualityReagentsMax") + print("SetNonQualityReagentsMax", false, true) for _, reagent in pairs(self.reagentData.requiredReagents) do if not reagent.hasQuality then reagent.items[1].quantity = reagent.requiredQuantity @@ -486,12 +488,41 @@ function CraftSim.RecipeData:SetNonQualityReagentsMax() end if self.reagentData:HasRequiredSelectableReagent() then + print("- HasRequiredSelectableReagent", false, false) if not self.reagentData.requiredSelectableReagentSlot.activeReagent then - for _, possibleRequiredSelectableReagent in pairs(self.reagentData.requiredSelectableReagentSlot.possibleReagents or {}) do - if possibleRequiredSelectableReagent:IsOrderReagentIn(self) then - self.reagentData.requiredSelectableReagentSlot:SetReagent(possibleRequiredSelectableReagent.item - :GetItemID()) - break + print("- No active reagent", false, false) + local orderReagent = GUTIL:Find(self.reagentData.requiredSelectableReagentSlot.possibleReagents or {}, + function(possibleOrderReagent) + if possibleOrderReagent:IsOrderReagentIn(self) then + return true + end + return false + end) + if orderReagent then + self.reagentData.requiredSelectableReagentSlot:SetReagent(orderReagent.item:GetItemID()) + else + local cheapestReagent + local cheapestPrice + local possibleReagents = GUTIL:Filter( + self.reagentData.requiredSelectableReagentSlot.possibleReagents or {}, function(optionalReagent) + return not GUTIL:isItemSoulbound(optionalReagent.item:GetItemID()) + end) + for _, optionalReagent in ipairs(possibleReagents) do + local reagentPrice = CraftSim.PRICE_SOURCE:GetMinBuyoutByItemID(optionalReagent.item:GetItemID(), + true, false, true) + if not cheapestReagent then + cheapestReagent = optionalReagent + cheapestPrice = reagentPrice + else + if reagentPrice < cheapestPrice then + cheapestPrice = reagentPrice + cheapestReagent = optionalReagent + end + end + end + + if cheapestReagent then + self.reagentData.requiredSelectableReagentSlot:SetReagent(cheapestReagent.item:GetItemID()) end end end diff --git a/CraftSim.toc b/CraftSim.toc index 0f7db1be..bd1f0654 100644 --- a/CraftSim.toc +++ b/CraftSim.toc @@ -4,7 +4,7 @@ ## Title: CraftSim ## Notes: Calculates the average profit based on your profession stats and other tools for the war within gold making ## Author: genju -## Version: 19.6.2 +## Version: 19.6.3 ## X-Curse-Project-ID: 705015 ## X-Wago-ID: 0mNwaPKo ## X-WoWI-ID: 26519 diff --git a/Data/News.lua b/Data/News.lua index 442a560c..c802d87c 100644 --- a/Data/News.lua +++ b/Data/News.lua @@ -17,6 +17,9 @@ function CraftSim.NEWS:GET_NEWS(itemMap) local news = { f.bb(" Hello and thank you for using CraftSim!\n"), f.bb(" ( You are awesome! )"), + newP("19.6.3"), + f.s .. "Fixed " .. f.bb("CraftLog") .. " PvP Item Bug", + f.s .. "Fixed " .. f.bb("CraftQueue") .. " PvP Item Queueing", newP("19.6.2"), f.s .. f.bb("Craft Log"), f.a .. "- Fixed not updating the graph", diff --git a/Libs/GUTIL b/Libs/GUTIL index b34bda8f..942d2e43 160000 --- a/Libs/GUTIL +++ b/Libs/GUTIL @@ -1 +1 @@ -Subproject commit b34bda8ff2fbf5d2be91ed8ea648bac2dff30378 +Subproject commit 942d2e437c5fb1c21ea5a63df188fe862bae56fb