Mercurial > wow > itemauditor
changeset 68:2d65db19d3ce
Fixed a bug with the crafting threshold options. Updated /ia queue so that it is a shortcut to using /ia crafting and then clicking export.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Wed, 28 Jul 2010 11:37:43 -0700 |
parents | b6c30a5156f9 |
children | 4ae431c98059 |
files | CHANGELOG.txt Core.lua Modules/Crafting.lua Modules/Options.lua Modules/QuickAuctions.lua |
diffstat | 5 files changed, 60 insertions(+), 134 deletions(-) [+] |
line wrap: on
line diff
--- a/CHANGELOG.txt Wed Jul 28 07:35:14 2010 -0700 +++ b/CHANGELOG.txt Wed Jul 28 11:37:43 2010 -0700 @@ -1,3 +1,8 @@ +2010-07-28 Asa Ayers <Asa.Ayers@Gmail.com> + +- Fixed a bug with the crafting threshold options. +- Updated /ia queue so that it is a shortcut to using /ia crafting and then clicking export. + 2010-07-27 Asa Ayers <Asa.Ayers@Gmail.com> - Fixed an infinite loop when when adding items to the Skillet queue from the crafting interface.
--- a/Core.lua Wed Jul 28 07:35:14 2010 -0700 +++ b/Core.lua Wed Jul 28 11:37:43 2010 -0700 @@ -71,16 +71,15 @@ self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor") - DevTools_Dump(ItemAuditor.Options); LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", ItemAuditor.Options, {"ia"}) ItemAuditor:RegisterFrame(ItemAuditor_DebugFrame) --@debug@ -- ItemAuditor_DebugFrame:Show() -- self:CreateFrame('tab_crafting') - self:RegisterEvent("TRADE_SKILL_SHOW", function() - ItemAuditor:CreateFrame('tab_crafting') - end) +-- self:RegisterEvent("TRADE_SKILL_SHOW", function() +-- ItemAuditor:CreateFrame('tab_crafting') +-- end) --@end-debug@ end
--- a/Modules/Crafting.lua Wed Jul 28 07:35:14 2010 -0700 +++ b/Modules/Crafting.lua Wed Jul 28 11:37:43 2010 -0700 @@ -10,6 +10,12 @@ local realData = {} +local queueDestinations = {} + +function Crafting.RegisterQueueDestination(name, destination) + queueDestinations[name] = destination +end + -- TODO: Convert this to a text field. local craftingThresholds = {5000, 10000, 50000} local craftingThresholdsDisplay = {} @@ -19,6 +25,11 @@ -- craftingThresholdsDisplay[key] = value end +function ItemAuditor:GetCraftingThreshold() + local key = ItemAuditor.db.char.crafting_threshold + return craftingThresholds[key] +end + ItemAuditor.Options.args.crafting_options = { name = "Crafting with Skillet", desc = "/ia queue", @@ -75,14 +86,34 @@ }, } -local function ExportToSkillet() +function Crafting.ExportToSkillet(data) + local skillString = select(3, string.find(data.recipeLink, "^|%x+|H(.+)|h%[.+%]")) + local _, skillId = strsplit(":", skillString) + + ItemAuditor:AddToQueue(skillId,tradeSkillIndex, data.queue) +end + +Crafting.RegisterQueueDestination('Skillet', Crafting.ExportToSkillet) + + + +function Crafting.Export(destination) + if type(destination) == 'function' then + -- do nothing + elseif destination == nil then + destination = queueDestinations['Skillet'] + elseif type(destination) == 'string' then + destination = queueDestinations[destination] + else + error('destination must be a function or a string') + end + local index = 1 local data = ItemAuditor:GetCraftingRow(index) while data do - local skillString = select(3, string.find(data.recipeLink, "^|%x+|H(.+)|h%[.+%]")) - local _, skillId = strsplit(":", skillString) - - ItemAuditor:AddToQueue(skillId,tradeSkillIndex, data.queue) + if data.queue > 0 then + destination(data) + end index = index + 1 data = ItemAuditor:GetCraftingRow(index) @@ -318,8 +349,10 @@ end end table.sort(realData, function(a, b) return a.profit*a.queue > b.profit*b.queue end) - craftingTable:SetFilter(tableFilter) - self:RefreshCraftingTable() + if craftingTable then + craftingTable:SetFilter(tableFilter) + self:RefreshCraftingTable() + end end function ItemAuditor:RefreshCraftingTable()
--- a/Modules/Options.lua Wed Jul 28 07:35:14 2010 -0700 +++ b/Modules/Options.lua Wed Jul 28 11:37:43 2010 -0700 @@ -81,10 +81,7 @@ return iter end -function ItemAuditor:GetCraftingThreshold() - local key = ItemAuditor.db.char.crafting_threshold - return craftingThresholds[key] -end + function ItemAuditor:GetAuctionThreshold() return ItemAuditor.db.char.auction_threshold
--- a/Modules/QuickAuctions.lua Wed Jul 28 07:35:14 2010 -0700 +++ b/Modules/QuickAuctions.lua Wed Jul 28 11:37:43 2010 -0700 @@ -1,6 +1,7 @@ local ItemAuditor = select(2, ...) local QuickAuctions= ItemAuditor:NewModule("QuickAuctions") local Crafting = ItemAuditor:GetModule("Crafting") +local Utils = ItemAuditor:GetModule("Utils") --[[ This is simply for compatibility while I change the QA API. Once @@ -116,127 +117,18 @@ end Crafting.RegisterCraftingDecider('IA QuickAuctions', isProfitable) ---[[ - This is based on KTQ -]] + function ItemAuditor:Queue() - if LSW == nil then - self:Print("This feature requires LilSparky's Workshop.") - return + local function Export(data) + ItemAuditor:Print(format("Adding %s x%s to skillet queue. Profit: %s", + data.link, + data.queue, + Utils.FormatMoney(data.profit) + )) + Crafting.ExportToSkillet(data) end - if Skillet == nil then - self:Print("This feature requires Skillet.") - return - end - if GetAuctionBuyout ~= nil then - elseif AucAdvanced and AucAdvanced.Version then - else - self:Print("This feature requires Auctionator, Auctioneer, AuctionLite, or AuctionMaster.") - return - end - - - if ItemAuditor.IsQAEnabled() then - self:Debug("Auction Threshold: %d%%", self:GetAuctionThreshold()*100 ) - end - self:Debug(format("Crafting Threshold: %s", self:FormatMoney(self:GetCraftingThreshold()))) - local profitableItems = {} - local profitableIndex = 1 - local numChecked = 0 - - for i = 1, GetNumTradeSkills() do - local itemLink = GetTradeSkillItemLink(i) - local itemId = Skillet:GetItemIDFromLink(itemLink) - - --Figure out if its an enchant or not - _, _, _, _, altVerb = GetTradeSkillInfo(i) - if LSW.scrollData[itemId] ~= nil and altVerb == 'Enchant' then - -- Ask LSW for the correct scroll - itemId = LSW.scrollData[itemId]["scrollID"] - end - - local skillName, skillType, numAvailable, isExpanded, altVerb = GetTradeSkillInfo(i) - local recipeLink = GetTradeSkillRecipeLink(i) - local stackSize = 1 - if recipeLink ~= nil then - _, itemLink= GetItemInfo(itemId) - - - -- if QA isn't enabled, this will just return nil - local QAGroup = nil - if ItemAuditor.IsQAEnabled() then - QAGroup = QAAPI:GetItemGroup(itemLink) - if QAGroup ~= nil then - local threshold, postCap, perAuction = QAAPI:GetGroupConfig(QAGroup) - stackSize = postCap * perAuction - stackSize = stackSize / GetTradeSkillNumMade(i) - - -- bonus - stackSize = ceil(stackSize *1.25) - end - end - - local count = Altoholic:GetItemCount(itemId) - - if count < stackSize and itemLink ~= nil then - local found, _, skillString = string.find(recipeLink, "^|%x+|H(.+)|h%[.+%]") - local _, skillId = strsplit(":", skillString ) - - local toQueue = stackSize - count - local newCost = 0 - for reagentId = 1, GetTradeSkillNumReagents(i) do - _, _, reagentCount = GetTradeSkillReagentInfo(i, reagentId); - reagentLink = GetTradeSkillReagentItemLink(i, reagentId) - newCost = newCost + ItemAuditor:GetReagentCost(reagentLink, reagentCount) - end - - local currentInvested, _, currentCount = ItemAuditor:GetItemCost(itemLink) - local newThreshold = (newCost + currentInvested) / (currentCount + toQueue) - - if ItemAuditor.IsQAEnabled() then - newThreshold = calculateQAThreshold(newThreshold) - else - -- if quick auctions isn't enabled, this will cause the decision to rely - -- completly on the crafting threshold - newThreshold = 0 - end - local currentPrice = ItemAuditor:GetAuctionPrice(itemLink) or 0 - numChecked = numChecked + 1 - - if newThreshold < currentPrice and (currentPrice - newCost) > self:GetCraftingThreshold() then - - profitableItems[profitableIndex] = { - itemLink = itemLink, - SkillID = skillId, - Index = i, - toQueue = toQueue, - profit = (currentPrice - newCost) * toQueue - } - profitableIndex = profitableIndex + 1 - else - local skipMessage = format("Skipping %s x%s. Profit: %s ", itemLink, toQueue, ItemAuditor:FormatMoney(currentPrice - newCost)) - if ItemAuditor.db.profile.messages.queue_skip then - self:Print(skipMessage) - else - self:Debug(format("Skipping %s x%s. Profit: %s ", itemLink, toQueue, ItemAuditor:FormatMoney(currentPrice - newCost))) - end - end - end - end - end - local numAdded = 0 - table.sort(profitableItems, function(a, b) return a.profit > b.profit end) - for key, data in pairs(profitableItems) do - self:Print(format("Adding %s x%s to skillet queue. Profit: %s", - data.itemLink, - data.toQueue, - self:FormatMoney(data.profit) - )) - self:AddToQueue(data.SkillID, data.Index, data.toQueue) - numAdded = numAdded +1 - end - self:Print(format("%d items checked", numChecked)) - self:Print(format("%d queued", numAdded)) + ItemAuditor:UpdateCraftingTable() + Crafting.Export(Export) end function ItemAuditor:GetReagentCost(link, total)