Mercurial > wow > itemauditor
comparison Core.lua @ 12:6a6296dd249f
Removed dependency on DevTools, completed chaning over the database to use links instead of names, Added integration with my version of QuickAuctions3 (I need to make this optional soon)
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Wed, 30 Jun 2010 22:59:37 -0700 |
parents | c79ede3c7b82 |
children | 8c83d5f6e306 |
comparison
equal
deleted
inserted
replaced
11:03e2d9edc344 | 12:6a6296dd249f |
---|---|
50 self:RemoveItem(link) | 50 self:RemoveItem(link) |
51 end | 51 end |
52 -- addon:UpdateQAThreshold(link) | 52 -- addon:UpdateQAThreshold(link) |
53 end | 53 end |
54 | 54 |
55 self:RefreshQAGroups() | |
56 end | |
57 | |
58 function addon:RefreshQAGroups() | |
55 for groupName in pairs(QAAPI:GetGroups()) do | 59 for groupName in pairs(QAAPI:GetGroups()) do |
56 self:UpdateQAGroup(groupName) | 60 self:UpdateQAGroup(groupName) |
57 end | 61 end |
58 end | 62 end |
59 | 63 |
116 local sender, msgSubject, msgMoney, msgCOD, _, msgItem, _, _, msgText, _, isGM = select(3, GetInboxHeaderInfo(mailIndex)) | 120 local sender, msgSubject, msgMoney, msgCOD, _, msgItem, _, _, msgText, _, isGM = select(3, GetInboxHeaderInfo(mailIndex)) |
117 local mailType = utils:GetMailType(msgSubject) | 121 local mailType = utils:GetMailType(msgSubject) |
118 | 122 |
119 results[mailType] = (results[mailType] or {}) | 123 results[mailType] = (results[mailType] or {}) |
120 | 124 |
121 if mailType == "NonAHMail" and msgCOD > 0 then | 125 if mailType == "NonAHMail" then |
122 --[[ | 126 --[[ |
127 and msgCOD > 0 | |
128 | |
123 mailType = 'COD' | 129 mailType = 'COD' |
124 results[mailType] = (results[mailType] or {}) | 130 results[mailType] = (results[mailType] or {}) |
125 | 131 |
126 local itemTypes = {} | 132 local itemTypes = {} |
127 for itemIndex = 1, ATTACHMENTS_MAX_RECEIVE do | 133 for itemIndex = 1, ATTACHMENTS_MAX_RECEIVE do |
168 end | 174 end |
169 | 175 |
170 local itemName = nil | 176 local itemName = nil |
171 if self:GetSafeLink(link) == nil then | 177 if self:GetSafeLink(link) == nil then |
172 itemName = link | 178 itemName = link |
179 link = self:GetSafeLink(link) | |
173 else | 180 else |
174 link = self:GetSafeLink(link) | 181 link = self:GetSafeLink(link) |
175 itemName = GetItemInfo(link) | 182 itemName = GetItemInfo(link) |
176 end | 183 end |
177 | 184 |
185 | |
178 if self.db.factionrealm.item_account[itemName] ~= nil then | 186 if self.db.factionrealm.item_account[itemName] ~= nil then |
179 self.items[link] = { | 187 self.items[link] = { |
180 count = Altoholic:GetItemCount(utils:GetIDFromLink(link)), | 188 count = Altoholic:GetItemCount(self:GetIDFromLink(link)), |
181 invested = abs(self.db.factionrealm.item_account[itemName] or 0), | 189 invested = abs(self.db.factionrealm.item_account[itemName] or 0), |
182 } | 190 } |
183 self.db.factionrealm.item_account[itemName] = nil | 191 self.db.factionrealm.item_account[itemName] = nil |
184 end | 192 end |
185 | 193 |
209 link = self:GetSafeLink(link) | 217 link = self:GetSafeLink(link) |
210 if link ~= nil then | 218 if link ~= nil then |
211 self.items[link] = nil | 219 self.items[link] = nil |
212 end | 220 end |
213 end | 221 end |
214 --[[ | 222 |
215 ItemAuditor:SaveValue('Scroll of Enchant Weapon - Exceptional Spellpower', 1) | |
216 | |
217 DevTools_Dump(ItemAuditor.db.factionrealm.item_account) | |
218 | |
219 = ItemAuditor:GetItem('Scroll of Enchant Weapon - Exceptional Spellpower', true).invested | |
220 ]] | |
221 function addon:SaveValue(link, value) | 223 function addon:SaveValue(link, value) |
222 local item = nil | 224 local item = nil |
223 local realLink = self:GetSafeLink(link) | 225 local realLink = self:GetSafeLink(link) |
224 local itemName = nil | 226 local itemName = nil |
225 if realLink == nil then | 227 if realLink == nil then |
232 itemName = GetItemInfo(realLink) | 234 itemName = GetItemInfo(realLink) |
233 end | 235 end |
234 | 236 |
235 if abs(value) > 0 then | 237 if abs(value) > 0 then |
236 self:Debug("Updated price of " .. itemName .. " to " .. utils:FormatMoney(item.invested) .. "(change: " .. utils:FormatMoney(value) .. ")") | 238 self:Debug("Updated price of " .. itemName .. " to " .. utils:FormatMoney(item.invested) .. "(change: " .. utils:FormatMoney(value) .. ")") |
237 end | 239 |
238 | 240 if item.invested <= 0 then |
239 if abs(value) > 0 and item.invested <= 0 then | 241 self:Debug("Updated price of " .. itemName .. " to " .. utils:FormatMoney(0)) |
240 self:Debug("Updated price of " .. itemName .. " to " .. utils:FormatMoney(0)) | 242 self:RemoveItem(link) |
241 self:RemoveItem(link) | 243 -- This doesn't work when you mail the only copy of an item you have to another character. |
242 elseif item.count == 0 and ItemAuditor:GetCurrentInventory() > 0 then | 244 --[[ |
243 self:Print("You ran out of " .. itemName .. " and never recovered " .. utils:FormatMoney(item.invested)) | 245 elseif item.count == 0 and realLink and Altoholic:GetItemCount(self:GetIDFromLink(realLink)) then |
244 self:RemoveItem(link) | 246 self:Print("You ran out of " .. itemName .. " and never recovered " .. utils:FormatMoney(item.invested)) |
247 self:RemoveItem(link) | |
248 ]] | |
249 end | |
245 end | 250 end |
246 | 251 |
247 if realLink ~= nil then | 252 if realLink ~= nil then |
248 addon:UpdateQAThreshold(realLink) | 253 addon:UpdateQAThreshold(realLink) |
249 end | 254 end |
250 end | 255 end |
251 --[[ | 256 |
252 | |
253 ItemAuditor:UpdateQAThreshold("item:42646") | |
254 ]] | |
255 function addon:UpdateQAThreshold(link) | 257 function addon:UpdateQAThreshold(link) |
256 _, link= GetItemInfo(link) | 258 _, link= GetItemInfo(link) |
257 | 259 |
258 self:UpdateQAGroup(QAAPI:GetItemGroup(link)) | 260 self:UpdateQAGroup(QAAPI:GetItemGroup(link)) |
259 end | 261 end |
260 | 262 |
261 function addon:UpdateQAGroup(groupName) | 263 function addon:UpdateQAGroup(groupName) |
262 if groupName then | 264 if groupName then |
263 local threshold = 10000 | 265 local threshold = 0 |
264 | 266 |
265 for link in pairs(QAAPI:GetItemsInGroup(groupName)) do | 267 for link in pairs(QAAPI:GetItemsInGroup(groupName)) do |
266 local totalCost, itemCost, itemCount = ItemAuditor:GetItemCost(link, 0) | 268 local _, itemCost= ItemAuditor:GetItemCost(link, 0) |
267 | 269 |
268 if itemCost > threshold then | 270 threshold = max(threshold, itemCost) |
269 threshold = itemCost | 271 end |
270 end | 272 |
271 end | 273 if threshold == 0 then |
274 threshold = 10000 | |
275 end | |
276 | |
277 -- add my minimum profit margin | |
278 threshold = threshold * 1.10 | |
272 | 279 |
273 -- Adding the cost of mailing every item once. | 280 -- Adding the cost of mailing every item once. |
274 threshold = threshold + 30 | 281 threshold = threshold + 30 |
275 | |
276 -- add my minimum profit margin 15% | |
277 threshold = threshold * 1.15 | |
278 | 282 |
279 -- add AH Cut | 283 -- add AH Cut |
280 local keep = 1 - self.db.factionrealm.AHCut | 284 local keep = 1 - self.db.factionrealm.AHCut |
281 threshold = threshold/keep | 285 threshold = threshold/keep |
282 | 286 |