diff 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
line wrap: on
line diff
--- a/Modules/Scanner.lua	Sun Feb 06 19:26:59 2011 +0100
+++ b/Modules/Scanner.lua	Sun Feb 06 19:27:20 2011 +0100
@@ -354,10 +354,11 @@
 		-- Settings
 		local trackAt = addon:GetOptionByKey(groupName, "trackAtCharacters");
 		local localItemData = addon:GetOptionByKey(groupName, "localItemData");
-		local requiredItems, bonusQueue, minCraftingQueue, isRefillEnabled;
+		local requiredItems, bonusQueue, priceThreshold, minCraftingQueue, isRefillEnabled;
 		if isRestock then
 			requiredItems = addon:GetOptionByKey(groupName, "restockTarget");
 			bonusQueue = addon:GetOptionByKey(groupName, "bonusQueue");
+			priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold");
 			minCraftingQueue = floor( addon:GetOptionByKey(groupName, "minCraftingQueue") * requiredItems ); -- If the minCraftingQueue is 5% and restockTarget is 60, this will result in 3
 		else
 			isRefillEnabled = addon:GetOptionByKey(groupName, "autoRefill");
@@ -390,16 +391,22 @@
 					end
 					
 					if missingItems > 0 and (not isRestock or missingItems >= minCraftingQueue) then
-						-- Check how many are available
-						local availableItems = ((containerItem.totalCount) or 0);
-						-- Calculate how many we'll be moving (less missing than available? use missing, otherwise use available)
-						-- -1 available items indicates unlimited amount, in that case we must cap at missing items
-						local moving = (((availableItems == -1 or missingItems <= availableItems) and missingItems) or availableItems);
+					
+						-- Get auction value when it is relevant
+						local value = (isRestock and priceThreshold ~= 0 and addon:GetAuctionValue(IdToItemLink(itemId), groupName));
 						
-						if availableItems == -1 or availableItems > 0 then
-							addon:Debug("Insufficient %s but this location has %d (moving %d)", IdToItemLink(itemId), availableItems, moving);
+						if not isRestock or priceThreshold == 0 or value == -1 or value >= priceThreshold then
+							-- Check how many are available
+							local availableItems = ((containerItem.totalCount) or 0);
+							-- Calculate how many we'll be moving (less missing than available? use missing, otherwise use available)
+							-- -1 available items indicates unlimited amount, in that case we must cap at missing items
+							local moving = (((availableItems == -1 or missingItems <= availableItems) and missingItems) or availableItems);
 							
-							Mover:AddMove(itemId, moving, missingItems, availableItems, containerItem.price);
+							if availableItems == -1 or availableItems > 0 then
+								addon:Debug("Insufficient %s but this location has %d (moving %d)", IdToItemLink(itemId), availableItems, moving);
+								
+								Mover:AddMove(itemId, moving, missingItems, availableItems, containerItem.price);
+							end
 						end
 					end
 				end