Mercurial > wow > itemauditor
comparison Modules/Crafting.lua @ 126:e8d3c299542c
Changed the Have Mats column to show the number of items you could create with the materials you have instead of just a y/n. The have mats filter simply checks that you can make at least 1.
| author | Asa Ayers <Asa.Ayers@Gmail.com> |
|---|---|
| date | Thu, 02 Sep 2010 22:34:22 -0700 |
| parents | 060d1c45afab |
| children | 451d8a19edea |
comparison
equal
deleted
inserted
replaced
| 125:bb78b6c9892d | 126:e8d3c299542c |
|---|---|
| 155 if Crafting.filter_show_all then | 155 if Crafting.filter_show_all then |
| 156 return true | 156 return true |
| 157 end | 157 end |
| 158 | 158 |
| 159 -- column 5 is how many should be crafted | 159 -- column 5 is how many should be crafted |
| 160 if Crafting.filter_have_mats and row[6] == 'n' then | 160 if Crafting.filter_have_mats and row[6] == 0 then |
| 161 return false | 161 return false |
| 162 end | 162 end |
| 163 if strfind(row[4], 'VETO: .*') or row[5] == 0 then | 163 if strfind(row[4], 'VETO: .*') or row[5] == 0 then |
| 164 return false | 164 return false |
| 165 end | 165 end |
| 535 table.sort(realData, function(a, b) return a.profit*max(1, a.queue) > b.profit*max(1, b.queue) end) | 535 table.sort(realData, function(a, b) return a.profit*max(1, a.queue) > b.profit*max(1, b.queue) end) |
| 536 | 536 |
| 537 local numOwned = {} | 537 local numOwned = {} |
| 538 | 538 |
| 539 for key, data in pairs(realData) do | 539 for key, data in pairs(realData) do |
| 540 data.haveMaterials = true | 540 data.haveMaterials = data.queue |
| 541 for id, reagent in pairs(data.reagents) do | 541 for id, reagent in pairs(data.reagents) do |
| 542 local needEach = reagent.count | |
| 542 reagent.count = reagent.count * data.queue | 543 reagent.count = reagent.count * data.queue |
| 543 | 544 |
| 544 if not numOwned[reagent.link] then | 545 if not numOwned[reagent.link] then |
| 545 numOwned[reagent.link] = ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(reagent.link)) | 546 numOwned[reagent.link] = ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(reagent.link)) |
| 546 end | 547 end |
| 548 data.haveMaterials = min(data.haveMaterials, floor(numOwned[reagent.link] / needEach)) | |
| 547 numOwned[reagent.link] = numOwned[reagent.link] - reagent.count | 549 numOwned[reagent.link] = numOwned[reagent.link] - reagent.count |
| 548 | 550 |
| 549 -- Vellums count in cost, but not against whether or not you have the mats. | 551 -- Vellums count in cost, but not against whether or not you have the mats. |
| 550 -- I chose to do it this way because you can use a higher level of vellum | 552 -- I chose to do it this way because you can use a higher level of vellum |
| 551 -- and I'm not sure the best way to determine cost and materials in that situation. | 553 -- and I'm not sure the best way to determine cost and materials in that situation. |
| 552 if numOwned[reagent.link] < 0 and not vellumLevelMap[reagent.itemID] then | 554 if numOwned[reagent.link] < 0 and not vellumLevelMap[reagent.itemID] then |
| 553 data.haveMaterials = false | |
| 554 reagent.need = min(reagent.count, abs(numOwned[reagent.link])) | 555 reagent.need = min(reagent.count, abs(numOwned[reagent.link])) |
| 555 end | 556 end |
| 556 end | 557 end |
| 558 data.haveMaterials = max(0, data.haveMaterials) | |
| 557 end | 559 end |
| 558 | 560 |
| 559 if craftingTable then | 561 if craftingTable then |
| 560 craftingTable:SetFilter(tableFilter) | 562 craftingTable:SetFilter(tableFilter) |
| 561 self:RefreshCraftingTable() | 563 self:RefreshCraftingTable() |
| 562 end | 564 end |
| 563 end | 565 end |
| 564 | 566 |
| 565 function ItemAuditor:RefreshCraftingTable() | 567 function ItemAuditor:RefreshCraftingTable() |
| 566 local displayMaterials | |
| 567 for key, data in pairs(realData) do | 568 for key, data in pairs(realData) do |
| 568 displayMaterials = 'n' | |
| 569 if data.haveMaterials then | |
| 570 displayMaterials = 'y' | |
| 571 end | |
| 572 tableData[key] = { | 569 tableData[key] = { |
| 573 data.name, | 570 data.name, |
| 574 data.cost, | 571 data.cost, |
| 575 data.price, | 572 data.price, |
| 576 data.winner, | 573 data.winner, |
| 577 abs(data.queue), | 574 abs(data.queue), |
| 578 displayMaterials, | 575 data.haveMaterials, |
| 579 data.profit, | 576 data.profit, |
| 580 } | 577 } |
| 581 end | 578 end |
| 582 craftingTable:SetData(tableData, true) | 579 craftingTable:SetData(tableData, true) |
| 583 | 580 |
