Quantcast

Converted all schooled damage on weapons and melee and physical damage to regular weapon damage

Kevin Lyles [07-26-10 - 13:27]
Converted all schooled damage on weapons and melee and physical damage to regular weapon damage
Added an upgrade function
Filename
GemIds.lua
Regexps.lua
Upgrade.lua
defaults.lua
diff --git a/GemIds.lua b/GemIds.lua
index bd3b8ed..331928d 100644
--- a/GemIds.lua
+++ b/GemIds.lua
@@ -455,7 +455,7 @@ ww_gems = {
 				[2834] = {
 					"meta",
 					"Brutal Earthstorm Diamond",
-					{["melee damage"] = 3, ["chance to stun target"] = 1},
+					{["average melee weapon damage"] = 3, ["maximum melee weapon damage"] = 3, ["chance to stun target"] = 1},
 				},
 				[2835] = {
 					"meta",
diff --git a/Regexps.lua b/Regexps.lua
index 3af84f4..ac1ee58 100644
--- a/Regexps.lua
+++ b/Regexps.lua
@@ -624,35 +624,19 @@ end

 function WeightsWatcher.damageRange(textL, textR)
 	local stats
-	local start, _, minimum, maximum = string.find(textL, "^(%d+) %- (%d+) damage$")
+	local start, _, minimum, maximum = string.find(textL, "^%+?(%d+) %- (%d+) %a* ?damage$")
 	if start then
 		stats = WeightsWatcher.newStatTable()
 		maximum = tonumber(maximum)
 		stats["average melee weapon damage"] = (minimum + maximum) / 2
 		stats["maximum melee weapon damage"] = maximum
 	else
-		local start, _, minimum, maximum, school = string.find(textL, "^(%d+) %- (%d+) (%a+) damage$")
+		local start, _, damage = string.find(textL, "^(%d+) damage$")
 		if start then
 			stats = WeightsWatcher.newStatTable()
-			maximum = tonumber(maximum)
-			stats["average wand " .. school .. " damage"] = (minimum + maximum) / 2
-			stats["maximum wand " .. school .. " damage"] = maximum
-		else
-			local start, _, minimum, maximum, school = string.find(textL, "^%+(%d+) %- (%d+) (%a+) damage$")
-			if start then
-				stats = WeightsWatcher.newStatTable()
-				maximum = tonumber(maximum)
-				stats["average added " .. school .. " damage"] = (minimum + maximum) / 2
-				stats["maximum added " .. school .. " damage"] = maximum
-			else
-				local start, _, damage = string.find(textL, "^(%d+) damage$")
-				if start then
-					stats = WeightsWatcher.newStatTable()
-					damage = tonumber(damage)
-					stats["average melee weapon damage"] = damage
-					stats["maximum melee weapon damage"] = damage
-				end
-			end
+			damage = tonumber(damage)
+			stats["average melee weapon damage"] = damage
+			stats["maximum melee weapon damage"] = damage
 		end
 	end
 	if stats and textR then
@@ -1334,7 +1318,18 @@ ww_SingleStatLines = {
 		end,
 		{"generic"},
 	},
-	{"^([+-]?%d+) (%a+ damage)$", WeightsWatcher.statNumFirst, {"enchant", "generic"}},
+	{"^([+-]?%d+) melee damage$",
+		function(text, pattern)
+			return WeightsWatcher.singleStatValueOnly(text, pattern, "average melee weapon damage") + WeightsWatcher.singleStatValueOnly(text, pattern, "maximum melee weapon damage")
+		end,
+		{"enchant", "generic"},
+	},
+	{"^([+-]?%d+) physical damage$",
+		function(text, pattern)
+			return WeightsWatcher.singleStatValueOnly(text, pattern, "average melee weapon damage") + WeightsWatcher.singleStatValueOnly(text, pattern, "maximum melee weapon damage") + WeightsWatcher.singleStatValueOnly(text, pattern, "average ranged weapon damage") + WeightsWatcher.singleStatValueOnly(text, pattern, "maximum ranged weapon damage")
+		end,
+		{"enchant"},
+	},
 	{"^minor run speed increase$",
 		function(text, pattern)
 			return WeightsWatcher.newStatTable({["minor run speed"] = 1})
diff --git a/Upgrade.lua b/Upgrade.lua
index 5d5f704..594530d 100644
--- a/Upgrade.lua
+++ b/Upgrade.lua
@@ -53,6 +53,23 @@ local function noop_major_up(vars)
 	return vars
 end

+local function upgradeAccountToNoMeleeDamage(vars)
+	for _, class in ipairs(vars.weightsList) do
+		for _, weight in ipairs(vars.weightsList[class]) do
+			if vars.weightsList[class][weight]["average melee weapon damage"] == nil then
+				vars.weightsList[class][weight]["average melee weapon damage"] = vars.weightsList[class][weight]["melee damage"]
+			end
+			if vars.weightsList[class][weight]["maximum melee weapon damage"] == nil then
+				vars.weightsList[class][weight]["maximum melee weapon damage"] = vars.weightsList[class][weight]["melee damage"]
+			end
+			vars.weightsList[class][weight]["melee damage"] = nil
+		end
+	end
+
+	vars.dataMinorVersion = 18
+	return vars
+end
+
 local function upgradeAccountToAverageWeaponDamage(vars)
 	for _, class in ipairs(vars.weightsList) do
 		for _, weight in ipairs(vars.weightsList[class]) do
@@ -923,6 +940,7 @@ local upgradeAccountFunctions = {
 		[14] = FixStunResistChance,
 		[15] = upgradeAccountToMeleeStatsAndRangedWeaponDamage,
 		[16] = upgradeAccountToAverageWeaponDamage,
+		[17] = upgradeAccountToNoMeleeDamage,
 	},
 }

@@ -957,6 +975,7 @@ local downgradeAccountFunctions = {
 		[15] = noop_down,
 		[16] = downgradeAccountFromMeleeStatsAndRangedWeaponDamage,
 		[17] = downgradeAccountFromAverageWeaponDamage,
+		[18] = noop_down,
 	},
 }

diff --git a/defaults.lua b/defaults.lua
index fb12962..5e02929 100644
--- a/defaults.lua
+++ b/defaults.lua
@@ -71,7 +71,6 @@ ww_trackedStats = {
 		"Fear Duration Reduction (Percent)",
 		"Intellect (Percent)",
 		"Mana (Percent)",
-		"Melee Damage",
 		"Minor Run Speed",
 		"Silence Duration Reduction (Percent)",
 		"Snare/Root Duration Reduction (Percent)",
@@ -239,7 +238,7 @@ ww_classNameOptions = {

 ww_defaultVars = {
 	dataMajorVersion = 1,
-	dataMinorVersion = 17,
+	dataMinorVersion = 18,
 	weightsList = {
 		"DEATHKNIGHT",
 		"DRUID",