From ccc4aa9801d60104b5c65414b827e57b7d010c61 Mon Sep 17 00:00:00 2001 From: pschifferer Date: Tue, 24 Feb 2009 04:02:04 +0000 Subject: [PATCH] Added debugging info to figure out why some items appear blank in the queue. Wrote the code to get a potential craft count for a skill. --- CauldronMain.lua | 3 +++ CauldronMainUI.lua | 25 ++++++++++++++++++++++--- CauldronUtil.lua | 21 +++++++++++++++++---- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/CauldronMain.lua b/CauldronMain.lua index e500c50..4d9da63 100644 --- a/CauldronMain.lua +++ b/CauldronMain.lua @@ -25,6 +25,9 @@ Cauldron.libs.PT = LibStub("LibPeriodicTable-3.1"); -- Cauldron:ToggleDebugLog(false); Cauldron:SetLogLevel(Cauldron.logLevels.INFO); +--@alpha@ +Cauldron:SetLogLevel(Cauldron.logLevels.DEBUG); +--@end-alpha@ CURRENT_TRADESKILL = ""; diff --git a/CauldronMainUI.lua b/CauldronMainUI.lua index cee4aba..ff3b429 100644 --- a/CauldronMainUI.lua +++ b/CauldronMainUI.lua @@ -591,6 +591,10 @@ function Cauldron:UpdateQueue() CauldronQueueFrameScrollFrameQueueSectionsMainItems:SetHeight(#itemQueue * itemFrameHeight); for i, queueInfo in ipairs(itemQueue) do +--@alpha@ + self:debug("queueInfo: name="..queueInfo.name); +--@end-alpha@ + local queueItemFrame = _G["CauldronQueueItem"..i]; -- check if we have a frame for this position @@ -618,7 +622,7 @@ function Cauldron:UpdateQueue() local skillInfo = Cauldron:GetSkillInfo(queueInfo.tradeskill, queueInfo.name); if not skillInfo then -- the skill isn't available (character doesn't know it?) - -- TODO + self:warn("No skill available for "..queueInfo.name.." ("..queueInfo.tradeskill..")"); end -- initialize the frame object @@ -638,6 +642,7 @@ function Cauldron:UpdateQueue() end else -- TODO: default color info + self:debug("Using default color info."); end -- set quantity info @@ -695,6 +700,8 @@ function Cauldron:UpdateQueue() frame:Hide(); frame:SetHeight(0); + frame = nil; + j = j + 1; end @@ -722,6 +729,10 @@ function Cauldron:UpdateQueue() local intHeight = 0; for i, queueInfo in ipairs(intQueue) do +--@alpha@ + self:debug("intQueue: name="..queueInfo.name); +--@end-alpha@ + local queueItemFrame = _G["CauldronQueueIntItem"..i]; -- check if we have a frame for this position @@ -833,7 +844,7 @@ function Cauldron:UpdateQueue() end -- hide any remaining frames - local j = #intQueue + 1; + j = #intQueue + 1; while true do local frame = _G["CauldronQueueIntItem"..j]; if not frame then @@ -845,6 +856,8 @@ function Cauldron:UpdateQueue() frame:Hide(); frame:SetHeight(0); + frame = nil; + j = j + 1; end @@ -856,6 +869,10 @@ function Cauldron:UpdateQueue() local reagentHeight = 0; for i, queueInfo in ipairs(reagentList) do +--@alpha@ + self:debug("reagentList: "..queueInfo.name); +--@end-alpha@ + local queueItemFrame = _G["CauldronQueueReagentItem"..i]; -- check if we have a frame for this position @@ -966,7 +983,7 @@ function Cauldron:UpdateQueue() end -- hide any remaining frames - local j = #reagentList + 1; + j = #reagentList + 1; while true do local frame = _G["CauldronQueueReagentItem"..j]; if not frame then @@ -978,6 +995,8 @@ function Cauldron:UpdateQueue() frame:Hide(); frame:SetHeight(0); + frame = nil; + j = j + 1; end --]] diff --git a/CauldronUtil.lua b/CauldronUtil.lua index 37280ac..68cd2a8 100644 --- a/CauldronUtil.lua +++ b/CauldronUtil.lua @@ -14,11 +14,17 @@ function Cauldron:GetPotentialCraftCount(skillInfo) local count = 0; - -- get reagent list --- local reagents = Cauldron:GetReagentsForSkill(skillInfo); + -- iterate over the reagent list and find out how many can be made for each reagent count; + -- the lowest value is the potential amount craftable + for i,rinfo in ipairs(skillInfo.reagents) do + local counts = Cauldron:ReagentCount(rinfo.name); + local makeable = math.floor(counts.total / rinfo.numRequired); + + if (makeable > 0) and (count > 0) and (makeable < count) then + count = makeable; + end + end - -- TODO - self:debug("GetPotentialCraftCount exit"); return count; @@ -32,6 +38,7 @@ function Cauldron:ReagentCount(reagent) guildBank = 0, mail = 0, altHas = {}, + total = 0, } -- sanity checks @@ -42,6 +49,12 @@ function Cauldron:ReagentCount(reagent) count.has = GetItemCount(reagent, false); count.bank = GetItemCount(reagent, true) - count.has; + + -- total up + count.total = count.has + count.bank + count.guildBank + count.mail; + for alt,altCount in pairs(count.altHas) do + count.total = count.total + altCount; + end return count; end -- 1.7.9.5