Mercurial > wow > itemauditor
comparison Core.lua @ 98:b29441cd130d
Ticket 30 (related to #23) - ItemAuditor is back to counting items in the mailbox, but will subtract items purchased from the AH or COD mail from its item counts.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Thu, 19 Aug 2010 22:53:54 -0700 |
parents | 693f664aad2b |
children | e6292f1a0cf3 |
comparison
equal
deleted
inserted
replaced
97:028c02f1d47f | 98:b29441cd130d |
---|---|
7 if not DevTools_Dump then | 7 if not DevTools_Dump then |
8 function DevTools_Dump() | 8 function DevTools_Dump() |
9 end | 9 end |
10 end | 10 end |
11 | 11 |
12 local WHITE = "|cFFFFFFFF" | 12 local allMailboxes = {} |
13 local RED = "|cFFFF0000" | 13 local myMailbox = {} |
14 local GREEN = "|cFF00FF00" | |
15 local YELLOW = "|cFFFFFF00" | |
16 local ORANGE = "|cFFFF7F00" | |
17 local TEAL = "|cFF00FF9A" | |
18 local GOLD = "|cFFFFD700" | |
19 | |
20 | 14 |
21 ItemAuditor.Options = { | 15 ItemAuditor.Options = { |
22 handler = ItemAuditor, | 16 handler = ItemAuditor, |
23 name = "ItemAuditor @project-version@", | 17 name = "ItemAuditor @project-version@", |
24 type = 'group', | 18 type = 'group', |
70 }, | 64 }, |
71 factionrealm = { | 65 factionrealm = { |
72 item_account = {}, | 66 item_account = {}, |
73 items = {}, | 67 items = {}, |
74 outbound_cod = {}, | 68 outbound_cod = {}, |
69 mailbox = {} | |
75 }, | 70 }, |
76 } | 71 } |
77 self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", DB_defaults, true) | 72 self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", DB_defaults, true) |
78 | 73 |
74 allMailboxes = self.db.factionrealm.mailbox | |
75 if not allMailboxes[UnitName("player")] then | |
76 allMailboxes[UnitName("player")] = {} | |
77 end | |
78 myMailbox = allMailboxes[UnitName("player")] | |
79 | |
79 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor") | 80 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor") |
80 | 81 |
81 LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", ItemAuditor.Options, {"ia"}) | 82 LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", ItemAuditor.Options, {"ia"}) |
82 ItemAuditor:RegisterFrame(ItemAuditor_DebugFrame) | 83 ItemAuditor:RegisterFrame(ItemAuditor_DebugFrame) |
83 | 84 |
327 elseif mailType == "AHWon" then | 328 elseif mailType == "AHWon" then |
328 local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); | 329 local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); |
329 results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) | 330 results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) |
330 results[mailType][itemName].total = results[mailType][itemName].total + bid | 331 results[mailType][itemName].total = results[mailType][itemName].total + bid |
331 | 332 |
332 local count = select(3, GetInboxItem(1,1)) | 333 local count = select(3, GetInboxItem(mailIndex,1)) |
333 results[mailType][itemName].count = results[mailType][itemName].count + count | 334 results[mailType][itemName].count = results[mailType][itemName].count + count |
334 elseif mailType == "AHExpired" or mailType == "AHCancelled" or mailType == "AHOutbid" then | 335 elseif mailType == "AHExpired" or mailType == "AHCancelled" or mailType == "AHOutbid" then |
335 -- These should be handled when you pay the deposit at the AH | 336 -- These should be handled when you pay the deposit at the AH |
336 else | 337 else |
337 -- self:Debug("Unhandled mail type: " .. mailType) | 338 -- self:Debug("Unhandled mail type: " .. mailType) |
338 -- self:Debug(msgSubject) | 339 -- self:Debug(msgSubject) |
339 end | 340 end |
340 | 341 |
341 end | 342 end |
342 | 343 |
344 wipe(myMailbox) | |
343 for mailType, collection in pairs(results) do | 345 for mailType, collection in pairs(results) do |
346 myMailbox[mailType] = {} | |
344 for item, data in pairs(collection) do | 347 for item, data in pairs(collection) do |
345 self:Debug(format("|cFF00FF00MailScan|r: %s - %s - %s x %s", mailType, item, data.total, data.count)) | 348 myMailbox[mailType][item] = { |
346 end | 349 total = data.total, |
347 end | 350 count = data.count, |
348 | 351 } |
352 -- self:Print(format("|cFF00FF00MailScan|r: %s - %s - %s x %s", mailType, item, data.total, data.count)) | |
353 end | |
354 end | |
349 return results | 355 return results |
350 end | 356 end |
351 | 357 |
352 function ItemAuditor:GetItemCount(searchID) | 358 function ItemAuditor:GetItemCount(searchID) |
353 local itemCounts = {} | 359 local count = Altoholic:GetItemCount(searchID) |
354 local count = 0 | 360 local itemName = GetItemInfo(searchID) |
355 for _, character in pairs(DataStore:GetCharacters()) do | 361 for character, mailbox in pairs(allMailboxes) do |
356 bags, bank = DataStore:GetContainerItemCount(character, searchID) | 362 for type, items in pairs(mailbox) do |
357 | 363 if type == 'AHWon' or type == 'COD' then |
358 count = count + bags + bank | 364 for name, data in pairs(items) do |
359 + (DataStore:GetAuctionHouseItemCount(character, searchID) or 0) | 365 if name == itemName then |
360 + (DataStore:GetInventoryItemCount(character, searchID) or 0) | 366 count = count - data.count |
361 + (DataStore:GetCurrencyItemCount(character, searchID) or 0) | 367 |
368 end | |
369 end | |
370 end | |
371 end | |
362 end | 372 end |
363 return count | 373 return count |
364 end | 374 end |
365 | 375 |
366 function ItemAuditor:GetItem(link, viewOnly) | 376 function ItemAuditor:GetItem(link, viewOnly) |