Quantcast

Replaced minimum weapon damage with average weapon damage

Kevin Lyles [07-25-10 - 22:34]
Replaced minimum weapon damage with average weapon damage
Added upgrade function
Filename
Regexps.lua
Upgrade.lua
WeightsWatcher.lua
defaults.lua
diff --git a/Regexps.lua b/Regexps.lua
index a50d1fd..a728d02 100644
--- a/Regexps.lua
+++ b/Regexps.lua
@@ -627,26 +627,30 @@ function WeightsWatcher.damageRange(textL, textR)
 	local start, _, minimum, maximum = string.find(textL, "^(%d+) %- (%d+) damage$")
 	if start then
 		stats = WeightsWatcher.newStatTable()
-		stats["minimum melee weapon damage"] = tonumber(minimum)
-		stats["maximum melee weapon damage"] = tonumber(maximum)
+		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$")
 		if start then
 			stats = WeightsWatcher.newStatTable()
-			stats["minimum wand " .. school .. " damage"] = tonumber(minimum)
-			stats["maximum wand " .. school .. " damage"] = tonumber(maximum)
+			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()
-				stats["minimum added " .. school .. " damage"] = tonumber(minimum)
-				stats["maximum added " .. school .. " damage"] = tonumber(maximum)
+				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()
-					stats["minimum melee weapon damage"] = tonumber(damage)
-					stats["maximum melee weapon damage"] = tonumber(damage)
+					damage = tonumber(damage)
+					stats["average melee weapon damage"] = damage
+					stats["maximum melee weapon damage"] = damage
 				end
 			end
 		end
@@ -1215,7 +1219,12 @@ ww_SingleStatLines = {
 	{"^([+-]?%d+) (ranged attack power)$", WeightsWatcher.statNumFirst, {"equipEffect", "generic"}},
 	{"^([+-]?%d+) (all stats)$", WeightsWatcher.statNumFirst, {"elixir", "enchant", "generic", "useEffect"}},
 	{"^([+-]?%d+) to (all stats)$", WeightsWatcher.statNumFirst, {"generic"}},
-	{"^([+-]?%d+) (ranged damage)$", WeightsWatcher.statNumFirst, {"enchant"}},
+	{"^([+-]?%d+) ranged damage$",
+		function(text, pattern)
+			return WeightsWatcher.singleStatValueOnly(text, pattern, "average ranged weapon damage") + WeightsWatcher.singleStatValueOnly(text, pattern, "maximum ranged weapon damage")
+		end,
+		{"enchant"},
+	},

 	{"^chance to resist (%a+) effects by (%d+)%%$",
 		function(text, pattern)
diff --git a/Upgrade.lua b/Upgrade.lua
index a87cec1..5d5f704 100644
--- a/Upgrade.lua
+++ b/Upgrade.lua
@@ -53,6 +53,42 @@ local function noop_major_up(vars)
 	return vars
 end

+local function upgradeAccountToAverageWeaponDamage(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]["minimum melee weapon damage"]
+			end
+			vars.weightsList[class][weight]["minimum melee weapon damage"] = nil
+			if vars.weightsList[class][weight]["average ranged weapon damage"] == nil then
+				vars.weightsList[class][weight]["average ranged weapon damage"] = vars.weightsList[class][weight]["minimum ranged weapon damage"]
+			end
+			vars.weightsList[class][weight]["minimum ranged weapon damage"] = nil
+		end
+	end
+
+	vars.dataMinorVersion = 17
+	return vars
+end
+
+local downgradeAccountFromAverageWeaponDamage = [[
+	return function(vars)
+		for _, class in ipairs(vars.weightsList) do
+			for _, weight in ipairs(vars.weightsList[class]) do
+				if vars.weightsList[class][weight]["minimum melee weapon damage"] == nil then
+					vars.weightsList[class][weight]["minimum melee weapon damage"] = vars.weightsList[class][weight]["average melee weapon damage"]
+				end
+				if vars.weightsList[class][weight]["minimum ranged weapon damage"] == nil then
+					vars.weightsList[class][weight]["minimum ranged weapon damage"] = vars.weightsList[class][weight]["average ranged weapon damage"]
+				end
+			end
+		end
+
+		vars.dataMinorVersion = 16
+		return vars
+	end
+]]
+
 local function upgradeAccountToMeleeStatsAndRangedWeaponDamage(vars)
 	for _, class in ipairs(vars.weightsList) do
 		for _, weight in ipairs(vars.weightsList[class]) do
@@ -886,6 +922,7 @@ local upgradeAccountFunctions = {
 		[13] = upgradeAccountToFixStunResistChance,
 		[14] = FixStunResistChance,
 		[15] = upgradeAccountToMeleeStatsAndRangedWeaponDamage,
+		[16] = upgradeAccountToAverageWeaponDamage,
 	},
 }

@@ -919,6 +956,7 @@ local downgradeAccountFunctions = {
 		[14] = downgradeAccountFromFixStunResistChance,
 		[15] = noop_down,
 		[16] = downgradeAccountFromMeleeStatsAndRangedWeaponDamage,
+		[17] = downgradeAccountFromAverageWeaponDamage,
 	},
 }

diff --git a/WeightsWatcher.lua b/WeightsWatcher.lua
index bf414c7..16eab61 100644
--- a/WeightsWatcher.lua
+++ b/WeightsWatcher.lua
@@ -1033,8 +1033,8 @@ end

 local rangedConversions = {
 	["melee dps"] = "ranged dps",
+	["average melee weapon damage"] = "average ranged weapon damage",
 	["maximum melee weapon damage"] = "maximum ranged weapon damage",
-	["minimum melee weapon damage"] = "minimum ranged weapon damage",
 	["melee weapon speed"] = "ranged weapon speed",
 }

diff --git a/defaults.lua b/defaults.lua
index 2dc83e4..fb12962 100644
--- a/defaults.lua
+++ b/defaults.lua
@@ -32,7 +32,7 @@ ww_trackedStats = {
 		"Armor Penetration Rating",
 		"Expertise Rating",
 		"Melee DPS",
-		"Minimum Melee Weapon Damage",
+		"Average Melee Weapon Damage",
 		"Maximum Melee Weapon Damage",
 		"Melee Weapon Speed",
 	},
@@ -53,7 +53,7 @@ ww_trackedStats = {
 	["Ranged"] = {
 		"Ranged Attack Power",
 		"Ranged DPS",
-		"Minimum Ranged Weapon Damage",
+		"Average Ranged Weapon Damage",
 		"Maximum Ranged Weapon Damage",
 		"Ranged Weapon Speed",
 	},
@@ -239,7 +239,7 @@ ww_classNameOptions = {

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