Mercurial > wow > itemauditor
comparison Core.lua @ 82:e9f7bc9199ca release 2010-08-05
Fixed Bug 23 - When you purchase multiple stacks of the same item and it is one you have not invested in yet, ItemAuditor mistakenly counted items you have not yet pulled from the mail as items you already owned. This resulted in those items being counted twice.
author | Asa Ayers <Asa.Ayers@Gmail.com> |
---|---|
date | Thu, 05 Aug 2010 22:20:44 -0700 |
parents | 64166ba5209a |
children | 210bcf218509 |
comparison
equal
deleted
inserted
replaced
81:64166ba5209a | 82:e9f7bc9199ca |
---|---|
339 end | 339 end |
340 | 340 |
341 return results | 341 return results |
342 end | 342 end |
343 | 343 |
344 function ItemAuditor:GetItemCount(searchID) | |
345 local itemCounts = {} | |
346 local count = 0 | |
347 for _, character in pairs(DataStore:GetCharacters()) do | |
348 bags, bank = DataStore:GetContainerItemCount(character, searchID) | |
349 | |
350 count = count + bags + bank | |
351 + DataStore:GetAuctionHouseItemCount(character, searchID) | |
352 + DataStore:GetInventoryItemCount(character, searchID) | |
353 + DataStore:GetCurrencyItemCount(character, searchID) | |
354 end | |
355 return count | |
356 end | |
357 | |
344 function ItemAuditor:GetItem(link, viewOnly) | 358 function ItemAuditor:GetItem(link, viewOnly) |
345 if viewOnly == nil then | 359 if viewOnly == nil then |
346 viewOnly = false | 360 viewOnly = false |
347 end | 361 end |
348 | 362 |
355 end | 369 end |
356 | 370 |
357 | 371 |
358 if self.db.factionrealm.item_account[itemName] ~= nil then | 372 if self.db.factionrealm.item_account[itemName] ~= nil then |
359 self.db.factionrealm.items[link] = { | 373 self.db.factionrealm.items[link] = { |
360 count = Altoholic:GetItemCount(self:GetIDFromLink(link)), | 374 count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)), |
361 invested = abs(self.db.factionrealm.item_account[itemName] or 0), | 375 invested = abs(self.db.factionrealm.item_account[itemName] or 0), |
362 } | 376 } |
363 self.db.factionrealm.item_account[itemName] = nil | 377 self.db.factionrealm.item_account[itemName] = nil |
364 end | 378 end |
365 | 379 |
366 if viewOnly == false and self.db.factionrealm.items[link] == nil then | 380 if viewOnly == false and self.db.factionrealm.items[link] == nil then |
367 | 381 |
368 self.db.factionrealm.items[link] = { | 382 self.db.factionrealm.items[link] = { |
369 count = Altoholic:GetItemCount(self:GetIDFromLink(link)), | 383 count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)), |
370 invested = abs(self.db.factionrealm.item_account[itemName] or 0), | 384 invested = abs(self.db.factionrealm.item_account[itemName] or 0), |
371 } | 385 } |
372 | 386 |
373 end | 387 end |
374 | 388 |
375 if self.db.factionrealm.items[link] ~= nil then | 389 if self.db.factionrealm.items[link] ~= nil then |
376 self.db.factionrealm.items[link].count = Altoholic:GetItemCount(self:GetIDFromLink(link)) | 390 self.db.factionrealm.items[link].count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)) |
377 | 391 |
378 if self.db.factionrealm.items[link].invested == nil then | 392 if self.db.factionrealm.items[link].invested == nil then |
379 self.db.factionrealm.items[link].invested = 0 | 393 self.db.factionrealm.items[link].invested = 0 |
380 end | 394 end |
381 end | 395 end |
434 self:Print(format("Updated price of %s from %s to %s. %sYou just made a profit of %s.", itemName, self:FormatMoney(item.invested - value), self:FormatMoney(0), GREEN, self:FormatMoney(abs(item.invested)))) | 448 self:Print(format("Updated price of %s from %s to %s. %sYou just made a profit of %s.", itemName, self:FormatMoney(item.invested - value), self:FormatMoney(0), GREEN, self:FormatMoney(abs(item.invested)))) |
435 end | 449 end |
436 self:RemoveItem(link) | 450 self:RemoveItem(link) |
437 -- This doesn't work when you mail the only copy of an item you have to another character. | 451 -- This doesn't work when you mail the only copy of an item you have to another character. |
438 --[[ | 452 --[[ |
439 elseif item.count == 0 and realLink and Altoholic:GetItemCount(self:GetIDFromLink(realLink)) then | 453 elseif item.count == 0 and realLink and ItemAuditor:GetItemCount(self:GetIDFromLink(realLink)) then |
440 self:Print("You ran out of " .. itemName .. " and never recovered " .. self:FormatMoney(item.invested)) | 454 self:Print("You ran out of " .. itemName .. " and never recovered " .. self:FormatMoney(item.invested)) |
441 self:RemoveItem(link) | 455 self:RemoveItem(link) |
442 ]] | 456 ]] |
443 else | 457 else |
444 if self.db.profile.messages.cost_updates then | 458 if self.db.profile.messages.cost_updates then |
504 if count > 0 then | 518 if count > 0 then |
505 return ceil(item.invested), ceil(item.invested/count), count | 519 return ceil(item.invested), ceil(item.invested/count), count |
506 end | 520 end |
507 | 521 |
508 end | 522 end |
509 return 0, 0, Altoholic:GetItemCount(ItemAuditor:GetIDFromLink(link)) | 523 return 0, 0, ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(link)) |
510 end | 524 end |