Mercurial > wow > itemauditor
changeset 20:ff9a698caebc
Added options for the crafting threshold and auction threshold. I also fixed the queue to use the item cost to determine if there is enough profit instead of the auction (QA) threshold which already has profit built in.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Sun, 04 Jul 2010 09:33:25 -0700 |
parents | 67f4151d535c |
children | d7f02c84994c |
files | Core.lua Modules/Events.lua Modules/Options.lua Modules/QuickAuctions.lua Modules/Utils.lua |
diffstat | 5 files changed, 91 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/Core.lua Sun Jul 04 07:24:12 2010 -0700 +++ b/Core.lua Sun Jul 04 09:33:25 2010 -0700 @@ -19,11 +19,14 @@ char = { ah = 1, use_quick_auctions = false, + crafting_threshold = 1, + auction_threshold = 0.15, }, profile = { messages = { debug = false, cost_updates = true, + queue_skip = false, } }, factionrealm = {
--- a/Modules/Events.lua Sun Jul 04 07:24:12 2010 -0700 +++ b/Modules/Events.lua Sun Jul 04 09:33:25 2010 -0700 @@ -100,7 +100,7 @@ if diff.money > 0 and self:tcount(positive) > 0 and self:tcount(negative) == 0 then self:Debug("loot") - elseif self:tcount(diff.items) == 1 then + elseif abs(diff.money) > 0 and self:tcount(diff.items) == 1 then self:Debug("purchase or sale") for link, count in pairs(diff.items) do
--- a/Modules/Options.lua Sun Jul 04 07:24:12 2010 -0700 +++ b/Modules/Options.lua Sun Jul 04 09:33:25 2010 -0700 @@ -6,6 +6,14 @@ local currentFaction = UnitFactionGroup("player") local AHFactions = { currentFaction, 'Neutral' } +local craftingThresholds = {5000, 10000, 50000} +local craftingThresholdsDisplay = {} + +for key, value in pairs(craftingThresholds) do + craftingThresholdsDisplay[key] = addon:FormatMoney(value, '', true) + -- craftingThresholdsDisplay[key] = value +end + local options = { handler = addon, name = "ItemAuditor", @@ -33,6 +41,24 @@ desc = "Control which messages display in your chat window.", type = 'group', args = { + + item_cost = { + type = "toggle", + name = "Item Cost", + desc = "Shows a message every time an item's cost changes", + get = function() return ItemAuditor.db.profile.messages.cost_updates end, + set = function(info, value) ItemAuditor.db.profile.messages.cost_updates = value end, + order = 0, + }, + queue_skip = { + type = "toggle", + name = "Queue Skip", + desc = "Displays a message when an item is excluded from the queue.", + get = function() return ItemAuditor.db.profile.messages.queue_skip end, + set = function(info, value) ItemAuditor.db.profile.messages.queue_skip = value end, + disabled = 'IsQADisabled', + order = 1, + }, dbg = { type = "toggle", name = "Debug", @@ -41,14 +67,6 @@ set = "SetDebug", order = 100, }, - item_cost = { - type = "toggle", - name = "Item Cost", - desc = "Shows a message every time an item's cost changes", - get = function() return ItemAuditor.db.profile.messages.cost_updates end, - set = function(info, value) ItemAuditor.db.profile.messages.cost_updates = value end, - order = 0, - }, }, }, @@ -76,13 +94,44 @@ order = 1, }, ]] + auction_threshold = { + type = "range", + name = "Auction Threshold", + desc = "Don't create items that will make less than this amount of profit", + min = 0.0, + max = 1.0, + isPercent = true, + get = function() return ItemAuditor.db.char.auction_threshold end, + set = function(info, value) ItemAuditor.db.char.auction_threshold = value end, + disabled = 'IsQADisabled', + order = 1, + }, refresh_qa = { type = "execute", name = "Refresh QA Thresholds", desc = "Resets all Quick Auctions thresholds", func = "RefreshQAGroups", disabled = 'IsQADisabled', + order = 9, }, + + queue_header = { + type = "header", + name = "Skillet Queue Options", + order = 10, + }, + + crafting_threshold = { + type = "select", + name = "Crafting Threshold", + desc = "Don't create items that will make less than this amount of profit", + values = craftingThresholdsDisplay, + get = function() return ItemAuditor.db.char.crafting_threshold end, + set = function(info, value) ItemAuditor.db.char.crafting_threshold = value end, + disabled = 'IsQADisabled', + order = 11, + }, + } }, options = { @@ -123,6 +172,15 @@ return iter end +function addon:GetCraftingThreshold() + local key = ItemAuditor.db.char.crafting_threshold + return craftingThresholds[key] +end + +function addon:GetAuctionThreshold() + return ItemAuditor.db.char.auction_threshold +end + function addon:GetAH() return ItemAuditor.db.char.ah end
--- a/Modules/QuickAuctions.lua Sun Jul 04 07:24:12 2010 -0700 +++ b/Modules/QuickAuctions.lua Sun Jul 04 09:33:25 2010 -0700 @@ -36,7 +36,6 @@ end addon.profit_margin = 1.15 -addon.minimum_profit = 50000 local function calculateQAThreshold(copper) if copper == 0 then @@ -44,7 +43,8 @@ end -- add my minimum profit margin - copper = copper * addon.profit_margin + -- GetAuctionThreshold returns a percent as a whole number. This will convert 25 to 1.25 + copper = copper * (1+addon:GetAuctionThreshold()) -- Adding the cost of mailing every item once. copper = copper + 30 @@ -85,6 +85,8 @@ self:Print("This feature requires LilSparky's Workshop.") return end + self:Debug(format("Auction Threshold: %d%%", self:GetAuctionThreshold()*100 )) + self:Debug(format("Crafting Threshold: %s", self:FormatMoney(self:GetCraftingThreshold()))) for i = 1, GetNumTradeSkills() do local itemLink = GetTradeSkillItemLink(i) @@ -135,15 +137,15 @@ -- bonus? - if newThreshold < currentPrice and (currentPrice - newThreshold) > addon.minimum_profit then + if newThreshold < currentPrice and (currentPrice - newCost) > self:GetCraftingThreshold() then self:Debug(format("Adding %s x%s to skillet queue. Profit: %s", itemLink, toQueue, addon:FormatMoney(currentPrice - newThreshold) )) self:AddToQueue(skillId,i, toQueue) - else - self:Debug(format("Skipping %s x%s. Would lose %s ", itemLink, toQueue, addon:FormatMoney(currentPrice - newThreshold))) + elseif ItemAuditor.db.profile.messages.queue_skip then + self:Debug(format("Skipping %s x%s. Profit: %s ", itemLink, toQueue, addon:FormatMoney(currentPrice - newCost))) end end end
--- a/Modules/Utils.lua Sun Jul 04 07:24:12 2010 -0700 +++ b/Modules/Utils.lua Sun Jul 04 09:33:25 2010 -0700 @@ -4,13 +4,22 @@ addonTable.utils = addon IAUtils = addon -function addon:FormatMoney(copper) - color = "|cFFFFFFFF" +function addon:FormatMoney(copper, color, textOnly) + color = color or "|cFFFFFFFF" local prefix = "" if copper < 0 then prefix = "-" copper = abs(copper) end + + local copperTexture = COPPER_AMOUNT_TEXTURE + local silverTexture = SILVER_AMOUNT_TEXTURE + local goldTexture = GOLD_AMOUNT_TEXTURE + if textOnly then + copperTexture = '%dc' + silverTexture = '%ds' + goldTexture = '%dg' + end local gold = floor( copper / 10000 ); copper = mod(copper, 10000) @@ -18,14 +27,14 @@ copper = mod(copper, 100) - copper = color..format(COPPER_AMOUNT_TEXTURE, copper, 13, 13) + copper = color .. format(copperTexture, copper, 13, 13) if silver > 0 or gold > 0 then - silver = color..format(SILVER_AMOUNT_TEXTURE, silver, 13, 13) .. ' ' + silver = color.. format(silverTexture, silver, 13, 13) .. ' ' else silver = "" end if gold > 0 then - gold = color..format(GOLD_AMOUNT_TEXTURE, gold, 13, 13) .. ' ' + gold = color.. format(goldTexture, gold, 13, 13) .. ' ' else gold = "" end