Quantcast

Handle socket bonuses separately from the rest of the stats

Kevin Lyles [09-17-09 - 07:36]
Handle socket bonuses separately from the rest of the stats
Filename
Regexps.lua
WeightsWatcher.lua
diff --git a/Regexps.lua b/Regexps.lua
index bb90a8e..97ea7cf 100644
--- a/Regexps.lua
+++ b/Regexps.lua
@@ -40,6 +40,8 @@ IgnoredLines = {
 	"^Requires %a[%a ]+ %- Exalted$",
 }

+socketBonus = "^Socket Bonus: (.*)"
+
 MultipleStatLines = {
 	{" and ",
 		function(text)
diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua
index 78530bd..e694f43 100644
--- a/WeightsWatcher.lua
+++ b/WeightsWatcher.lua
@@ -68,7 +68,7 @@ end
 function WeightsWatcher:displayItemStats(tooltip, ttname)
 	local itemType, ttleft, ttright, origTextL, textL, textR, pattern, func, stat, start
 	-- Stats tables: normal stats, socket bonus, gem-given stats, current stat table
-	local normalStats, gemStats, statTable = {}, {}
+	local normalStats, socketBonusStat, gemStats, statTable = {}, {}, {}
 	local _, link = tooltip:GetItem()

 	if link == nil then
@@ -90,7 +90,15 @@ function WeightsWatcher:displayItemStats(tooltip, ttname)
 			textR = ttright:GetText()
 			textL = WeightsWatcher:preprocess(origTextL)

-			statTable = normalStats
+			-- Determine which table this line of stats should go in
+			-- TODO: add the other two types
+			start, _, value = string.find(textL, socketBonus)
+			if start then
+				textL = value
+				statTable = socketBonusStat
+			else
+				statTable = normalStats
+			end

 			matched = false
 			for _, regex in pairs(IgnoredLines) do
@@ -145,6 +153,13 @@ function WeightsWatcher:displayItemStats(tooltip, ttname)
 		for _, stat in pairs(normalStats) do
 			tooltip:AddDoubleLine(unpack(stat))
 		end
+		if #(socketBonusStat) > 0 then
+			tooltip:AddLine("Socket Bonus:")
+			for _, stat in pairs(socketBonusStat) do
+				name, value = unpack(stat)
+				tooltip:AddDoubleLine("  " .. name, value)
+			end
+		end
 		if #(gemStats) > 0 then
 			tooltip:AddLine("Gem Stats:")
 			for _, stat in pairs(gemStats) do