Mercurial > wow > itemauditor
diff Core.lua @ 26:75d917ccd942
Fixed Bug #9 - If existing items have 0c invested, increase them all to match the first transaction that changes their price.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Wed, 14 Jul 2010 00:28:44 -0700 |
parents | 554b30908b33 |
children | 34daa46b644a |
line wrap: on
line diff
--- a/Core.lua Sun Jul 11 09:24:33 2010 -0700 +++ b/Core.lua Wed Jul 14 00:28:44 2010 -0700 @@ -166,15 +166,22 @@ elseif mailType == "CODPayment" then itemName = msgSubject:gsub(utils.SubjectPatterns[mailType], function(item) return item end) - results[mailType][itemName] = (results[mailType][itemName] or 0) - msgMoney + results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) + results[mailType][itemName].total = results[mailType][itemName].total - msgMoney elseif mailType == "AHSuccess" then local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); - results[mailType][itemName] = (results[mailType][itemName] or 0) - deposit - buyout + consignment + results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) + results[mailType][itemName].total = results[mailType][itemName].total - deposit - buyout + consignment + elseif mailType == "AHWon" then local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); - results[mailType][itemName] = (results[mailType][itemName] or 0) + bid + results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) + results[mailType][itemName].total = results[mailType][itemName].total + bid + + local count = select(3, GetInboxItem(1,1)) + results[mailType][itemName].count = results[mailType][itemName].count + count elseif mailType == "AHExpired" or mailType == "AHCancelled" or mailType == "AHOutbid" then -- These should be handled when you pay the deposit at the AH else @@ -185,8 +192,8 @@ end for mailType, collection in pairs(results) do - for item, total in pairs(collection) do - self:Debug(format("|cFF00FF00MailScan|r: %s - %s - %s", mailType, item, total)) + for item, data in pairs(collection) do + self:Debug(format("|cFF00FF00MailScan|r: %s - %s - %s x %s", mailType, item, data.total, data.count)) end end @@ -246,14 +253,15 @@ end end -function addon:SaveValue(link, value) - self:Debug(format("SaveValue(%s, %s)", tostring(link), value)) +function addon:SaveValue(link, value, countChange) + self:Debug("SaveValue(%s, %s, %s)", tostring(link), value, (countChange or 'default')) + countChange = countChange or 0 local item = nil local realLink = self:GetSafeLink(link) local itemName = nil if realLink == nil then + itemName = link self:Debug('SaveValue: GetSafeLink failed, falling back to storing by name: ' .. tostring(itemName)) - itemName = link self.db.factionrealm.item_account[itemName] = (self.db.factionrealm.item_account[itemName] or 0) + value item = {invested = self.db.factionrealm.item_account[itemName], count = 1} else @@ -263,6 +271,13 @@ itemName = GetItemInfo(realLink) end + if value > 0 and countChange > 0 and item.invested == value and item.count ~= countChange then + local costPerItem = value / countChange + value = costPerItem * item.count + item.invested = value + self:Print("You already owned %s %s with an unknown price, so they have also been updated to %s each", (item.count - countChange), itemName, self:FormatMoney(costPerItem)) + end + if abs(value) > 0 then if item.invested < 0 then if self.db.profile.messages.cost_updates then