Mercurial > wow > itemauditor
diff Modules/Crafting.lua @ 94:4ec8611d9466
Fixed Enchanting. I was not getting the ItemID correctly, so enchants could not be mapped to the scrolls they were to created
Changed snatch to only add each item once and to only add a snatch for items you don't have
API: Added haveMaterials to the item and need to the reagents that get passed to queue destinations. This is in preparation for building a shopping list module.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Wed, 11 Aug 2010 23:48:23 -0700 |
parents | 693f664aad2b |
children | 63823b6b5e28 |
line wrap: on
line diff
--- a/Modules/Crafting.lua Wed Aug 11 22:16:59 2010 -0700 +++ b/Modules/Crafting.lua Wed Aug 11 23:48:23 2010 -0700 @@ -389,6 +389,8 @@ name = reagentName, count = reagentCount, price = self:GetReagentCost(reagentLink, reagentCount), + need = 0, -- This will get populated after the decisions have been made. it can't + -- be done before that because highest profit items get priority on materials. } totalCost = totalCost + self:GetReagentCost(reagentLink, reagentCount) end @@ -420,6 +422,23 @@ end end table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end) + + local numOwned = {} + for key, data in pairs(realData) do + data.haveMaterials = true + for id, reagent in pairs(data.reagents) do + if not numOwned[reagent.link] then + numOwned[reagent.link] = ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(reagent.link)) + end + numOwned[reagent.link] = numOwned[reagent.link] - reagent.count + + if numOwned[reagent.link] < 0 then + data.haveMaterials = false + reagent.need = min(reagent.count, abs(numOwned[reagent.link])) + end + end + end + if craftingTable then craftingTable:SetFilter(tableFilter) self:RefreshCraftingTable()