Mercurial > wow > itemauditor
comparison Modules/QuickAuctions.lua @ 18:c7b3585c73df
Added the missing QuickAuctions module. I've also added integration with Skillet and LilSparkysWorkshop. IA and queue any item set up in QuickAuctions where the reagent cost is less than the current price of the item. This is based on KevTool Queue.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Sat, 03 Jul 2010 14:53:27 -0700 |
parents | |
children | 67f4151d535c |
comparison
equal
deleted
inserted
replaced
17:e62d878c716d | 18:c7b3585c73df |
---|---|
1 local addonName, addonTable = ...; | |
2 local addon = _G[addonName] | |
3 | |
4 function addon:IsQACompatible() | |
5 return (QAAPI ~= nil and QAAPI.GetGroups ~= nil) | |
6 end | |
7 | |
8 function addon:IsQAEnabled() | |
9 return addon:IsQACompatible() and ItemAuditor.db.char.use_quick_auctions | |
10 end | |
11 | |
12 function addon:IsQADisabled() | |
13 return not self:IsQAEnabled() | |
14 end | |
15 | |
16 function addon:SetQAEnabled(info, value) | |
17 ItemAuditor.db.char.use_quick_auctions = value | |
18 end | |
19 | |
20 function addon:RefreshQAGroups() | |
21 if not addon.IsQAEnabled() then | |
22 return | |
23 end | |
24 for groupName in pairs(QAAPI:GetGroups()) do | |
25 self:UpdateQAGroup(groupName) | |
26 end | |
27 end | |
28 | |
29 function addon:UpdateQAThreshold(link) | |
30 if not addon.IsQAEnabled() then | |
31 return | |
32 end | |
33 _, link= GetItemInfo(link) | |
34 | |
35 self:UpdateQAGroup(QAAPI:GetItemGroup(link)) | |
36 end | |
37 | |
38 function addon:UpdateQAGroup(groupName) | |
39 if not addon.IsQAEnabled() then | |
40 return | |
41 end | |
42 if groupName then | |
43 local threshold = 0 | |
44 | |
45 for link in pairs(QAAPI:GetItemsInGroup(groupName)) do | |
46 local _, itemCost= ItemAuditor:GetItemCost(link, 0) | |
47 | |
48 threshold = max(threshold, itemCost) | |
49 end | |
50 | |
51 if threshold == 0 then | |
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 | |
65 QAAPI:SetGroupThreshold(groupName, ceil(threshold)) | |
66 end | |
67 end | |
68 | |
69 --[[ | |
70 This is based on KTQ | |
71 ]] | |
72 function addon:Queue() | |
73 if not addon.IsQAEnabled() then | |
74 self:Debug("Refusing to run :Queue() QA is disabled") | |
75 return | |
76 end | |
77 if LSW == nil then | |
78 self:Print("This feature requires LilSparky's Workshop.") | |
79 return | |
80 end | |
81 | |
82 for i = 1, GetNumTradeSkills() do | |
83 local itemLink = GetTradeSkillItemLink(i) | |
84 local itemId = Skillet:GetItemIDFromLink(itemLink) | |
85 | |
86 --Figure out if its an enchant or not | |
87 _, _, _, _, altVerb = GetTradeSkillInfo(i) | |
88 if LSW.scrollData[itemId] ~= nil and altVerb == 'Enchant' then | |
89 -- Ask LSW for the correct scroll | |
90 itemId = LSW.scrollData[itemId]["scrollID"] | |
91 end | |
92 | |
93 local skillName, skillType, numAvailable, isExpanded, altVerb = GetTradeSkillInfo(i) | |
94 local recipeLink = GetTradeSkillRecipeLink(i) | |
95 local stackSize = 0 | |
96 if recipeLink ~= nil then | |
97 _, itemLink= GetItemInfo(itemId) | |
98 local QAGroup = QAAPI:GetItemGroup(itemLink) | |
99 if QAGroup ~= nil then | |
100 stackSize = QAAPI:GetGroupPostCap(QAGroup) * QAAPI:GetGroupPerAuction(QAGroup) | |
101 stackSize = stackSize / GetTradeSkillNumMade(i) | |
102 end | |
103 | |
104 local count = Altoholic:GetItemCount(itemId) | |
105 | |
106 if count < stackSize then | |
107 local found, _, skillString = string.find(recipeLink, "^|%x+|H(.+)|h%[.+%]") | |
108 local _, skillId = strsplit(":", skillString ) | |
109 | |
110 | |
111 local totalCost = 0 | |
112 for reagentId = 1, GetTradeSkillNumReagents(i) do | |
113 _, _, reagentCount = GetTradeSkillReagentInfo(i, reagentId); | |
114 reagentLink = GetTradeSkillReagentItemLink(i, reagentId) | |
115 | |
116 totalCost = totalCost + addon:GetReagentCost(reagentLink, reagentCount) | |
117 end | |
118 | |
119 local currentPrice = GetAuctionBuyout(itemLink) or 0 | |
120 | |
121 local toQueue = stackSize - count | |
122 -- bonus? | |
123 | |
124 if totalCost < currentPrice then | |
125 self:Debug(format("Adding %s x%s to skillet queue.", itemLink, toQueue)) | |
126 self:AddToQueue(skillId,i, toQueue) | |
127 else | |
128 self:Debug(format("Skipping %s. Would cost %s to craft and sell for %s", itemLink, addon:FormatMoney(totalCost), addon:FormatMoney(currentPrice))) | |
129 end | |
130 end | |
131 end | |
132 end | |
133 | |
134 | |
135 end | |
136 | |
137 function addon:GetReagentCost(link, total) | |
138 local totalCost = 0 | |
139 local investedTotal, investedPerItem, count = addon:GetItemCost(link) | |
140 | |
141 if count > 0 then | |
142 if total <= count then | |
143 totalCost = investedPerItem * total | |
144 total = 0 | |
145 else | |
146 totalCost = investedTotal | |
147 total = total - count | |
148 end | |
149 end | |
150 | |
151 -- If there is none on the auction house, this uses a large enough number | |
152 -- to prevent us from trying to make the item. | |
153 local ahPrice = (GetAuctionBuyout(link) or 99990000) | |
154 | |
155 return totalCost + (ahPrice * total) | |
156 end | |
157 | |
158 function addon:AddToQueue(skillId,skillIndex, toQueue) | |
159 if Skillet == nil then | |
160 self:Print("Skillet not loaded") | |
161 end | |
162 if Skillet.QueueCommandIterate ~= nil then | |
163 local queueCommand = Skillet:QueueCommandIterate(tonumber(skillId), toQueue) | |
164 Skillet:AddToQueue(queueCommand) | |
165 else | |
166 Skillet.stitch:AddToQueue(skillIndex, toQueue) | |
167 end | |
168 end |