Mercurial > wow > inventory
comparison Modules/Scanner.lua @ 218:07263a435f3c
Merchant restocking now takes the price threshold into account.
| author | Zerotorescue |
|---|---|
| date | Sun, 06 Feb 2011 19:27:20 +0100 |
| parents | 12a8ea5af671 |
| children | 24e71ed0a422 |
comparison
equal
deleted
inserted
replaced
| 217:ca05b8ade1ea | 218:07263a435f3c |
|---|---|
| 352 -- Go through all groups | 352 -- Go through all groups |
| 353 for groupName, values in pairs(addon.db.profile.groups) do | 353 for groupName, values in pairs(addon.db.profile.groups) do |
| 354 -- Settings | 354 -- Settings |
| 355 local trackAt = addon:GetOptionByKey(groupName, "trackAtCharacters"); | 355 local trackAt = addon:GetOptionByKey(groupName, "trackAtCharacters"); |
| 356 local localItemData = addon:GetOptionByKey(groupName, "localItemData"); | 356 local localItemData = addon:GetOptionByKey(groupName, "localItemData"); |
| 357 local requiredItems, bonusQueue, minCraftingQueue, isRefillEnabled; | 357 local requiredItems, bonusQueue, priceThreshold, minCraftingQueue, isRefillEnabled; |
| 358 if isRestock then | 358 if isRestock then |
| 359 requiredItems = addon:GetOptionByKey(groupName, "restockTarget"); | 359 requiredItems = addon:GetOptionByKey(groupName, "restockTarget"); |
| 360 bonusQueue = addon:GetOptionByKey(groupName, "bonusQueue"); | 360 bonusQueue = addon:GetOptionByKey(groupName, "bonusQueue"); |
| 361 priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold"); | |
| 361 minCraftingQueue = floor( addon:GetOptionByKey(groupName, "minCraftingQueue") * requiredItems ); -- If the minCraftingQueue is 5% and restockTarget is 60, this will result in 3 | 362 minCraftingQueue = floor( addon:GetOptionByKey(groupName, "minCraftingQueue") * requiredItems ); -- If the minCraftingQueue is 5% and restockTarget is 60, this will result in 3 |
| 362 else | 363 else |
| 363 isRefillEnabled = addon:GetOptionByKey(groupName, "autoRefill"); | 364 isRefillEnabled = addon:GetOptionByKey(groupName, "autoRefill"); |
| 364 requiredItems = addon:GetOptionByKey(groupName, "minLocalStock"); | 365 requiredItems = addon:GetOptionByKey(groupName, "minLocalStock"); |
| 365 end | 366 end |
| 388 | 389 |
| 389 missingItems = floor( ( missingItems * ( bonusQueue + 1 ) ) + .5 ); -- round | 390 missingItems = floor( ( missingItems * ( bonusQueue + 1 ) ) + .5 ); -- round |
| 390 end | 391 end |
| 391 | 392 |
| 392 if missingItems > 0 and (not isRestock or missingItems >= minCraftingQueue) then | 393 if missingItems > 0 and (not isRestock or missingItems >= minCraftingQueue) then |
| 393 -- Check how many are available | 394 |
| 394 local availableItems = ((containerItem.totalCount) or 0); | 395 -- Get auction value when it is relevant |
| 395 -- Calculate how many we'll be moving (less missing than available? use missing, otherwise use available) | 396 local value = (isRestock and priceThreshold ~= 0 and addon:GetAuctionValue(IdToItemLink(itemId), groupName)); |
| 396 -- -1 available items indicates unlimited amount, in that case we must cap at missing items | |
| 397 local moving = (((availableItems == -1 or missingItems <= availableItems) and missingItems) or availableItems); | |
| 398 | 397 |
| 399 if availableItems == -1 or availableItems > 0 then | 398 if not isRestock or priceThreshold == 0 or value == -1 or value >= priceThreshold then |
| 400 addon:Debug("Insufficient %s but this location has %d (moving %d)", IdToItemLink(itemId), availableItems, moving); | 399 -- Check how many are available |
| 400 local availableItems = ((containerItem.totalCount) or 0); | |
| 401 -- Calculate how many we'll be moving (less missing than available? use missing, otherwise use available) | |
| 402 -- -1 available items indicates unlimited amount, in that case we must cap at missing items | |
| 403 local moving = (((availableItems == -1 or missingItems <= availableItems) and missingItems) or availableItems); | |
| 401 | 404 |
| 402 Mover:AddMove(itemId, moving, missingItems, availableItems, containerItem.price); | 405 if availableItems == -1 or availableItems > 0 then |
| 406 addon:Debug("Insufficient %s but this location has %d (moving %d)", IdToItemLink(itemId), availableItems, moving); | |
| 407 | |
| 408 Mover:AddMove(itemId, moving, missingItems, availableItems, containerItem.price); | |
| 409 end | |
| 403 end | 410 end |
| 404 end | 411 end |
| 405 end | 412 end |
| 406 end | 413 end |
| 407 end | 414 end |
