Mercurial > wow > inventory
changeset 146:ebe6f90c4bb9
Fixed IM crafting so the bonus queue isn?t reset after an item is created.
author | Zerotorescue |
---|---|
date | Thu, 20 Jan 2011 00:15:09 +0100 |
parents | 6a52272a0e5a |
children | fa909634e3b3 |
files | Modules/Queue.lua |
diffstat | 1 files changed, 41 insertions(+), 53 deletions(-) [+] |
line wrap: on
line diff
--- a/Modules/Queue.lua Thu Jan 20 00:07:47 2011 +0100 +++ b/Modules/Queue.lua Thu Jan 20 00:15:09 2011 +0100 @@ -318,9 +318,6 @@ -- Because of that we assume the average amount was made, this isn't really the best solution, but it's pretty-est - for now. if unit == "player" and currentQueueItem and spellId == currentQueueItem.craft.spellId then - -- Make sure the old amount is accurate, this won't be updated by the spell we just finished, that item hasn't been received yet - currentQueueItem.amount = mod:GetRestockAmount(currentQueueItem.itemId, currentQueueItem.groupName); - -- Decrease amount remaining by one quantity currentQueueItem.amount = ( currentQueueItem.amount - currentQueueItem.craft.quantity ); @@ -458,40 +455,59 @@ end -- Retrieve group settings + local restockTarget = addon:GetOptionByKey(groupName, "restockTarget"); + local bonusQueue = addon:GetOptionByKey(groupName, "bonusQueue"); local minCraftingQueue = floor( addon:GetOptionByKey(groupName, "minCraftingQueue") * addon:GetOptionByKey(groupName, "restockTarget") ); -- If the minCraftingQueue is 5% and restockTarget is 60, this will result in 3 local priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold"); for itemId, count in pairs(addon.db.profile.groups[groupName].items) do if craftables[itemId] then - local amount, bonus = self:GetRestockAmount(itemId, groupName); + local currentStock = addon:GetItemCount(itemId, groupName); - if amount and amount >= minCraftingQueue then - -- If we are queuing at least one AND more than the minimum amount, then proceed + if currentStock >= 0 then + -- Current stock will be -1 when no itemcount addon was found - -- Auction value settings - local value = (priceThreshold ~= 0 and addon:GetAuctionValue(IdToItemLink(itemId), groupName)); + -- Calculate the amount to be queued + local amount = ( restockTarget - currentStock ); + local bonus = 0; - if priceThreshold == 0 or value == -1 or value >= priceThreshold then - -- If no price threshold is set or the auction value is equal to or larger than the price threshold, then proceed + if currentStock == 0 and bonusQueue > 0 then + -- If we have none left and the bonus queue is enabled, modify the amount to be queued - self:Queue(itemId, amount, bonus, craftables[itemId], groupName); + bonus = floor( ( amount * ( bonusQueue ) ) + .5 ); -- round + + -- Update amount + amount = (amount + bonus); + end + + if amount >= minCraftingQueue then + -- If we are queuing at least one AND more than the minimum amount, then proceed + + -- Get auction value when it is relevant + local value = (priceThreshold ~= 0 and addon:GetAuctionValue(IdToItemLink(itemId), groupName)); + + if priceThreshold == 0 or value == -1 or value >= priceThreshold then + -- If no price threshold is set or the auction value is equal to or larger than the price threshold, then proceed + + self:Queue(itemId, amount, bonus, craftables[itemId], groupName); + else + self:Skip(itemId, skipReasons.LOW_VALUE); + --addon:Debug("%s is valued at %s while %s is needed", IdToItemLink(itemId), tostring(value), tostring(priceThreshold)); + end else - self:Skip(itemId, skipReasons.LOW_VALUE); - --addon:Debug("%s is valued at %s while %s is needed", IdToItemLink(itemId), tostring(value), tostring(priceThreshold)); + if amount <= 0 then + -- less than 0 = (over)capped + self:Skip(itemId, skipReasons.CAPPED); + else + -- more than 0 = below min crafting queue + self:Skip(itemId, skipReasons.MIN_CRAFTING_QUEUE); + end end else - if not amount then - -- nil = no item count addon - self:Skip(itemId, skipReasons.NO_ITEMCOUNT_ADDON); - addon:Print("No usable itemcount addon found."); - return; - elseif amount <= 0 then - -- less than 0 = (over)capped - self:Skip(itemId, skipReasons.CAPPED); - else - -- more than 0 = below min crafting queue - self:Skip(itemId, skipReasons.MIN_CRAFTING_QUEUE); - end + -- No item count addon + self:Skip(itemId, skipReasons.NO_ITEMCOUNT_ADDON); + addon:Print("No usable itemcount addon found."); + return; end else self:Skip(itemId, skipReasons.NOT_CRAFTABLE); @@ -499,34 +515,6 @@ end end -function mod:GetRestockAmount(itemId, groupName) - local currentStock = addon:GetItemCount(itemId, groupName); - - if currentStock >= 0 then - -- Current stock will be -1 when no itemcount addon was found - - local restockTarget = addon:GetOptionByKey(groupName, "restockTarget"); - local bonusQueue = addon:GetOptionByKey(groupName, "bonusQueue"); - - -- Calculate the amount to be queued - local amount = ( restockTarget - currentStock ); - local bonus = 0; - - if currentStock == 0 and bonusQueue > 0 then - -- If we have none left and the bonus queue is enabled, modify the amount to be queued - - bonus = floor( ( amount * ( bonusQueue ) ) + .5 ); -- round - - -- Update amount - amount = (amount + bonus); - end - - return amount, bonus; - else - return; - end -end - function mod:Queue(itemId, amount, bonus, craft, groupName) tinsert(queue, { ["itemId"] = itemId, -- needed to display the queued item in the queue window