comparison Modules/Events.lua @ 10:c79ede3c7b82

Updated version and added a dependency on my modified API for QuickAuctions. Next I need to make that dependency optional
author Asa Ayers <Asa.Ayers@Gmail.com>
date Fri, 25 Jun 2010 22:03:44 -0700
parents 374dd1a90d02
children 8c83d5f6e306
comparison
equal deleted inserted replaced
9:374dd1a90d02 10:c79ede3c7b82
78 function addon:UpdateCurrentInventory() 78 function addon:UpdateCurrentInventory()
79 self.lastInventory = self:GetCurrentInventory() 79 self.lastInventory = self:GetCurrentInventory()
80 end 80 end
81 81
82 function addon:UpdateAudit() 82 function addon:UpdateAudit()
83 self:Debug("UpdateAudit") 83 -- self:Debug("UpdateAudit")
84 local currentInventory = self:GetCurrentInventory() 84 local currentInventory = self:GetCurrentInventory()
85 local diff = addon:GetInventoryDiff(self.lastInventory, currentInventory) 85 local diff = addon:GetInventoryDiff(self.lastInventory, currentInventory)
86 -- this is only here for debugging 86 -- this is only here for debugging
87 self.lastdiff = diff 87 self.lastdiff = diff
88 88
99 end 99 end
100 100
101 if diff.money > 0 and utils:tcount(positive) > 0 and utils:tcount(negative) == 0 then 101 if diff.money > 0 and utils:tcount(positive) > 0 and utils:tcount(negative) == 0 then
102 -- self:Debug("loot") 102 -- self:Debug("loot")
103 elseif utils:tcount(diff.items) == 1 then 103 elseif utils:tcount(diff.items) == 1 then
104 self:Debug("purchase or sale") 104 -- self:Debug("purchase or sale")
105 105
106 for link, count in pairs(diff.items) do 106 for link, count in pairs(diff.items) do
107 self:SaveValue(link, 0 - diff.money) 107 self:SaveValue(link, 0 - diff.money)
108 end 108 end
109 elseif utils:tcount(diff.items) > 1 then 109 elseif utils:tcount(diff.items) > 1 then
110 110
111 if utils:tcount(positive) > 0 and utils:tcount(negative) > 0 then 111 if utils:tcount(positive) > 0 and utils:tcount(negative) > 0 then
112 -- we must have created/converted something 112 -- we must have created/converted something
113 -- self:Debug("conversion") 113 -- self:Debug("conversion")
114
114 local totalChange = 0 115 local totalChange = 0
115 for link, change in pairs(negative) do 116 for link, change in pairs(negative) do
116 local _, itemCost, count = self:GetItemCost(link, change) 117 local _, itemCost, count = self:GetItemCost(link, change)
117 self:SaveValue(link, itemCost * change) 118 self:SaveValue(link, itemCost * change)
118 119