Quantcast

Fixed parsing of a few meta gems

Kevin Lyles [01-26-14 - 17:36]
Fixed parsing of a few meta gems
Filename
Locales/enUS/patterns-generic.lua
Locales/enUS/patterns.lua
Locales/enUS/stats.lua
Upgrade.lua
defaults.lua
diff --git a/Locales/enUS/patterns-generic.lua b/Locales/enUS/patterns-generic.lua
index a7b0152..007c87d 100644
--- a/Locales/enUS/patterns-generic.lua
+++ b/Locales/enUS/patterns-generic.lua
@@ -19,6 +19,8 @@ local GenericPreprocessLines = {
 	{" critical strike %(ranged%)", " ranged critical strike"},
 	-- items 95346 and 95347
 	{", and ", " and "},
+	-- items 95346 and 95347
+	{" crit ", " critical strike "},
 }

 local GenericAffixes = {
diff --git a/Locales/enUS/patterns.lua b/Locales/enUS/patterns.lua
index 496044e..bbc3216 100644
--- a/Locales/enUS/patterns.lua
+++ b/Locales/enUS/patterns.lua
@@ -570,7 +570,7 @@ ww_SingleStatLines = {
 		end,
 		{"generic"},
 	},
-	{"^chance on being hit to gain 20%% reduction to physical damage taken$",
+	{"^chance on being hit to gain 20%% reduction to damage taken$",
 		function(text, pattern)
 			return WeightsWatcher.newStatTable({[text] = 1})
 		end,
diff --git a/Locales/enUS/stats.lua b/Locales/enUS/stats.lua
index 0a7e649..fd6d9e7 100644
--- a/Locales/enUS/stats.lua
+++ b/Locales/enUS/stats.lua
@@ -25,7 +25,7 @@ ww_localizedStats = {
 	["block"] = "block",
 	["block value (percent)"] = "block value (percent)",
 	["blood draining"] = "blood draining",
-	["chance on being hit to gain 20% reduction to physical damage taken"] = "chance on being hit to gain 20% reduction to physical damage taken",
+	["chance on being hit to gain 20% reduction to damage taken"] = "chance on being hit to gain 20% reduction to damage taken",
 	["chance on beneficial spell to make your spells cost no mana for 4 sec."] = "chance on beneficial spell to make your spells cost no mana for 4 sec.",
 	["chance on melee or ranged hit to gain capacitance"] = "chance on melee or ranged hit to gain capacitance",
 	["chance on spell damage to gain 30% spell haste"] = "chance on spell damage to gain 30% spell haste",
@@ -179,7 +179,7 @@ ww_statDisplayNames = {
 	[ww_localizedStats["block"]] = "Block",
 	[ww_localizedStats["block value (percent)"]] = "Block Value (Percent)",
 	[ww_localizedStats["blood draining"]] = "Blood Draining",
-	[ww_localizedStats["chance on being hit to gain 20% reduction to physical damage taken"]] = "Chance on Being Hit to Gain 20% Reduction to Physical Damage Taken",
+	[ww_localizedStats["chance on being hit to gain 20% reduction to damage taken"]] = "Chance on Being Hit to Gain 20% Reduction to Damage Taken",
 	[ww_localizedStats["chance on beneficial spell to make your spells cost no mana for 4 sec."]] = "Chance on Beneficial Spell to Make Your Spells Cost no Mana for 4 sec.",
 	[ww_localizedStats["chance on melee or ranged hit to gain capacitance"]] = "Chance on Melee or Ranged Hit to Gain Capacitance",
 	[ww_localizedStats["chance on spell damage to gain 30% spell haste"]] = "Chance on Spell Damage to Gain 30% Spell Haste",
diff --git a/Upgrade.lua b/Upgrade.lua
index 5966f71..59a498b 100644
--- a/Upgrade.lua
+++ b/Upgrade.lua
@@ -36,6 +36,62 @@ local function noop_major_up(vars)
 	return vars
 end

+local function replaceStats(vars, conversions)
+	for _, class in ipairs(vars.weightsList) do
+		for _, weight in ipairs(vars.weightsList[class]) do
+			if vars.weightsList[class][weight] then
+				for oldStat, newStat in pairs(conversions) do
+					if vars.weightsList[class][weight][newStat] == nil then
+						vars.weightsList[class][weight][newStat] = vars.weightsList[class][weight][oldStat]
+					end
+					vars.weightsList[class][weight][oldStat] = nil
+				end
+			end
+		end
+	end
+end
+
+local replaceStatsStr = [[
+	local function replaceStats(vars, conversions)
+		for _, class in ipairs(vars.weightsList) do
+			for _, weight in ipairs(vars.weightsList[class]) do
+				if vars.weightsList[class][weight] then
+					for oldStat, newStat in pairs(conversions) do
+						if vars.weightsList[class][weight][newStat] == nil then
+							vars.weightsList[class][weight][newStat] = vars.weightsList[class][weight][oldStat]
+						end
+						vars.weightsList[class][weight][oldStat] = nil
+					end
+				end
+			end
+		end
+	end
+]]
+
+local function upgradeAccountToNewMetaEffects(vars)
+	local conversions = {
+		["chance on being hit to gain 20% reduction to physical damage taken"] = "chance on being hit to gain 20% reduction to damage taken",
+	}
+
+	replaceStats(vars, conversions)
+
+	vars.dataMinorVersion = 7
+	return vars
+end
+
+local downgradeAccountFromNewMetaEffects = replaceStatsStr .. [[
+	return function(vars)
+		local conversions = {
+			["chance on being hit to gain 20% reduction to damage taken"] = "chance on being hit to gain 20% reduction to physical damage taken",
+		}
+
+		replaceStats(vars, conversions)
+
+		vars.dataMinorVersion = 6
+		return vars
+	end
+]]
+
 local function upgradeAccountToReplaceEmptyOptions(vars)
 	if not vars.options then
 		vars.options = ww_deepTableCopy(ww_defaultVars.options)
@@ -1256,6 +1312,7 @@ local upgradeAccountFunctions = {
 		[3] = upgradeAccountToMoPEnhancements,
 		[4] = upgradeAccountToMonks,
 		[5] = upgradeAccountToReplaceEmptyOptions,
+		[6] = upgradeAccountToNewMetaEffects,
 	},
 }

@@ -1307,6 +1364,7 @@ local downgradeAccountFunctions = {
 		[4] = downgradeAccountFromMoPEnhancements,
 		[5] = noop_down,
 		[6] = noop_down,
+		[7] = downgradeAccountFromNewMetaEffects,
 	},
 }

diff --git a/defaults.lua b/defaults.lua
index 6f1af26..e02678f 100644
--- a/defaults.lua
+++ b/defaults.lua
@@ -82,7 +82,7 @@ ww_trackedStats = {
 			"armor from items (percent)",
 			"average damage dealt on block",
 			"block value (percent)",
-			"chance on being hit to gain 20% reduction to physical damage taken",
+			"chance on being hit to gain 20% reduction to damage taken",
 			"chance to restore health on hit",
 			"damage absorption (2% chance)",
 			"damage absorption (5% chance)",
@@ -265,7 +265,7 @@ ww_classNameOptions = {

 ww_defaultVars = {
 	dataMajorVersion = 2,
-	dataMinorVersion = 6,
+	dataMinorVersion = 7,
 	weightsList = {
 		"DEATHKNIGHT",
 		"DRUID",