Mercurial > wow > itemauditor
comparison Core.lua @ 5:7d0f4ebedf8c
work in progress: I added Prospecting and Disenchanting and AHOutbid mail and I also changed the initialization to quit forcing debug every time ItemAuditor loads and have begun to implement the COD mail scanning.
| author | Asa Ayers <Asa.Ayers@Gmail.com> |
|---|---|
| date | Wed, 26 May 2010 21:26:24 -0700 |
| parents | c940b527ccab |
| children | 5dddd73b2220 |
comparison
equal
deleted
inserted
replaced
| 4:c940b527ccab | 5:7d0f4ebedf8c |
|---|---|
| 21 factionrealm = { | 21 factionrealm = { |
| 22 item_account = {} | 22 item_account = {} |
| 23 }, | 23 }, |
| 24 } | 24 } |
| 25 self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", DB_defaults, true) | 25 self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", DB_defaults, true) |
| 26 | |
| 27 self.db.char.debug = true | |
| 28 | 26 |
| 29 self:RegisterOptions() | 27 self:RegisterOptions() |
| 30 | 28 |
| 31 self:RegisterEvent("PLAYER_ENTERING_WORLD") | 29 self:RegisterEvent("PLAYER_ENTERING_WORLD") |
| 32 end | 30 end |
| 91 local results = {} | 89 local results = {} |
| 92 for mailIndex = 1, GetInboxNumItems() or 0 do | 90 for mailIndex = 1, GetInboxNumItems() or 0 do |
| 93 local sender, msgSubject, msgMoney, msgCOD, _, msgItem, _, _, msgText, _, isGM = select(3, GetInboxHeaderInfo(mailIndex)) | 91 local sender, msgSubject, msgMoney, msgCOD, _, msgItem, _, _, msgText, _, isGM = select(3, GetInboxHeaderInfo(mailIndex)) |
| 94 local mailType = Postal:GetMailType(msgSubject) | 92 local mailType = Postal:GetMailType(msgSubject) |
| 95 | 93 |
| 96 if mailType == "NonAHMail" then | 94 if mailType == "NonAHMail" and msgCOD > 0 then |
| 97 -- Don't know how to handle these yet | 95 -- Don't know how to handle these yet |
| 96 | |
| 97 local itemTypes = {} | |
| 98 for itemIndex = 1, ATTACHMENTS_MAX_RECEIVE do | |
| 99 local itemName, _, count, _, _= GetInboxItem(mailIndex, itemIndex) | |
| 100 if itemName ~= nil then | |
| 101 itemTypes[itemName] = (itemTypes[itemName] or 0) + count | |
| 102 end | |
| 103 end | |
| 104 | |
| 105 if utils:tcount(itemTypes) == 1 then | |
| 106 for itemName, count in pairs(itemTypes) do | |
| 107 results[itemName] = (results[itemName] or 0) - msgCOD | |
| 108 end | |
| 109 else | |
| 110 self:Debug("Don't know what to do with more than one item type on COD mail.") | |
| 111 end | |
| 112 | |
| 113 | |
| 98 elseif mailType == "AHSuccess" then | 114 elseif mailType == "AHSuccess" then |
| 99 local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); | 115 local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); |
| 100 if results[itemName] == nil then | 116 results[itemName] = (results[itemName] or 0) + deposit + buyout - consignment |
| 101 results[itemName] = 0 | |
| 102 end | |
| 103 results[itemName] = results[itemName] + deposit + buyout - consignment | |
| 104 | 117 |
| 105 elseif mailType == "AHWon" then | 118 elseif mailType == "AHWon" then |
| 106 local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); | 119 local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); |
| 107 if results[itemName] == nil then | 120 results[itemName] = (results[itemName] or 0) - bid |
| 108 results[itemName] = 0 | 121 elseif mailType == "AHExpired" or mailType == "AHCancelled" or mailType == "AHOutbid" then |
| 109 end | |
| 110 results[itemName] = results[itemName] - bid | |
| 111 elseif mailType == "AHExpired" or mailType == "AHCancelled" then | |
| 112 -- These should be handled when you pay the deposit at the AH | 122 -- These should be handled when you pay the deposit at the AH |
| 113 else | 123 else |
| 114 self:Debug("Unhandled mail type: " .. mailType) | 124 self:Debug("Unhandled mail type: " .. mailType) |
| 115 self:Debug(msgSubject) | 125 self:Debug(msgSubject) |
| 116 end | 126 end |
