Mercurial > wow > itemauditor
comparison Modules/QuickAuctions.lua @ 21:d7f02c84994c
Changed QA to be an option part of /ia queue. If QA is there, IA will queue enough of an item to be created to have 1.25x QA auctino count x QA stack size (rounded up) items. If it is not there, it will create 1 on every profitable item. This commit also adds support for Auctioneer.
| author | Asa Ayers <Asa.Ayers@Gmail.com> |
|---|---|
| date | Tue, 06 Jul 2010 23:48:54 -0700 |
| parents | ff9a698caebc |
| children | 819bfdc5d73c |
comparison
equal
deleted
inserted
replaced
| 20:ff9a698caebc | 21:d7f02c84994c |
|---|---|
| 75 | 75 |
| 76 --[[ | 76 --[[ |
| 77 This is based on KTQ | 77 This is based on KTQ |
| 78 ]] | 78 ]] |
| 79 function addon:Queue() | 79 function addon:Queue() |
| 80 if not addon.IsQAEnabled() then | |
| 81 self:Debug("Refusing to run :Queue() QA is disabled") | |
| 82 return | |
| 83 end | |
| 84 if LSW == nil then | 80 if LSW == nil then |
| 85 self:Print("This feature requires LilSparky's Workshop.") | 81 self:Print("This feature requires LilSparky's Workshop.") |
| 86 return | 82 return |
| 87 end | 83 end |
| 88 self:Debug(format("Auction Threshold: %d%%", self:GetAuctionThreshold()*100 )) | 84 if Skillet == nil then |
| 85 self:Print("This feature requires Skillet.") | |
| 86 return | |
| 87 end | |
| 88 if GetAuctionBuyout ~= nil then | |
| 89 elseif AucAdvanced and AucAdvanced.Version then | |
| 90 else | |
| 91 self:Print("This feature requires Auctionator, Auctioneer, AuctionLite, or AuctionMaster.") | |
| 92 return | |
| 93 end | |
| 94 | |
| 95 | |
| 96 if addon.IsQAEnabled() then | |
| 97 self:Debug(format("Auction Threshold: %d%%", self:GetAuctionThreshold()*100 )) | |
| 98 end | |
| 89 self:Debug(format("Crafting Threshold: %s", self:FormatMoney(self:GetCraftingThreshold()))) | 99 self:Debug(format("Crafting Threshold: %s", self:FormatMoney(self:GetCraftingThreshold()))) |
| 100 local profitableItems = {} | |
| 101 local profitableIndex = 1 | |
| 102 local numChecked = 0 | |
| 90 | 103 |
| 91 for i = 1, GetNumTradeSkills() do | 104 for i = 1, GetNumTradeSkills() do |
| 92 local itemLink = GetTradeSkillItemLink(i) | 105 local itemLink = GetTradeSkillItemLink(i) |
| 93 local itemId = Skillet:GetItemIDFromLink(itemLink) | 106 local itemId = Skillet:GetItemIDFromLink(itemLink) |
| 94 | 107 |
| 102 local skillName, skillType, numAvailable, isExpanded, altVerb = GetTradeSkillInfo(i) | 115 local skillName, skillType, numAvailable, isExpanded, altVerb = GetTradeSkillInfo(i) |
| 103 local recipeLink = GetTradeSkillRecipeLink(i) | 116 local recipeLink = GetTradeSkillRecipeLink(i) |
| 104 local stackSize = 1 | 117 local stackSize = 1 |
| 105 if recipeLink ~= nil then | 118 if recipeLink ~= nil then |
| 106 _, itemLink= GetItemInfo(itemId) | 119 _, itemLink= GetItemInfo(itemId) |
| 107 local QAGroup = QAAPI:GetItemGroup(itemLink) | 120 |
| 108 if QAGroup ~= nil then | 121 |
| 109 stackSize = QAAPI:GetGroupPostCap(QAGroup) * QAAPI:GetGroupPerAuction(QAGroup) | 122 -- if QA isn't enabled, this will just return nil |
| 110 stackSize = stackSize / GetTradeSkillNumMade(i) | 123 local QAGroup = nil |
| 111 | 124 if addon.IsQAEnabled() then |
| 112 -- bonus | 125 QAGroup = QAAPI:GetItemGroup(itemLink) |
| 113 stackSize = ceil(stackSize *1.25) | 126 if QAGroup ~= nil then |
| 127 stackSize = QAAPI:GetGroupPostCap(QAGroup) * QAAPI:GetGroupPerAuction(QAGroup) | |
| 128 stackSize = stackSize / GetTradeSkillNumMade(i) | |
| 129 | |
| 130 -- bonus | |
| 131 stackSize = ceil(stackSize *1.25) | |
| 132 end | |
| 114 end | 133 end |
| 115 | 134 |
| 116 local count = Altoholic:GetItemCount(itemId) | 135 local count = Altoholic:GetItemCount(itemId) |
| 117 | 136 |
| 118 if count < stackSize and itemLink ~= nil then | 137 if count < stackSize and itemLink ~= nil then |
| 119 local found, _, skillString = string.find(recipeLink, "^|%x+|H(.+)|h%[.+%]") | 138 local found, _, skillString = string.find(recipeLink, "^|%x+|H(.+)|h%[.+%]") |
| 120 local _, skillId = strsplit(":", skillString ) | 139 local _, skillId = strsplit(":", skillString ) |
| 128 end | 147 end |
| 129 | 148 |
| 130 local currentInvested, _, currentCount = addon:GetItemCost(itemLink) | 149 local currentInvested, _, currentCount = addon:GetItemCost(itemLink) |
| 131 local newThreshold = (newCost + currentInvested) / (currentCount + toQueue) | 150 local newThreshold = (newCost + currentInvested) / (currentCount + toQueue) |
| 132 | 151 |
| 133 | 152 if addon.IsQAEnabled() then |
| 134 newThreshold = calculateQAThreshold(newThreshold) | 153 newThreshold = calculateQAThreshold(newThreshold) |
| 135 local currentPrice = GetAuctionBuyout(itemLink) or 0 | 154 else |
| 136 | 155 -- if quick auctions isn't enabled, this will cause the decision to rely |
| 137 | 156 -- completly on the crafting threshold |
| 138 -- bonus? | 157 newThreshold = 0 |
| 158 end | |
| 159 local currentPrice = addon:GetAuctionPrice(itemLink) or 0 | |
| 160 numChecked = numChecked + 1 | |
| 139 | 161 |
| 140 if newThreshold < currentPrice and (currentPrice - newCost) > self:GetCraftingThreshold() then | 162 if newThreshold < currentPrice and (currentPrice - newCost) > self:GetCraftingThreshold() then |
| 141 self:Debug(format("Adding %s x%s to skillet queue. Profit: %s", | 163 |
| 142 itemLink, | 164 profitableItems[profitableIndex] = { |
| 143 toQueue, | 165 itemLink = itemLink, |
| 144 addon:FormatMoney(currentPrice - newThreshold) | 166 SkillID = skillId, |
| 145 )) | 167 Index = i, |
| 146 self:AddToQueue(skillId,i, toQueue) | 168 toQueue = toQueue, |
| 169 profit = (currentPrice - newCost) * toQueue | |
| 170 } | |
| 171 profitableIndex = profitableIndex + 1 | |
| 147 elseif ItemAuditor.db.profile.messages.queue_skip then | 172 elseif ItemAuditor.db.profile.messages.queue_skip then |
| 148 self:Debug(format("Skipping %s x%s. Profit: %s ", itemLink, toQueue, addon:FormatMoney(currentPrice - newCost))) | 173 self:Print(format("Skipping %s x%s. Profit: %s ", itemLink, toQueue, addon:FormatMoney(currentPrice - newCost))) |
| 149 end | 174 end |
| 150 end | 175 end |
| 151 end | 176 end |
| 152 end | 177 end |
| 153 | 178 local numAdded = 0 |
| 154 | 179 table.sort(profitableItems, function(a, b) return a.profit > b.profit end) |
| 180 for key, data in pairs(profitableItems) do | |
| 181 self:Print(format("Adding %s x%s to skillet queue. Profit: %s", | |
| 182 data.itemLink, | |
| 183 data.toQueue, | |
| 184 self:FormatMoney(data.profit) | |
| 185 )) | |
| 186 self:AddToQueue(data.SkillID, data.Index, data.toQueue) | |
| 187 numAdded = numAdded +1 | |
| 188 end | |
| 189 self:Print(format("%d items checked", numChecked)) | |
| 190 self:Print(format("%d queued", numAdded)) | |
| 155 end | 191 end |
| 156 | 192 |
| 157 function addon:GetReagentCost(link, total) | 193 function addon:GetReagentCost(link, total) |
| 158 local totalCost = 0 | 194 local totalCost = 0 |
| 159 | 195 |
| 176 end | 212 end |
| 177 end | 213 end |
| 178 | 214 |
| 179 -- If there is none on the auction house, this uses a large enough number | 215 -- If there is none on the auction house, this uses a large enough number |
| 180 -- to prevent us from trying to make the item. | 216 -- to prevent us from trying to make the item. |
| 181 local ahPrice = (GetAuctionBuyout(link) or 99990000) | 217 local ahPrice = (self:GetAuctionPrice(link) or 99990000) |
| 218 -- local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, _, _, _, _, itemVendorPrice = GetItemInfo (link); | |
| 182 | 219 |
| 183 return totalCost + (ahPrice * total) | 220 return totalCost + (ahPrice * total) |
| 221 end | |
| 222 | |
| 223 function addon:GetAuctionPrice(itemLink) | |
| 224 if GetAuctionBuyout ~= nil then | |
| 225 return GetAuctionBuyout(itemLink) | |
| 226 elseif AucAdvanced and AucAdvanced.Version then | |
| 227 local _, _, _, _, _, lowBuy= AucAdvanced.Modules.Util.SimpleAuction.Private.GetItems(itemLink) | |
| 228 return lowBuy | |
| 229 end | |
| 230 return nil | |
| 184 end | 231 end |
| 185 | 232 |
| 186 function addon:AddToQueue(skillId,skillIndex, toQueue) | 233 function addon:AddToQueue(skillId,skillIndex, toQueue) |
| 187 if Skillet == nil then | 234 if Skillet == nil then |
| 188 self:Print("Skillet not loaded") | 235 self:Print("Skillet not loaded") |
| 236 return | |
| 189 end | 237 end |
| 190 if Skillet.QueueCommandIterate ~= nil then | 238 if Skillet.QueueCommandIterate ~= nil then |
| 191 local queueCommand = Skillet:QueueCommandIterate(tonumber(skillId), toQueue) | 239 local queueCommand = Skillet:QueueCommandIterate(tonumber(skillId), toQueue) |
| 192 Skillet:AddToQueue(queueCommand) | 240 Skillet:AddToQueue(queueCommand) |
| 193 else | 241 else |
