Mercurial > wow > itemauditor
comparison 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 |
comparison
equal
deleted
inserted
replaced
93:693f664aad2b | 94:4ec8611d9466 |
---|---|
387 reagents[reagentId] = { | 387 reagents[reagentId] = { |
388 link = reagentLink, | 388 link = reagentLink, |
389 name = reagentName, | 389 name = reagentName, |
390 count = reagentCount, | 390 count = reagentCount, |
391 price = self:GetReagentCost(reagentLink, reagentCount), | 391 price = self:GetReagentCost(reagentLink, reagentCount), |
392 need = 0, -- This will get populated after the decisions have been made. it can't | |
393 -- be done before that because highest profit items get priority on materials. | |
392 } | 394 } |
393 totalCost = totalCost + self:GetReagentCost(reagentLink, reagentCount) | 395 totalCost = totalCost + self:GetReagentCost(reagentLink, reagentCount) |
394 end | 396 end |
395 local data = { | 397 local data = { |
396 recipeLink = recipeLink, | 398 recipeLink = recipeLink, |
418 row = row + 1 | 420 row = row + 1 |
419 end | 421 end |
420 end | 422 end |
421 end | 423 end |
422 table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end) | 424 table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end) |
425 | |
426 local numOwned = {} | |
427 for key, data in pairs(realData) do | |
428 data.haveMaterials = true | |
429 for id, reagent in pairs(data.reagents) do | |
430 if not numOwned[reagent.link] then | |
431 numOwned[reagent.link] = ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(reagent.link)) | |
432 end | |
433 numOwned[reagent.link] = numOwned[reagent.link] - reagent.count | |
434 | |
435 if numOwned[reagent.link] < 0 then | |
436 data.haveMaterials = false | |
437 reagent.need = min(reagent.count, abs(numOwned[reagent.link])) | |
438 end | |
439 end | |
440 end | |
441 | |
423 if craftingTable then | 442 if craftingTable then |
424 craftingTable:SetFilter(tableFilter) | 443 craftingTable:SetFilter(tableFilter) |
425 self:RefreshCraftingTable() | 444 self:RefreshCraftingTable() |
426 end | 445 end |
427 end | 446 end |