Mercurial > wow > itemauditor
comparison Modules/QuickAuctions.lua @ 62:70dc84df13b3
Updated the QuickAuctions API to use the new API calls. This commit also includes a compatibility layer to maintain backward compatibility so that none of my users have to upgrade QuickAuctions twice before getting any new features.
| author | Asa Ayers <Asa.Ayers@Gmail.com> |
|---|---|
| date | Tue, 27 Jul 2010 17:52:21 -0700 |
| parents | 4ec321eb0dfe |
| children | e7d287cc3b02 |
comparison
equal
deleted
inserted
replaced
| 61:b24dbfbe2aef | 62:70dc84df13b3 |
|---|---|
| 1 local addonName, addonTable = ...; | 1 local addonName, addonTable = ...; |
| 2 local addon = _G[addonName] | 2 local addon = _G[addonName] |
| 3 | 3 |
| 4 --[[ | |
| 5 This is simply for compatibility while I change the QA API. Once | |
| 6 my changes get merged into the main project, this can go away. | |
| 7 ]] | |
| 8 if QAAPI ~= nil and QAAPI.GetGroupThreshold ~= nil and QAAPI.GetGroupConfig == nil then | |
| 9 function QAAPI:GetGroupConfig(groupName) | |
| 10 return QAAPI:GetGroupThreshold(groupName), | |
| 11 QAAPI:GetGroupPostCap(groupName), | |
| 12 QAAPI:GetGroupPerAuction(groupName) | |
| 13 end | |
| 14 | |
| 15 function QAAPI:SetGroupConfig(groupName, key, value) | |
| 16 if key == 'threshold' then | |
| 17 return QAAPI:SetGroupThreshold(groupName, value) | |
| 18 end | |
| 19 end | |
| 20 end | |
| 21 | |
| 22 | |
| 23 | |
| 4 function addon:IsQACompatible() | 24 function addon:IsQACompatible() |
| 5 return (QAAPI ~= nil and QAAPI.GetGroups ~= nil) | 25 return (QAAPI ~= nil and QAAPI.GetGroupConfig ~= nil) |
| 6 end | 26 end |
| 7 | 27 |
| 8 function addon:IsQAEnabled() | 28 function addon:IsQAEnabled() |
| 9 return addon:IsQACompatible() and ItemAuditor.db.char.use_quick_auctions | 29 return addon:IsQACompatible() and ItemAuditor.db.char.use_quick_auctions |
| 10 end | 30 end |
| 64 threshold = max(threshold, itemCost) | 84 threshold = max(threshold, itemCost) |
| 65 end | 85 end |
| 66 | 86 |
| 67 threshold = calculateQAThreshold(threshold) | 87 threshold = calculateQAThreshold(threshold) |
| 68 | 88 |
| 69 QAAPI:SetGroupThreshold(groupName, ceil(threshold)) | 89 QAAPI:SetGroupConfig(groupName, 'threshold', ceil(threshold)) |
| 70 end | 90 end |
| 71 end | 91 end |
| 72 | 92 |
| 73 local function isProfitable(data) | 93 local function isProfitable(data) |
| 74 if addon.IsQAEnabled() then | 94 if addon.IsQAEnabled() then |
| 75 local QAGroup = QAAPI:GetItemGroup(data.link) | 95 local QAGroup = QAAPI:GetItemGroup(data.link) |
| 76 if QAGroup ~= nil then | 96 if QAGroup ~= nil then |
| 77 local currentInvested, _, currentCount = addon:GetItemCost(data.link) | 97 local currentInvested, _, currentCount = addon:GetItemCost(data.link) |
| 78 | 98 local threshold, postCap, perAuction = QAAPI:GetGroupConfig(QAGroup) |
| 79 local stackSize = QAAPI:GetGroupPostCap(QAGroup) * QAAPI:GetGroupPerAuction(QAGroup) | 99 local stackSize = postCap * perAuction |
| 100 | |
| 80 stackSize = stackSize / GetTradeSkillNumMade(data.tradeSkillIndex) | 101 stackSize = stackSize / GetTradeSkillNumMade(data.tradeSkillIndex) |
| 81 | 102 |
| 82 -- bonus | 103 -- bonus |
| 83 stackSize = ceil(stackSize *1.25) | 104 stackSize = ceil(stackSize *1.25) |
| 84 | 105 |
| 145 -- if QA isn't enabled, this will just return nil | 166 -- if QA isn't enabled, this will just return nil |
| 146 local QAGroup = nil | 167 local QAGroup = nil |
| 147 if addon.IsQAEnabled() then | 168 if addon.IsQAEnabled() then |
| 148 QAGroup = QAAPI:GetItemGroup(itemLink) | 169 QAGroup = QAAPI:GetItemGroup(itemLink) |
| 149 if QAGroup ~= nil then | 170 if QAGroup ~= nil then |
| 150 stackSize = QAAPI:GetGroupPostCap(QAGroup) * QAAPI:GetGroupPerAuction(QAGroup) | 171 local threshold, postCap, perAuction = QAAPI:GetGroupConfig(QAGroup) |
| 172 stackSize = postCap * perAuction | |
| 151 stackSize = stackSize / GetTradeSkillNumMade(i) | 173 stackSize = stackSize / GetTradeSkillNumMade(i) |
| 152 | 174 |
| 153 -- bonus | 175 -- bonus |
| 154 stackSize = ceil(stackSize *1.25) | 176 stackSize = ceil(stackSize *1.25) |
| 155 end | 177 end |
