Mercurial > wow > itemauditor
comparison Core.lua @ 133:5eefa40e2a29
Trimmed trailing spaces
| author | Asa Ayers <Asa.Ayers@Gmail.com> |
|---|---|
| date | Wed, 15 Sep 2010 21:34:57 -0700 |
| parents | 0eaec1b52a63 |
| children | a529a4a4ccbe |
comparison
equal
deleted
inserted
replaced
| 132:0eaec1b52a63 | 133:5eefa40e2a29 |
|---|---|
| 81 allMailboxes[UnitName("player")] = {} | 81 allMailboxes[UnitName("player")] = {} |
| 82 end | 82 end |
| 83 myMailbox = allMailboxes[UnitName("player")] | 83 myMailbox = allMailboxes[UnitName("player")] |
| 84 | 84 |
| 85 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor") | 85 self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("ItemAuditor", "ItemAuditor") |
| 86 | 86 |
| 87 LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", ItemAuditor.Options, {"ia"}) | 87 LibStub("AceConfig-3.0"):RegisterOptionsTable("ItemAuditor", ItemAuditor.Options, {"ia"}) |
| 88 ItemAuditor:RegisterFrame(ItemAuditor_DebugFrame) | 88 ItemAuditor:RegisterFrame(ItemAuditor_DebugFrame) |
| 89 | 89 |
| 90 LibStub("AceConsole-3.0"):RegisterChatCommand('rl', ReloadUI) | 90 LibStub("AceConsole-3.0"):RegisterChatCommand('rl', ReloadUI) |
| 91 | 91 |
| 92 if self.db.char.crafting_threshold then | 92 if self.db.char.crafting_threshold then |
| 93 local threshold = self.db.char.crafting_threshold | 93 local threshold = self.db.char.crafting_threshold |
| 94 if threshold == 1 then | 94 if threshold == 1 then |
| 96 elseif threshold == 2 then | 96 elseif threshold == 2 then |
| 97 self.db.char.profitable_threshold = 10000 | 97 self.db.char.profitable_threshold = 10000 |
| 98 elseif threshold == 3 then | 98 elseif threshold == 3 then |
| 99 self.db.char.profitable_threshold = 50000 | 99 self.db.char.profitable_threshold = 50000 |
| 100 end | 100 end |
| 101 | 101 |
| 102 self.db.char.crafting_threshold = nil | 102 self.db.char.crafting_threshold = nil |
| 103 end | 103 end |
| 104 | 104 |
| 105 ItemAuditor:IsQAEnabled() | 105 ItemAuditor:IsQAEnabled() |
| 106 | 106 |
| 114 end | 114 end |
| 115 | 115 |
| 116 | 116 |
| 117 | 117 |
| 118 local registeredEvents = {} | 118 local registeredEvents = {} |
| 119 local originalRegisterEvent = ItemAuditor.RegisterEvent | 119 local originalRegisterEvent = ItemAuditor.RegisterEvent |
| 120 function ItemAuditor:RegisterEvent(event, callback, arg) | 120 function ItemAuditor:RegisterEvent(event, callback, arg) |
| 121 registeredEvents[event] = true | 121 registeredEvents[event] = true |
| 122 if arg ~= nil then | 122 if arg ~= nil then |
| 123 return originalRegisterEvent(self, event, callback, arg) | 123 return originalRegisterEvent(self, event, callback, arg) |
| 124 elseif callback ~= nil then | 124 elseif callback ~= nil then |
| 161 end | 161 end |
| 162 if value == 0 then | 162 if value == 0 then |
| 163 self.db.factionrealm.item_account[itemName] = nil | 163 self.db.factionrealm.item_account[itemName] = nil |
| 164 end | 164 end |
| 165 end | 165 end |
| 166 | 166 |
| 167 for link, data in pairs(self.db.factionrealm.items) do | 167 for link, data in pairs(self.db.factionrealm.items) do |
| 168 if self:GetItem(link).count == 0 or self:GetItem(link).invested == 0 then | 168 if self:GetItem(link).count == 0 or self:GetItem(link).invested == 0 then |
| 169 self:RemoveItem(link) | 169 self:RemoveItem(link) |
| 170 end | 170 end |
| 171 end | 171 end |
| 172 | 172 |
| 173 self:RefreshQAGroups() | 173 self:RefreshQAGroups() |
| 174 end | 174 end |
| 175 | 175 |
| 176 -- Options doesn't exist when this file is created the first time, so getOptions will | 176 -- Options doesn't exist when this file is created the first time, so getOptions will |
| 177 -- make one call to :GetModule and return the result and replace itself with a | 177 -- make one call to :GetModule and return the result and replace itself with a |
| 178 -- function that simply returns the same object. The permanent solution will probably be | 178 -- function that simply returns the same object. The permanent solution will probably be |
| 179 -- to move :Print to a different module. | 179 -- to move :Print to a different module. |
| 180 local function getOptions() | 180 local function getOptions() |
| 181 local Options = ItemAuditor:GetModule("Options") | 181 local Options = ItemAuditor:GetModule("Options") |
| 182 getOptions = function() return Options end | 182 getOptions = function() return Options end |
| 210 | 210 |
| 211 function ItemAuditor:GetCurrentInventory() | 211 function ItemAuditor:GetCurrentInventory() |
| 212 local i = {} | 212 local i = {} |
| 213 local bagID | 213 local bagID |
| 214 local slotID | 214 local slotID |
| 215 | 215 |
| 216 for bagID = 0, NUM_BAG_SLOTS do | 216 for bagID = 0, NUM_BAG_SLOTS do |
| 217 scanBag(bagID, i) | 217 scanBag(bagID, i) |
| 218 end | 218 end |
| 219 | 219 |
| 220 if bankOpen then | 220 if bankOpen then |
| 221 scanBag(BANK_CONTAINER, i) | 221 scanBag(BANK_CONTAINER, i) |
| 222 for bagID = NUM_BAG_SLOTS+1, NUM_BANKBAGSLOTS do | 222 for bagID = NUM_BAG_SLOTS+1, NUM_BANKBAGSLOTS do |
| 223 scanBag(bagID, i) | 223 scanBag(bagID, i) |
| 224 end | 224 end |
| 225 end | 225 end |
| 226 | 226 |
| 227 return {items = i, money = GetMoney()} | 227 return {items = i, money = GetMoney()} |
| 228 end | 228 end |
| 229 | 229 |
| 230 function ItemAuditor:GetInventoryDiff(pastInventory, current) | 230 function ItemAuditor:GetInventoryDiff(pastInventory, current) |
| 231 if current == nil then | 231 if current == nil then |
| 237 if pastInventory.items[link] == nil then | 237 if pastInventory.items[link] == nil then |
| 238 diff[link] = count | 238 diff[link] = count |
| 239 self:Debug("1 diff[" .. link .. "]=" .. diff[link]) | 239 self:Debug("1 diff[" .. link .. "]=" .. diff[link]) |
| 240 elseif count - pastInventory.items[link] ~= 0 then | 240 elseif count - pastInventory.items[link] ~= 0 then |
| 241 diff[link] = count - pastInventory.items[link] | 241 diff[link] = count - pastInventory.items[link] |
| 242 self:Debug("2 diff[" .. link .. "]=" .. diff[link]) | 242 self:Debug("2 diff[" .. link .. "]=" .. diff[link]) |
| 243 end | 243 end |
| 244 end | 244 end |
| 245 | 245 |
| 246 for link, count in pairs(pastInventory.items) do | 246 for link, count in pairs(pastInventory.items) do |
| 247 if current.items[link] == nil then | 247 if current.items[link] == nil then |
| 248 diff[link] = -count | 248 diff[link] = -count |
| 249 self:Debug("3 diff[" .. link .. "]=" .. diff[link]) | 249 self:Debug("3 diff[" .. link .. "]=" .. diff[link]) |
| 250 elseif current.items[link] - count ~= 0 then | 250 elseif current.items[link] - count ~= 0 then |
| 251 diff[link] = current.items[link] - pastInventory.items[link] | 251 diff[link] = current.items[link] - pastInventory.items[link] |
| 252 self:Debug("4 diff[" .. link .. "]=" .. diff[link]) | 252 self:Debug("4 diff[" .. link .. "]=" .. diff[link]) |
| 253 end | 253 end |
| 254 end | 254 end |
| 255 | 255 |
| 256 local moneyDiff = current.money - pastInventory.money | 256 local moneyDiff = current.money - pastInventory.money |
| 257 if abs(moneyDiff) > 0 then | 257 if abs(moneyDiff) > 0 then |
| 264 local inboundCOD = {} | 264 local inboundCOD = {} |
| 265 local skipMail = {} | 265 local skipMail = {} |
| 266 function ItemAuditor:ScanMail() | 266 function ItemAuditor:ScanMail() |
| 267 local results = {} | 267 local results = {} |
| 268 local CODPaymentRegex = gsub(COD_PAYMENT, "%%s", "(.*)") | 268 local CODPaymentRegex = gsub(COD_PAYMENT, "%%s", "(.*)") |
| 269 | 269 |
| 270 for mailIndex = 1, GetInboxNumItems() or 0 do | 270 for mailIndex = 1, GetInboxNumItems() or 0 do |
| 271 local sender, msgSubject, msgMoney, msgCOD, daysLeft, msgItem, _, _, msgText, _, isGM = select(3, GetInboxHeaderInfo(mailIndex)) | 271 local sender, msgSubject, msgMoney, msgCOD, daysLeft, msgItem, _, _, msgText, _, isGM = select(3, GetInboxHeaderInfo(mailIndex)) |
| 272 local mailType = self:GetMailType(msgSubject) | 272 local mailType = self:GetMailType(msgSubject) |
| 273 | 273 |
| 274 local mailSignature = msgSubject .. '-' .. msgMoney .. '-' .. msgCOD .. '-' .. daysLeft | 274 local mailSignature = msgSubject .. '-' .. msgMoney .. '-' .. msgCOD .. '-' .. daysLeft |
| 275 | 275 |
| 276 results[mailType] = (results[mailType] or {}) | 276 results[mailType] = (results[mailType] or {}) |
| 277 | 277 |
| 278 if skipMail[mailSignature] ~= nil then | 278 if skipMail[mailSignature] ~= nil then |
| 279 -- do nothing | 279 -- do nothing |
| 280 elseif mailType == "NonAHMail" and msgCOD > 0 then | 280 elseif mailType == "NonAHMail" and msgCOD > 0 then |
| 281 mailType = 'COD' | 281 mailType = 'COD' |
| 282 results[mailType] = (results[mailType] or {}) | 282 results[mailType] = (results[mailType] or {}) |
| 283 | 283 |
| 284 local itemTypes = {} | 284 local itemTypes = {} |
| 285 for itemIndex = 1, ATTACHMENTS_MAX_RECEIVE do | 285 for itemIndex = 1, ATTACHMENTS_MAX_RECEIVE do |
| 286 local itemName, _, count, _, _= GetInboxItem(mailIndex, itemIndex) | 286 local itemName, _, count, _, _= GetInboxItem(mailIndex, itemIndex) |
| 287 if itemName ~= nil then | 287 if itemName ~= nil then |
| 288 itemTypes[itemName] = (itemTypes[itemName] or 0) + count | 288 itemTypes[itemName] = (itemTypes[itemName] or 0) + count |
| 289 end | 289 end |
| 290 end | 290 end |
| 291 | 291 |
| 292 if self:tcount(itemTypes) == 1 then | 292 if self:tcount(itemTypes) == 1 then |
| 293 for itemName, count in pairs(itemTypes) do | 293 for itemName, count in pairs(itemTypes) do |
| 294 results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) | 294 results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) |
| 295 results[mailType][itemName].total = results[mailType][itemName].total + msgCOD | 295 results[mailType][itemName].total = results[mailType][itemName].total + msgCOD |
| 296 | 296 |
| 297 if inboundCOD[mailSignature] == nil then | 297 if inboundCOD[mailSignature] == nil then |
| 298 results[mailType][itemName].count = results[mailType][itemName].count + count | 298 results[mailType][itemName].count = results[mailType][itemName].count + count |
| 299 inboundCOD[mailSignature] = (inboundCOD[mailSignature] or 0) + count | 299 inboundCOD[mailSignature] = (inboundCOD[mailSignature] or 0) + count |
| 300 else | 300 else |
| 301 results[mailType][itemName].count = inboundCOD[mailSignature] | 301 results[mailType][itemName].count = inboundCOD[mailSignature] |
| 302 end | 302 end |
| 303 | 303 |
| 304 | 304 |
| 305 end | 305 end |
| 306 else | 306 else |
| 307 self:Debug("Don't know what to do with more than one item type on COD mail.") | 307 self:Debug("Don't know what to do with more than one item type on COD mail.") |
| 308 end | 308 end |
| 309 elseif mailType == "CODPayment" then | 309 elseif mailType == "CODPayment" then |
| 310 -- /dump ItemAuditor.db.factionrealm.outbound_cod | 310 -- /dump ItemAuditor.db.factionrealm.outbound_cod |
| 311 self:Debug(msgSubject) | 311 self:Debug(msgSubject) |
| 312 self:Debug(CODPaymentRegex) | 312 self:Debug(CODPaymentRegex) |
| 313 local outboundSubject = select(3, msgSubject:find(CODPaymentRegex)) | 313 local outboundSubject = select(3, msgSubject:find(CODPaymentRegex)) |
| 314 local trackID | 314 local trackID |
| 315 if outboundSubject ~= nil then | 315 if outboundSubject ~= nil then |
| 316 self:Debug(outboundSubject) | 316 self:Debug(outboundSubject) |
| 317 trackID = select(3, outboundSubject:find('[[]IA: (%d*)[]]')) | 317 trackID = select(3, outboundSubject:find('[[]IA: (%d*)[]]')) |
| 318 | 318 |
| 319 if trackID ~= nil then | 319 if trackID ~= nil then |
| 320 trackID = tonumber(trackID) | 320 trackID = tonumber(trackID) |
| 321 self:Debug('COD ID: %s', trackID) | 321 self:Debug('COD ID: %s', trackID) |
| 322 local cod = self.db.factionrealm.outbound_cod[trackID] | 322 local cod = self.db.factionrealm.outbound_cod[trackID] |
| 323 if cod == nil then | 323 if cod == nil then |
| 324 skipMail[mailSignature] = true | 324 skipMail[mailSignature] = true |
| 325 self:Print("WARNING: {%s} has an invalid ItemAuditor tracking number.", msgSubject) | 325 self:Print("WARNING: {%s} has an invalid ItemAuditor tracking number.", msgSubject) |
| 326 else | 326 else |
| 327 itemName = trackID .. "|" .. cod['link'] | 327 itemName = trackID .. "|" .. cod['link'] |
| 328 | 328 |
| 329 | 329 |
| 330 results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) | 330 results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) |
| 331 results[mailType][itemName].total = results[mailType][itemName].total - msgMoney | 331 results[mailType][itemName].total = results[mailType][itemName].total - msgMoney |
| 332 results[mailType][itemName].count = results[mailType][itemName].count - cod.count | 332 results[mailType][itemName].count = results[mailType][itemName].count - cod.count |
| 333 end | 333 end |
| 334 end | 334 end |
| 335 end | 335 end |
| 336 | 336 |
| 337 if trackID == nil then | 337 if trackID == nil then |
| 338 skipMail[mailSignature] = true | 338 skipMail[mailSignature] = true |
| 339 self:Print("WARNING: {%s} is a COD payment but doesn't have an ItemAuditor tracking number.", msgSubject) | 339 self:Print("WARNING: {%s} is a COD payment but doesn't have an ItemAuditor tracking number.", msgSubject) |
| 340 end | 340 end |
| 341 | 341 |
| 342 elseif mailType == "AHSuccess" then | 342 elseif mailType == "AHSuccess" then |
| 343 local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); | 343 local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); |
| 344 results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) | 344 results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) |
| 345 results[mailType][itemName].total = results[mailType][itemName].total - deposit - buyout + consignment | 345 results[mailType][itemName].total = results[mailType][itemName].total - deposit - buyout + consignment |
| 346 | 346 |
| 347 | 347 |
| 348 elseif mailType == "AHWon" then | 348 elseif mailType == "AHWon" then |
| 349 local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); | 349 local invoiceType, itemName, playerName, bid, buyout, deposit, consignment = GetInboxInvoiceInfo(mailIndex); |
| 350 results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) | 350 results[mailType][itemName] = (results[mailType][itemName] or {total=0,count=0}) |
| 351 results[mailType][itemName].total = results[mailType][itemName].total + bid | 351 results[mailType][itemName].total = results[mailType][itemName].total + bid |
| 352 | 352 |
| 353 local count = select(3, GetInboxItem(mailIndex,1)) | 353 local count = select(3, GetInboxItem(mailIndex,1)) |
| 354 results[mailType][itemName].count = results[mailType][itemName].count + count | 354 results[mailType][itemName].count = results[mailType][itemName].count + count |
| 355 elseif mailType == "AHExpired" or mailType == "AHCancelled" or mailType == "AHOutbid" then | 355 elseif mailType == "AHExpired" or mailType == "AHCancelled" or mailType == "AHOutbid" then |
| 356 -- These should be handled when you pay the deposit at the AH | 356 -- These should be handled when you pay the deposit at the AH |
| 357 else | 357 else |
| 370 count = data.count, | 370 count = data.count, |
| 371 } | 371 } |
| 372 -- self:Print(format("|cFF00FF00MailScan|r: %s - %s - %s x %s", mailType, item, data.total, data.count)) | 372 -- self:Print(format("|cFF00FF00MailScan|r: %s - %s - %s x %s", mailType, item, data.total, data.count)) |
| 373 end | 373 end |
| 374 end | 374 end |
| 375 return results | 375 return results |
| 376 end | 376 end |
| 377 | 377 |
| 378 local realm = GetRealmName() | 378 local realm = GetRealmName() |
| 379 local ds_account = 'Default' | 379 local ds_account = 'Default' |
| 380 function ItemAuditor:GetItemCount(searchID) | 380 function ItemAuditor:GetItemCount(searchID) |
| 409 | 409 |
| 410 function ItemAuditor:GetItem(link, viewOnly) | 410 function ItemAuditor:GetItem(link, viewOnly) |
| 411 if viewOnly == nil then | 411 if viewOnly == nil then |
| 412 viewOnly = false | 412 viewOnly = false |
| 413 end | 413 end |
| 414 | 414 |
| 415 local itemName = nil | 415 local itemName = nil |
| 416 if self:GetSafeLink(link) == nil then | 416 if self:GetSafeLink(link) == nil then |
| 417 itemName = link | 417 itemName = link |
| 418 else | 418 else |
| 419 link = self:GetSafeLink(link) | 419 link = self:GetSafeLink(link) |
| 420 itemName = GetItemInfo(link) | 420 itemName = GetItemInfo(link) |
| 421 end | 421 end |
| 422 | 422 |
| 423 | 423 |
| 424 if self.db.factionrealm.item_account[itemName] ~= nil then | 424 if self.db.factionrealm.item_account[itemName] ~= nil then |
| 425 self.db.factionrealm.items[link] = { | 425 self.db.factionrealm.items[link] = { |
| 426 count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)), | 426 count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)), |
| 427 invested = abs(self.db.factionrealm.item_account[itemName] or 0), | 427 invested = abs(self.db.factionrealm.item_account[itemName] or 0), |
| 428 } | 428 } |
| 429 self.db.factionrealm.item_account[itemName] = nil | 429 self.db.factionrealm.item_account[itemName] = nil |
| 430 end | 430 end |
| 431 | 431 |
| 432 if viewOnly == false and self.db.factionrealm.items[link] == nil then | 432 if viewOnly == false and self.db.factionrealm.items[link] == nil then |
| 433 | 433 |
| 434 self.db.factionrealm.items[link] = { | 434 self.db.factionrealm.items[link] = { |
| 435 count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)), | 435 count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)), |
| 436 invested = abs(self.db.factionrealm.item_account[itemName] or 0), | 436 invested = abs(self.db.factionrealm.item_account[itemName] or 0), |
| 437 } | 437 } |
| 438 | 438 |
| 439 end | 439 end |
| 440 | 440 |
| 441 if self.db.factionrealm.items[link] ~= nil then | 441 if self.db.factionrealm.items[link] ~= nil then |
| 442 self.db.factionrealm.items[link].count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)) | 442 self.db.factionrealm.items[link].count = ItemAuditor:GetItemCount(self:GetIDFromLink(link)) |
| 443 | 443 |
| 444 if self.db.factionrealm.items[link].invested == nil then | 444 if self.db.factionrealm.items[link].invested == nil then |
| 445 self.db.factionrealm.items[link].invested = 0 | 445 self.db.factionrealm.items[link].invested = 0 |
| 446 end | 446 end |
| 447 end | 447 end |
| 448 | 448 |
| 449 if viewOnly == true and self.db.factionrealm.items[link] == nil then | 449 if viewOnly == true and self.db.factionrealm.items[link] == nil then |
| 450 return {count = 0, invested = 0} | 450 return {count = 0, invested = 0} |
| 451 elseif viewOnly == true then | 451 elseif viewOnly == true then |
| 452 | 452 |
| 453 return {count = self.db.factionrealm.items[link].count, invested = self.db.factionrealm.items[link].invested} | 453 return {count = self.db.factionrealm.items[link].count, invested = self.db.factionrealm.items[link].invested} |
| 454 end | 454 end |
| 455 | 455 |
| 456 | 456 |
| 457 | 457 |
| 458 return self.db.factionrealm.items[link] | 458 return self.db.factionrealm.items[link] |
| 459 end | 459 end |
| 460 | 460 |
| 461 function ItemAuditor:RemoveItem(link) | 461 function ItemAuditor:RemoveItem(link) |
| 462 self.db.factionrealm.item_account[link] = nil | 462 self.db.factionrealm.item_account[link] = nil |
| 479 itemName = link | 479 itemName = link |
| 480 self:Debug('SaveValue: GetSafeLink failed, falling back to storing by name: ' .. tostring(itemName)) | 480 self:Debug('SaveValue: GetSafeLink failed, falling back to storing by name: ' .. tostring(itemName)) |
| 481 self.db.factionrealm.item_account[itemName] = (self.db.factionrealm.item_account[itemName] or 0) + value | 481 self.db.factionrealm.item_account[itemName] = (self.db.factionrealm.item_account[itemName] or 0) + value |
| 482 item = {invested = self.db.factionrealm.item_account[itemName], count = 1} | 482 item = {invested = self.db.factionrealm.item_account[itemName], count = 1} |
| 483 else | 483 else |
| 484 | 484 |
| 485 item = self:GetItem(realLink) | 485 item = self:GetItem(realLink) |
| 486 item.invested = item.invested + value | 486 item.invested = item.invested + value |
| 487 itemName = GetItemInfo(realLink) | 487 itemName = GetItemInfo(realLink) |
| 488 end | 488 end |
| 489 | 489 |
| 490 if value > 0 and countChange > 0 and item.invested == value and item.count ~= countChange then | 490 if value > 0 and countChange > 0 and item.invested == value and item.count ~= countChange then |
| 491 local costPerItem = value / countChange | 491 local costPerItem = value / countChange |
| 492 value = costPerItem * item.count | 492 value = costPerItem * item.count |
| 493 item.invested = value | 493 item.invested = value |
| 494 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)) | 494 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)) |
| 495 end | 495 end |
| 496 | 496 |
| 497 if abs(value) > 0 then | 497 if abs(value) > 0 then |
| 498 if item.invested < 0 then | 498 if item.invested < 0 then |
| 499 if self.db.profile.messages.cost_updates then | 499 if self.db.profile.messages.cost_updates then |
| 500 self:Print(format("Updated price of %s from %s to %s. |cFF00FF00You just made a profit of %s.", itemName, self:FormatMoney(item.invested - value), self:FormatMoney(0), self:FormatMoney(abs(item.invested)))) | 500 self:Print(format("Updated price of %s from %s to %s. |cFF00FF00You just made a profit of %s.", itemName, self:FormatMoney(item.invested - value), self:FormatMoney(0), self:FormatMoney(abs(item.invested)))) |
| 501 end | 501 end |
| 502 self:RemoveItem(link) | 502 self:RemoveItem(link) |
| 503 -- This doesn't work when you mail the only copy of an item you have to another character. | 503 -- This doesn't work when you mail the only copy of an item you have to another character. |
| 504 --[[ | 504 --[[ |
| 505 elseif item.count == 0 and realLink and ItemAuditor:GetItemCount(self:GetIDFromLink(realLink)) then | 505 elseif item.count == 0 and realLink and ItemAuditor:GetItemCount(self:GetIDFromLink(realLink)) then |
| 506 self:Print("You ran out of " .. itemName .. " and never recovered " .. self:FormatMoney(item.invested)) | 506 self:Print("You ran out of " .. itemName .. " and never recovered " .. self:FormatMoney(item.invested)) |
| 507 self:RemoveItem(link) | 507 self:RemoveItem(link) |
| 508 ]] | 508 ]] |
| 509 else | 509 else |
| 510 if self.db.profile.messages.cost_updates then | 510 if self.db.profile.messages.cost_updates then |
| 511 self:Print(format("Updated price of %s from %s to %s. (total change:%s)", itemName, self:FormatMoney(item.invested - value), self:FormatMoney(item.invested), self:FormatMoney(value))) | 511 self:Print(format("Updated price of %s from %s to %s. (total change:%s)", itemName, self:FormatMoney(item.invested - value), self:FormatMoney(item.invested), self:FormatMoney(value))) |
| 512 end | 512 end |
| 513 end | 513 end |
| 514 end | 514 end |
| 515 | 515 |
| 516 if realLink ~= nil then | 516 if realLink ~= nil then |
| 517 ItemAuditor:UpdateQAThreshold(realLink) | 517 ItemAuditor:UpdateQAThreshold(realLink) |
| 518 self:SendMessage("IA_COST_CHANGED", realLink, unpack({ItemAuditor:GetItemCost(realLink)})) | 518 self:SendMessage("IA_COST_CHANGED", realLink, unpack({ItemAuditor:GetItemCost(realLink)})) |
| 519 end | 519 end |
| 520 UpdateInvestedData() | 520 UpdateInvestedData() |
| 562 function ItemAuditor:GetItemCost(link, countModifier) | 562 function ItemAuditor:GetItemCost(link, countModifier) |
| 563 local item = self:GetItem(link, true) | 563 local item = self:GetItem(link, true) |
| 564 | 564 |
| 565 if item.invested > 0 then | 565 if item.invested > 0 then |
| 566 local count = item.count | 566 local count = item.count |
| 567 | 567 |
| 568 if countModifier ~= nil then | 568 if countModifier ~= nil then |
| 569 count = count - countModifier | 569 count = count - countModifier |
| 570 end | 570 end |
| 571 if count > 0 then | 571 if count > 0 then |
| 572 return ceil(item.invested), ceil(item.invested/count), count | 572 return ceil(item.invested), ceil(item.invested/count), count |
| 573 end | 573 end |
| 574 return ceil(item.invested), 0, count | 574 return ceil(item.invested), 0, count |
| 575 end | 575 end |
| 576 return 0, 0, ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(link)) | 576 return 0, 0, ItemAuditor:GetItemCount(ItemAuditor:GetIDFromLink(link)) |
