From 347586d73260fa42be2b918fc15eadab7b1ee110 Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Sat, 26 Sep 2009 11:39:00 -0500 Subject: [PATCH] Actually calculate weights --- WeightsWatcher.lua | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua index 7cdab66..cdcd1c8 100644 --- a/WeightsWatcher.lua +++ b/WeightsWatcher.lua @@ -110,6 +110,16 @@ function WeightsWatcher:displayItemStats(tooltip, ttname) socketBonusActive = false end + for class, weights in pairs(ww_charVars.activeWeights) do + if ww_vars.weightsList[class] then + for _, weight in pairs(weights) do + if ww_vars.weightsList[class][weight] then + tooltip:AddDoubleLine(weight, WeightsWatcher:calculateWeight(normalStats, socketBonusActive, socketBonusStat, gemStats, ww_vars.weightsList[class][weight])) + end + end + end + end + tooltip:Show() end end @@ -137,6 +147,33 @@ function WeightsWatcher:matchesSocket(gemColor, socketColor) return false end +function WeightsWatcher:calculateWeight(normalStats, socketBonusActive, socketBonusStat, gemStats, weightsScale) + local weight, name, value = 0 + + for _, value in pairs(normalStats) do + weight = weight + WeightsWatcher:getWeight(value, weightsScale) + end + if socketBonusActive then + weight = weight + WeightsWatcher:getWeight(socketBonusStat, weightsScale) + end + for _, value in pairs(gemStats) do + for _, value in pairs(value[2]) do + weight = weight + WeightsWatcher:getWeight(value, weightsScale) + end + end + return weight +end + +function WeightsWatcher:getWeight(stat, weightsScale) + local name, value = unpack(stat) + name = string.lower(name) + if weightsScale[name] then + return weightsScale[name] * value + else + return 0 + end +end + function WeightsWatcher:getGemStats(...) local stats, stat, lastGem local statTable = {} -- 1.7.9.5