Mercurial > wow > itemauditor
comparison Modules/QuickAuctions.lua @ 19:67f4151d535c
Expanded the queue system to calculate what the new QA threshold would be and to consider buying items from vendors. It also sets a threshold so that items with less than 5g profit will not be crafted. I will turn this into an option later.
| author | Asa Ayers <Asa.Ayers@Gmail.com> |
|---|---|
| date | Sun, 04 Jul 2010 07:24:12 -0700 |
| parents | c7b3585c73df |
| children | ff9a698caebc |
comparison
equal
deleted
inserted
replaced
| 18:c7b3585c73df | 19:67f4151d535c |
|---|---|
| 33 _, link= GetItemInfo(link) | 33 _, link= GetItemInfo(link) |
| 34 | 34 |
| 35 self:UpdateQAGroup(QAAPI:GetItemGroup(link)) | 35 self:UpdateQAGroup(QAAPI:GetItemGroup(link)) |
| 36 end | 36 end |
| 37 | 37 |
| 38 addon.profit_margin = 1.15 | |
| 39 addon.minimum_profit = 50000 | |
| 40 | |
| 41 local function calculateQAThreshold(copper) | |
| 42 if copper == 0 then | |
| 43 copper = 1 | |
| 44 end | |
| 45 | |
| 46 -- add my minimum profit margin | |
| 47 copper = copper * addon.profit_margin | |
| 48 | |
| 49 -- Adding the cost of mailing every item once. | |
| 50 copper = copper + 30 | |
| 51 | |
| 52 -- add AH Cut | |
| 53 local keep = 1 - addon:GetAHCut() | |
| 54 return copper/keep | |
| 55 end | |
| 56 | |
| 38 function addon:UpdateQAGroup(groupName) | 57 function addon:UpdateQAGroup(groupName) |
| 39 if not addon.IsQAEnabled() then | 58 if not addon.IsQAEnabled() then |
| 40 return | 59 return |
| 41 end | 60 end |
| 42 if groupName then | 61 if groupName then |
| 46 local _, itemCost= ItemAuditor:GetItemCost(link, 0) | 65 local _, itemCost= ItemAuditor:GetItemCost(link, 0) |
| 47 | 66 |
| 48 threshold = max(threshold, itemCost) | 67 threshold = max(threshold, itemCost) |
| 49 end | 68 end |
| 50 | 69 |
| 51 if threshold == 0 then | 70 threshold = calculateQAThreshold(threshold) |
| 52 threshold = 1 | |
| 53 end | |
| 54 | |
| 55 -- add my minimum profit margin | |
| 56 threshold = threshold * 1.10 | |
| 57 | |
| 58 -- Adding the cost of mailing every item once. | |
| 59 threshold = threshold + 30 | |
| 60 | |
| 61 -- add AH Cut | |
| 62 local keep = 1 - addon:GetAHCut() | |
| 63 threshold = threshold/keep | |
| 64 | 71 |
| 65 QAAPI:SetGroupThreshold(groupName, ceil(threshold)) | 72 QAAPI:SetGroupThreshold(groupName, ceil(threshold)) |
| 66 end | 73 end |
| 67 end | 74 end |
| 68 | 75 |
| 90 itemId = LSW.scrollData[itemId]["scrollID"] | 97 itemId = LSW.scrollData[itemId]["scrollID"] |
| 91 end | 98 end |
| 92 | 99 |
| 93 local skillName, skillType, numAvailable, isExpanded, altVerb = GetTradeSkillInfo(i) | 100 local skillName, skillType, numAvailable, isExpanded, altVerb = GetTradeSkillInfo(i) |
| 94 local recipeLink = GetTradeSkillRecipeLink(i) | 101 local recipeLink = GetTradeSkillRecipeLink(i) |
| 95 local stackSize = 0 | 102 local stackSize = 1 |
| 96 if recipeLink ~= nil then | 103 if recipeLink ~= nil then |
| 97 _, itemLink= GetItemInfo(itemId) | 104 _, itemLink= GetItemInfo(itemId) |
| 98 local QAGroup = QAAPI:GetItemGroup(itemLink) | 105 local QAGroup = QAAPI:GetItemGroup(itemLink) |
| 99 if QAGroup ~= nil then | 106 if QAGroup ~= nil then |
| 100 stackSize = QAAPI:GetGroupPostCap(QAGroup) * QAAPI:GetGroupPerAuction(QAGroup) | 107 stackSize = QAAPI:GetGroupPostCap(QAGroup) * QAAPI:GetGroupPerAuction(QAGroup) |
| 101 stackSize = stackSize / GetTradeSkillNumMade(i) | 108 stackSize = stackSize / GetTradeSkillNumMade(i) |
| 109 | |
| 110 -- bonus | |
| 111 stackSize = ceil(stackSize *1.25) | |
| 102 end | 112 end |
| 103 | 113 |
| 104 local count = Altoholic:GetItemCount(itemId) | 114 local count = Altoholic:GetItemCount(itemId) |
| 105 | 115 |
| 106 if count < stackSize then | 116 if count < stackSize and itemLink ~= nil then |
| 107 local found, _, skillString = string.find(recipeLink, "^|%x+|H(.+)|h%[.+%]") | 117 local found, _, skillString = string.find(recipeLink, "^|%x+|H(.+)|h%[.+%]") |
| 108 local _, skillId = strsplit(":", skillString ) | 118 local _, skillId = strsplit(":", skillString ) |
| 109 | 119 |
| 110 | 120 local toQueue = stackSize - count |
| 111 local totalCost = 0 | 121 local newCost = 0 |
| 112 for reagentId = 1, GetTradeSkillNumReagents(i) do | 122 for reagentId = 1, GetTradeSkillNumReagents(i) do |
| 113 _, _, reagentCount = GetTradeSkillReagentInfo(i, reagentId); | 123 _, _, reagentCount = GetTradeSkillReagentInfo(i, reagentId); |
| 114 reagentLink = GetTradeSkillReagentItemLink(i, reagentId) | 124 reagentLink = GetTradeSkillReagentItemLink(i, reagentId) |
| 115 | 125 newCost = newCost + addon:GetReagentCost(reagentLink, reagentCount) |
| 116 totalCost = totalCost + addon:GetReagentCost(reagentLink, reagentCount) | |
| 117 end | 126 end |
| 118 | 127 |
| 128 local currentInvested, _, currentCount = addon:GetItemCost(itemLink) | |
| 129 local newThreshold = (newCost + currentInvested) / (currentCount + toQueue) | |
| 130 | |
| 131 | |
| 132 newThreshold = calculateQAThreshold(newThreshold) | |
| 119 local currentPrice = GetAuctionBuyout(itemLink) or 0 | 133 local currentPrice = GetAuctionBuyout(itemLink) or 0 |
| 120 | 134 |
| 121 local toQueue = stackSize - count | 135 |
| 122 -- bonus? | 136 -- bonus? |
| 123 | 137 |
| 124 if totalCost < currentPrice then | 138 if newThreshold < currentPrice and (currentPrice - newThreshold) > addon.minimum_profit then |
| 125 self:Debug(format("Adding %s x%s to skillet queue.", itemLink, toQueue)) | 139 self:Debug(format("Adding %s x%s to skillet queue. Profit: %s", |
| 140 itemLink, | |
| 141 toQueue, | |
| 142 addon:FormatMoney(currentPrice - newThreshold) | |
| 143 )) | |
| 126 self:AddToQueue(skillId,i, toQueue) | 144 self:AddToQueue(skillId,i, toQueue) |
| 127 else | 145 else |
| 128 self:Debug(format("Skipping %s. Would cost %s to craft and sell for %s", itemLink, addon:FormatMoney(totalCost), addon:FormatMoney(currentPrice))) | 146 self:Debug(format("Skipping %s x%s. Would lose %s ", itemLink, toQueue, addon:FormatMoney(currentPrice - newThreshold))) |
| 129 end | 147 end |
| 130 end | 148 end |
| 131 end | 149 end |
| 132 end | 150 end |
| 133 | 151 |
| 134 | 152 |
| 135 end | 153 end |
| 136 | 154 |
| 137 function addon:GetReagentCost(link, total) | 155 function addon:GetReagentCost(link, total) |
| 138 local totalCost = 0 | 156 local totalCost = 0 |
| 157 | |
| 158 if Skillet:VendorSellsReagent(link) then | |
| 159 local _, _, _, _, _, _, _, _, _, _, itemVendorPrice = GetItemInfo (link); | |
| 160 totalCost = itemVendorPrice * total | |
| 161 total = 0 | |
| 162 end | |
| 163 | |
| 164 | |
| 139 local investedTotal, investedPerItem, count = addon:GetItemCost(link) | 165 local investedTotal, investedPerItem, count = addon:GetItemCost(link) |
| 140 | 166 |
| 141 if count > 0 then | 167 if count > 0 then |
| 142 if total <= count then | 168 if total <= count then |
| 143 totalCost = investedPerItem * total | 169 totalCost = investedPerItem * total |
