Quantcast

Fixed parsing of 'restores x to y z'

Kevin Lyles [09-27-12 - 00:34]
Fixed parsing of 'restores x to y z'
Filename
Locales/enUS/patterns.lua
Regexps.lua
diff --git a/Locales/enUS/patterns.lua b/Locales/enUS/patterns.lua
index 3b29dd8..085af87 100644
--- a/Locales/enUS/patterns.lua
+++ b/Locales/enUS/patterns.lua
@@ -138,7 +138,7 @@ ww_TempIgnoredLines = {
 	"^use: restores %d+ to %d+ %a+ over ",
 	"^use: restores %d+ to %d+ %a+ and ",
 	"^use: restores %d+ to %d+ %a+ every .* for ",
-	"^use: restores %d+ to %d+ %a+.[^0-9]*$",
+--	"^use: restores %d+ to %d+ %a+.[^0-9]*$",
 	"^use: teaches .* %(rank %d+%)%.$",
 	"^%d+ slot ",
 	"^use: heals %d+ damage over %d+ sec%.$",
@@ -362,6 +362,7 @@ ww_SingleStatLines = {
 	},
 	{"^([+-]?%d+) (ranged attack power)$", WeightsWatcher.statNumFirst, {"equipEffect", "generic"}},
 	{"^([+-]?%d+) (health)$", WeightsWatcher.statNumFirst, {"cooldownUseEffect", "elixir", "enchant", "useEffect"}},
+	{"^(%d+) to (%d+) (health)$", WeightsWatcher.statRangeFirst, {"cooldownUseEffect", "elixir", "enchant", "useEffect"}},
 	{"^(fishing) by ([+-]?%d+)$", WeightsWatcher.statNameFirst, {"enchant", "fishing"}},
 	{"^([+-]?%d+) (all stats)$", WeightsWatcher.statNumFirst, {"cooldownUseEffect", "elixir", "enchant", "food", "generic", "useEffect"}},
 	{"^(%a+ spell )power by ([+-]?%d+)$",
diff --git a/Regexps.lua b/Regexps.lua
index 447e0a3..ebb47c6 100644
--- a/Regexps.lua
+++ b/Regexps.lua
@@ -159,6 +159,13 @@ function WeightsWatcher.statNameFirst(text, pattern)
 	end
 end

+function WeightsWatcher.statRangeFirst(text, pattern)
+	local start, _, minValue, maxValue, name = string.find(text, pattern)
+	if start then
+		return WeightsWatcher.newStatTable({[name] = (tonumber(minValue) + tonumber(maxValue)) / 2})
+	end
+end
+
 local normalStatsMetatable = {
 	-- Allows us to skip the nil check
 	__index = function()