From 6cf051a4e2149d9bd88e99b97339ac2213c8fb22 Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Wed, 26 Sep 2012 19:34:27 -0500 Subject: [PATCH] Fixed parsing of 'restores x to y z' --- Locales/enUS/patterns.lua | 3 ++- Regexps.lua | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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() -- 1.7.9.5