comparison Core.lua @ 137:526036e4358f

Ticket 42 - In order to fix an issue with having multiple items that are the same base item with different enchants, all costs are now tracked against the base item instead of the exact item.
author Asa Ayers <Asa.Ayers@Gmail.com>
date Sat, 02 Oct 2010 19:21:56 -0700
parents d3d5e82043d8
children 7e1496b25311
comparison
equal deleted inserted replaced
136:d3d5e82043d8 137:526036e4358f
1 local ItemAuditor = select(2, ...) 1 local ItemAuditor = select(2, ...)
2 local Utils
2 ItemAuditor = LibStub("AceAddon-3.0"):NewAddon(ItemAuditor, "ItemAuditor", "AceEvent-3.0", "AceBucket-3.0") 3 ItemAuditor = LibStub("AceAddon-3.0"):NewAddon(ItemAuditor, "ItemAuditor", "AceEvent-3.0", "AceBucket-3.0")
3 --@debug@ 4 --@debug@
4 _G['ItemAuditor'] = ItemAuditor 5 _G['ItemAuditor'] = ItemAuditor
5 --@end-debug@ 6 --@end-debug@
6 7
71 enabled_guilds = {}, 72 enabled_guilds = {},
72 }, 73 },
73 } 74 }
74 75
75 function ItemAuditor:OnInitialize() 76 function ItemAuditor:OnInitialize()
77 Utils = self:GetModule("Utils")
76 self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", ItemAuditor.DB_defaults, true) 78 self.db = LibStub("AceDB-3.0"):New("ItemAuditorDB", ItemAuditor.DB_defaults, true)
77 79
78 allMailboxes = self.db.factionrealm.mailbox 80 allMailboxes = self.db.factionrealm.mailbox
79 if not allMailboxes[UnitName("player")] then 81 if not allMailboxes[UnitName("player")] then
80 allMailboxes[UnitName("player")] = {} 82 allMailboxes[UnitName("player")] = {}
197 199
198 local function scanBag(bagID, i) 200 local function scanBag(bagID, i)
199 bagSize=GetContainerNumSlots(bagID) 201 bagSize=GetContainerNumSlots(bagID)
200 for slotID = 0, bagSize do 202 for slotID = 0, bagSize do
201 local link= GetContainerItemLink(bagID, slotID); 203 local link= GetContainerItemLink(bagID, slotID);
202 link = link and ItemAuditor:GetSafeLink(link) 204 itemID = link and Utils.GetItemID(link)
203 205
204 if link ~= nil and i[link] == nil then 206 if link and itemID and i[itemID] == nil then
205 i[link] = GetItemCount(link, bankOpen); 207 i[itemID] = GetItemCount(itemID, bankOpen);
206 end 208 end
207 end 209 end
208 end 210 end
209 211
210 function ItemAuditor:GetCurrentInventory() 212 function ItemAuditor:GetCurrentInventory()
230 if current == nil then 232 if current == nil then
231 current = self:GetCurrentInventory() 233 current = self:GetCurrentInventory()
232 end 234 end
233 local diff = {} 235 local diff = {}
234 236
235 for link, count in pairs(current.items) do 237 for itemID, count in pairs(current.items) do
236 if pastInventory.items[link] == nil then 238 if pastInventory.items[itemID] == nil then
237 diff[link] = count 239 diff[itemID] = count
238 self:Debug("1 diff[" .. link .. "]=" .. diff[link]) 240 self:Debug("1 diff[" .. itemID .. "]=" .. diff[itemID])
239 elseif count - pastInventory.items[link] ~= 0 then 241 elseif count - pastInventory.items[itemID] ~= 0 then
240 diff[link] = count - pastInventory.items[link] 242 diff[itemID] = count - pastInventory.items[itemID]
241 self:Debug("2 diff[" .. link .. "]=" .. diff[link]) 243 self:Debug("2 diff[" .. itemID .. "]=" .. diff[itemID])
242 end 244 end
243 end 245 end
244 246
245 for link, count in pairs(pastInventory.items) do 247 for itemID, count in pairs(pastInventory.items) do
246 if current.items[link] == nil then 248 if current.items[itemID] == nil then
247 diff[link] = -count 249 diff[itemID] = -count
248 self:Debug("3 diff[" .. link .. "]=" .. diff[link]) 250 self:Debug("3 diff[" .. liitemIDnk .. "]=" .. diff[itemID])
249 elseif current.items[link] - count ~= 0 then 251 elseif current.items[itemID] - count ~= 0 then
250 diff[link] = current.items[link] - pastInventory.items[link] 252 diff[itemID] = current.items[itemID] - pastInventory.items[itemID]
251 self:Debug("4 diff[" .. link .. "]=" .. diff[link]) 253 self:Debug("4 diff[" .. itemID .. "]=" .. diff[itemID])
252 end 254 end
253 end 255 end
254 256
255 local moneyDiff = current.money - pastInventory.money 257 local moneyDiff = current.money - pastInventory.money
256 if abs(moneyDiff) > 0 then 258 if abs(moneyDiff) > 0 then