From 73ec2f83adda8d917ed1b3376adf3993bc32e92c Mon Sep 17 00:00:00 2001 From: Kevin Lyles Date: Sun, 1 Jul 2012 22:26:32 -0500 Subject: [PATCH] Added upgrade function to convert existing weights to the new stats --- Upgrade.lua | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ defaults.lua | 2 +- 2 files changed, 69 insertions(+), 1 deletion(-) diff --git a/Upgrade.lua b/Upgrade.lua index e02aa14..c380d65 100644 --- a/Upgrade.lua +++ b/Upgrade.lua @@ -36,6 +36,72 @@ local function noop_major_up(vars) return vars end +local function upgradeAccountToMoPStats(vars) + local stats = { + "critical strike", + "dodge", + "expertise", + "haste", + "hit", + "mastery", + "parry", + "ranged critical strike", + "ranged haste", + "ranged hit", + "resilience", + "spell critical strike", + "spell hit" + } + + for _, class in ipairs(vars.weightsList) do + for _, weight in ipairs(vars.weightsList[class]) do + for _, stat in ipairs(stats) do + if vars.weightsList[class][weight][stat] == nil then + vars.weightsList[class][weight][stat] = vars.weightsList[class][weight][stat .. " rating"] + end + vars.weightsList[class][weight][stat .. " rating"] = nil + end + end + end + + vars.dataMinorVersion = 2 + return vars +end + +local downgradeAccountFromMoPStats = [[ + return function(vars) + local stats = { + "critical strike", + "dodge", + "expertise", + "haste", + "hit", + "mastery", + "parry", + "ranged critical strike", + "ranged haste", + "ranged hit", + "resilience", + "spell critical strike", + "spell hit" + } + + for _, class in ipairs(vars.weightsList) do + for _, weight in ipairs(vars.weightsList[class]) do + for _, stat in ipairs(stats) do + if vars.weightsList[class][weight][stat .. " rating"] == nil then + vars.weightsList[class][weight][stat .. " rating"] = vars.weightsList[class][weight][stat] + end + vars.weightsList[class][weight][stat] = nil + end + end + end + + vars.dataMinorVersion = 1 + return vars + end +]] + local function upgradeAccountToCriticalEffect(vars) for _, class in ipairs(vars.weightsList) do for _, weight in ipairs(vars.weightsList[class]) do @@ -1112,6 +1178,7 @@ local upgradeAccountFunctions = { }, [2] = { [0] = upgradeAccountToCriticalEffect, + [1] = upgradeAccountToMoPStats, }, } @@ -1158,6 +1225,7 @@ local downgradeAccountFunctions = { [2] = { [0] = downgradeAccountFromEnchants, [1] = noop_down, + [2] = downgradeAccountFromMoPStats, }, } diff --git a/defaults.lua b/defaults.lua index b5dea95..5386423 100644 --- a/defaults.lua +++ b/defaults.lua @@ -242,7 +242,7 @@ ww_classNameOptions = { ww_defaultVars = { dataMajorVersion = 2, - dataMinorVersion = 1, + dataMinorVersion = 2, weightsList = { "DEATHKNIGHT", "DRUID", -- 1.7.9.5