local addonName, addon = ...
---@class StatLogic
local StatLogic = LibStub:GetLibrary(addonName)

-- 3.1.0
-- Haste Rating: Shamans, Paladins, Druids, and Death Knights now receive 30% more melee haste from Haste Rating.
StatLogic.ExtraHasteClasses["PALADIN"] = true
StatLogic.ExtraHasteClasses["DEATHKNIGHT"] = true
StatLogic.ExtraHasteClasses["SHAMAN"] = true
StatLogic.ExtraHasteClasses["DRUID"] = true
local extraHaste = StatLogic.ExtraHasteClasses[addon.class] and 1.3 or 1

-- Level 60 rating base
StatLogic.RatingBase = {
	[StatLogic.Stats.DefenseRating] = 1.5,
	[StatLogic.Stats.DodgeRating] = 13.8,
	[StatLogic.Stats.ParryRating] = 13.8,
	[StatLogic.Stats.BlockRating] = 5,
	[StatLogic.Stats.MeleeHitRating] = 10,
	[StatLogic.Stats.RangedHitRating] = 10,
	[StatLogic.Stats.SpellHitRating] = 8,
	[StatLogic.Stats.MeleeCritRating] = 14,
	[StatLogic.Stats.RangedCritRating] = 14,
	[StatLogic.Stats.SpellCritRating] = 14,
	[StatLogic.Stats.ResilienceRating] = 28.75,
	[StatLogic.Stats.MeleeHasteRating] = 10 / extraHaste,
	[StatLogic.Stats.RangedHasteRating] = 10,
	[StatLogic.Stats.SpellHasteRating] = 10,
	[StatLogic.Stats.ExpertiseRating] = 2.5,
	[StatLogic.Stats.ArmorPenetrationRating] = 4.69512176513672 / 1.1,
}

StatLogic.GenericStatMap[StatLogic.Stats.HitRating] = {
	StatLogic.Stats.MeleeHitRating,
	StatLogic.Stats.RangedHitRating,
	StatLogic.Stats.SpellHitRating,
}
StatLogic.GenericStatMap[StatLogic.Stats.CritRating] = {
	StatLogic.Stats.MeleeCritRating,
	StatLogic.Stats.RangedCritRating,
	StatLogic.Stats.SpellCritRating,
}
StatLogic.GenericStatMap[StatLogic.Stats.HasteRating] = {
	StatLogic.Stats.MeleeHasteRating,
	StatLogic.Stats.RangedHasteRating,
	StatLogic.Stats.SpellHasteRating,
}

-- Extracted from the client at GameTables/RegenMPPerSpt.txt via wow.tools.local
local BaseManaRegenPerSpi = {
	0.062937, 0.056900, 0.051488, 0.046267, 0.041637, 0.037784, 0.034309, 0.031172, 0.028158, 0.025460,
	0.022654, 0.019904, 0.017817, 0.015771, 0.014008, 0.013650, 0.013175, 0.012832, 0.012475, 0.012073,
	0.011840, 0.011494, 0.011292, 0.010990, 0.010761, 0.010546, 0.010321, 0.010151, 0.009949, 0.009740,
	0.009597, 0.009425, 0.009278, 0.009123, 0.008974, 0.008847, 0.008698, 0.008581, 0.008457, 0.008338,
	0.008235, 0.008113, 0.008018, 0.007906, 0.007798, 0.007713, 0.007612, 0.007524, 0.007430, 0.007340,
	0.007268, 0.007184, 0.007116, 0.007029, 0.006945, 0.006884, 0.006805, 0.006747, 0.006667, 0.006600,
	0.006421, 0.006314, 0.006175, 0.006072, 0.005981, 0.005885, 0.005791, 0.005732, 0.005668, 0.005596,
	0.005316, 0.005049, 0.004796, 0.004555, 0.004327, 0.004110, 0.003903, 0.003708, 0.003522, 0.003345,
}

local NormalManaRegenPerSpi = function(level)
	local _, int = UnitStat("player", LE_UNIT_STAT_INTELLECT)
	local _, spi = UnitStat("player", LE_UNIT_STAT_SPIRIT)
	return (0.001 / spi + BaseManaRegenPerSpi[level] * (int ^ 0.5)) * 5
end

local NormalManaRegenPerInt = function(level)
	local _, int = UnitStat("player", LE_UNIT_STAT_INTELLECT)
	local _, spi = UnitStat("player", LE_UNIT_STAT_SPIRIT)
	-- Derivative of regen with respect to int
	return (spi * BaseManaRegenPerSpi[level] / (2 * (int ^ 0.5))) * 5
end

-- Extracted from the client at GameTables/OCTRegenHP.txt via wow.tools.local
local BaseHealthRegenPerSpi = {
	["WARRIOR"] = {
		0.394737, 0.462264, 0.474862, 0.515375, 0.521857, 0.533258, 0.520401, 0.509427, 0.500415, 0.462648,
		0.488835, 0.486706, 0.449973, 0.450681, 0.454545, 0.454545, 0.454545, 0.500000, 0.500000, 0.500000,
		0.500000, 0.500000, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556,
		0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556,
		0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000,
		0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000,
		0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000,
		0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000,
	},
	["PALADIN"] = {
		0.277778, 0.301476, 0.328751, 0.320368, 0.313114, 0.316622, 0.302168, 0.298629, 0.276091, 0.255254,
		0.253470, 0.243353, 0.243736, 0.225340, 0.208333, 0.208333, 0.208333, 0.217391, 0.217391, 0.217391,
		0.217391, 0.217391, 0.217391, 0.227273, 0.227273, 0.227273, 0.227273, 0.238095, 0.238095, 0.238095,
		0.238095, 0.238095, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000, 0.250000,
		0.250000, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158,
		0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158,
		0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158,
		0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158, 0.263158,
	},
	["HUNTER"] = {
		0.267857, 0.288915, 0.312714, 0.311937, 0.313114, 0.297997, 0.302168, 0.279363, 0.266888, 0.255254,
		0.235989, 0.218179, 0.208916, 0.193149, 0.178571, 0.178571, 0.178571, 0.178571, 0.178571, 0.178571,
		0.178571, 0.178571, 0.178571, 0.178571, 0.178571, 0.185185, 0.185185, 0.185185, 0.185185, 0.185185,
		0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308,
		0.192308, 0.192308, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000,
		0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000,
		0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000,
		0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000, 0.200000,
	},
	["ROGUE"] = {
		0.365854, 0.420240, 0.442113, 0.455908, 0.476478, 0.460541, 0.468361, 0.455803, 0.421402, 0.411242,
		0.402570, 0.372187, 0.365603, 0.338010, 0.312500, 0.333333, 0.333333, 0.333333, 0.333333, 0.333333,
		0.333333, 0.333333, 0.333333, 0.333333, 0.333333, 0.333333, 0.333333, 0.333333, 0.333333, 0.333333,
		0.333333, 0.333333, 0.333333, 0.333333, 0.333333, 0.333333, 0.333333, 0.333333, 0.333333, 0.333333,
		0.333333, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143,
		0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143,
		0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143,
		0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143, 0.357143,
	},
	["PRIEST"] = {
		0.357143, 0.355588, 0.337402, 0.311937, 0.288395, 0.266629, 0.246506, 0.227901, 0.210701, 0.194799,
		0.180097, 0.166505, 0.153938, 0.142320, 0.131579, 0.131579, 0.131579, 0.131579, 0.131579, 0.131579,
		0.131579, 0.131579, 0.131579, 0.142857, 0.142857, 0.142857, 0.142857, 0.142857, 0.142857, 0.142857,
		0.142857, 0.142857, 0.142857, 0.142857, 0.142857, 0.166667, 0.166667, 0.166667, 0.166667, 0.166667,
		0.166667, 0.166667, 0.166667, 0.166667, 0.166667, 0.166667, 0.172414, 0.178571, 0.178571, 0.178571,
		0.178571, 0.178571, 0.178571, 0.178571, 0.178571, 0.178571, 0.178571, 0.178571, 0.178571, 0.192308,
		0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308,
		0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308, 0.192308,
	},
	["DEATHKNIGHT"] = {
		0.394737, 0.462264, 0.474862, 0.515375, 0.521857, 0.533258, 0.520401, 0.509427, 0.500415, 0.462648,
		0.488835, 0.486706, 0.449973, 0.450681, 0.454545, 0.454545, 0.454545, 0.500000, 0.500000, 0.500000,
		0.500000, 0.500000, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556,
		0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.555556,
		0.555556, 0.555556, 0.555556, 0.555556, 0.555556, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000,
		0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000,
		0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000,
		0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000, 0.625000,
	},
	["SHAMAN"] = {
		0.258621, 0.277358, 0.284917, 0.289113, 0.281000, 0.273835, 0.260201, 0.240563, 0.222407, 0.205621,
		0.190103, 0.175755, 0.162490, 0.150227, 0.138889, 0.138889, 0.142857, 0.147059, 0.151515, 0.151515,
		0.151515, 0.156250, 0.156250, 0.156250, 0.156250, 0.156250, 0.161290, 0.161290, 0.161290, 0.166667,
		0.166667, 0.166667, 0.166667, 0.166667, 0.166667, 0.166667, 0.172414, 0.172414, 0.172414, 0.172414,
		0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414,
		0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414,
		0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414,
		0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414, 0.172414,
	},
	["MAGE"] = {
		0.238095, 0.252144, 0.261659, 0.241911, 0.223653, 0.206773, 0.191168, 0.176740, 0.163401, 0.151069,
		0.139667, 0.129126, 0.119381, 0.110371, 0.102041, 0.102041, 0.102041, 0.102041, 0.102041, 0.102041,
		0.102041, 0.102041, 0.102041, 0.102041, 0.102041, 0.102041, 0.102041, 0.102041, 0.102041, 0.102041,
		0.102041, 0.102041, 0.102041, 0.102041, 0.104167, 0.104167, 0.104167, 0.104167, 0.106383, 0.106383,
		0.106383, 0.108696, 0.108696, 0.108696, 0.108696, 0.108696, 0.111111, 0.111111, 0.111111, 0.113636,
		0.113636, 0.113636, 0.116279, 0.116279, 0.116279, 0.116279, 0.119048, 0.119048, 0.119048, 0.119048,
		0.121951, 0.121951, 0.121951, 0.121951, 0.121951, 0.121951, 0.121951, 0.121951, 0.121951, 0.121951,
		0.121951, 0.121951, 0.121951, 0.121951, 0.121951, 0.121951, 0.121951, 0.121951, 0.121951, 0.121951,
	},
	["WARLOCK"] = {
		0.241935, 0.256813, 0.261659, 0.263414, 0.249068, 0.230270, 0.212891, 0.196824, 0.181969, 0.168236,
		0.155538, 0.143800, 0.132947, 0.122913, 0.113636, 0.113636, 0.113636, 0.113636, 0.113636, 0.113636,
		0.113636, 0.113636, 0.113636, 0.113636, 0.113636, 0.113636, 0.113636, 0.113636, 0.113636, 0.113636,
		0.113636, 0.116279, 0.116279, 0.116279, 0.116279, 0.116279, 0.116279, 0.116279, 0.116279, 0.119048,
		0.119048, 0.119048, 0.119048, 0.119048, 0.119048, 0.121951, 0.121951, 0.121951, 0.121951, 0.121951,
		0.125000, 0.125000, 0.125000, 0.125000, 0.125000, 0.125000, 0.125000, 0.128205, 0.128205, 0.128205,
		0.128205, 0.128205, 0.128205, 0.128205, 0.128205, 0.128205, 0.128205, 0.128205, 0.128205, 0.128205,
		0.128205, 0.128205, 0.128205, 0.128205, 0.128205, 0.128205, 0.128205, 0.128205, 0.128205, 0.128205,
	},
	["DRUID"] = {
		0.245902, 0.266691, 0.278723, 0.282229, 0.273975, 0.266629, 0.246506, 0.227901, 0.210701, 0.194799,
		0.180097, 0.166505, 0.153938, 0.142320, 0.131579, 0.131579, 0.131579, 0.131579, 0.131579, 0.131579,
		0.131579, 0.135135, 0.135135, 0.135135, 0.135135, 0.135135, 0.135135, 0.135135, 0.135135, 0.135135,
		0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889,
		0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889,
		0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889,
		0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889,
		0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889, 0.138889,
	},
}

-- Patch 3.3.0:
-- Health and Mana Regeneration: These regeneration rates have been increased by up to 200% for low level characters.
-- As a player's level increases, the regeneration rates gradually reduce, returning to normal rates at level 15.
-- Extracted from the client at GameTables/RegenHPPerSpt.txt via wow.tools.local
local HealthRegenPerSpi = {
	["WARRIOR"] = {
		1.50000, 1.38679, 1.28212, 1.18536, 1.09590, 1.01319, 0.93672, 0.86602, 0.80066, 0.74023,
		0.68436, 0.63271, 0.58496, 0.54081, 0.50000,
	},
	["PALADIN"] = {
		0.37500, 0.34669, 0.32053, 0.29634, 0.27397, 0.25329, 0.23418, 0.21650, 0.20016, 0.18505,
		0.17109, 0.15818, 0.14624, 0.13520, 0.12500,
	},
	["HUNTER"] = {
		0.37500, 0.34669, 0.32053, 0.29634, 0.27397, 0.25329, 0.23418, 0.21650, 0.20016, 0.18505,
		0.17109, 0.15818, 0.14624, 0.13520, 0.12500,
	},
	["ROGUE"] = {
		1.00000, 0.92452, 0.85475, 0.79024, 0.73060, 0.67546, 0.62448, 0.57735, 0.53377, 0.49349,
		0.45624, 0.42181, 0.38997, 0.36054, 0.333333,
	},
	["PRIEST"] = {
		0.12500, 0.11556, 0.10684, 0.09878, 0.09132, 0.08443, 0.07806, 0.07216, 0.06672, 0.06168,
		0.05703, 0.05272, 0.04874, 0.04506, 0.041667,
	},
	["DEATHKNIGHT"] = {
		1.50000, 1.38679, 1.28212, 1.18536, 1.09590, 1.01319, 0.93672, 0.86602, 0.80066, 0.74023,
		0.68436, 0.63271, 0.58496, 0.54081, 0.50000,
	},
	["SHAMAN"] = {
		0.21428, 0.19811, 0.18316, 0.16933, 0.15655, 0.14474, 0.13381, 0.12371, 0.11438, 0.10574,
		0.09776, 0.09038, 0.08356, 0.07726, 0.071429,
	},
	["MAGE"] = {
		0.12500, 0.11556, 0.10684, 0.09878, 0.09132, 0.08443, 0.07806, 0.07216, 0.06672, 0.06168,
		0.05703, 0.05272, 0.04874, 0.04506, 0.041667,
	},
	["WARLOCK"] = {
		0.13636, 0.12607, 0.11655, 0.10776, 0.09962, 0.09210, 0.08515, 0.07873, 0.07278, 0.06729,
		0.06221, 0.05752, 0.05317, 0.04916, 0.045455,
	},
	["DRUID"] = {
		0.18750, 0.17334, 0.16026, 0.14817, 0.13698, 0.12664, 0.11709, 0.10825, 0.10008, 0.09253,
		0.08554, 0.07909, 0.07312, 0.06760, 0.06250,
	},
}

-- See patch note above; the values are the same for all levels 15 and up
for _, v in pairs(HealthRegenPerSpi) do
	setmetatable(v, {
		__index = function()
			return v[#v]
		end
	})
end

local function NormalHealthRegenPerSpi(level)
	local _, spi = UnitStat("player", LE_UNIT_STAT_SPIRIT)
	local data = HealthRegenPerSpi
	if spi < 50 then
		data = BaseHealthRegenPerSpi
	end
	return data[addon.class][level] * 5
end

-- Numbers reverse engineered by Whitetooth (hotdogee [at] gmail [dot] com)
addon.CritPerAgi = {
	["WARRIOR"] = {
		0.2587, 0.2264, 0.2264, 0.2264, 0.2264, 0.2012, 0.2012, 0.2012, 0.2012, 0.2012,
		0.1811, 0.1811, 0.1646, 0.1646, 0.1509, 0.1509, 0.1509, 0.1393, 0.1393, 0.1293,
		0.1293, 0.1293, 0.1207, 0.1132, 0.1132, 0.1065, 0.1065, 0.1006, 0.1006, 0.0953,
		0.0953, 0.0905, 0.0905, 0.0862, 0.0862, 0.0823, 0.0823, 0.0787, 0.0787, 0.0755,
		0.0724, 0.0724, 0.0696, 0.0696, 0.0671, 0.0671, 0.0647, 0.0624, 0.0624, 0.0604,
		0.0604, 0.0584, 0.0566, 0.0566, 0.0549, 0.0549, 0.0533, 0.0517, 0.0517, 0.0503,
		0.0477, 0.0453, 0.0431, 0.0421, 0.0402, 0.0385, 0.0370, 0.0355, 0.0342, 0.0335,
		0.0312, 0.0287, 0.0266, 0.0248, 0.0232, 0.0216, 0.0199, 0.0185, 0.0172, 0.0160,
	},
	["PALADIN"] = {
		0.2164, 0.2164, 0.2164, 0.1924, 0.1924, 0.1924, 0.1924, 0.1732, 0.1732, 0.1732,
		0.1732, 0.1732, 0.1574, 0.1574, 0.1443, 0.1443, 0.1443, 0.1332, 0.1332, 0.1237,
		0.1237, 0.1237, 0.1154, 0.1082, 0.1082, 0.1082, 0.1019, 0.1019, 0.0962, 0.0962,
		0.0911, 0.0911, 0.0866, 0.0866, 0.0825, 0.0825, 0.0825, 0.0787, 0.0787, 0.0753,
		0.0753, 0.0753, 0.0721, 0.0693, 0.0693, 0.0666, 0.0666, 0.0641, 0.0641, 0.0618,
		0.0597, 0.0597, 0.0577, 0.0577, 0.0559, 0.0559, 0.0541, 0.0525, 0.0525, 0.0509,
		0.0495, 0.0481, 0.0468, 0.0456, 0.0444, 0.0444, 0.0422, 0.0422, 0.0412, 0.0403,
		0.0368, 0.0346, 0.0321, 0.0299, 0.0275, 0.0258, 0.0240, 0.0222, 0.0206, 0.0192,
	},
	["HUNTER"] = {
		0.2840, 0.2834, 0.2711, 0.2530, 0.2430, 0.2337, 0.2251, 0.2171, 0.2051, 0.1984,
		0.1848, 0.1670, 0.1547, 0.1441, 0.1330, 0.1267, 0.1194, 0.1117, 0.1060, 0.0998,
		0.0962, 0.0910, 0.0872, 0.0829, 0.0797, 0.0767, 0.0734, 0.0709, 0.0680, 0.0654,
		0.0637, 0.0614, 0.0592, 0.0575, 0.0556, 0.0541, 0.0524, 0.0508, 0.0493, 0.0481,
		0.0470, 0.0457, 0.0444, 0.0433, 0.0421, 0.0413, 0.0402, 0.0391, 0.0382, 0.0373,
		0.0366, 0.0358, 0.0350, 0.0341, 0.0334, 0.0328, 0.0321, 0.0314, 0.0307, 0.0301,
		0.0297, 0.0290, 0.0284, 0.0279, 0.0273, 0.0270, 0.0264, 0.0259, 0.0254, 0.0250,
		0.0232, 0.0216, 0.0201, 0.0187, 0.0173, 0.0161, 0.0150, 0.0139, 0.0129, 0.0120,
	},
	["ROGUE"] = {
		0.4476, 0.4290, 0.4118, 0.3813, 0.3677, 0.3550, 0.3321, 0.3217, 0.3120, 0.2941,
		0.2640, 0.2394, 0.2145, 0.1980, 0.1775, 0.1660, 0.1560, 0.1450, 0.1355, 0.1271,
		0.1197, 0.1144, 0.1084, 0.1040, 0.0980, 0.0936, 0.0903, 0.0865, 0.0830, 0.0792,
		0.0768, 0.0741, 0.0715, 0.0691, 0.0664, 0.0643, 0.0628, 0.0609, 0.0592, 0.0572,
		0.0556, 0.0542, 0.0528, 0.0512, 0.0497, 0.0486, 0.0474, 0.0464, 0.0454, 0.0440,
		0.0431, 0.0422, 0.0412, 0.0404, 0.0394, 0.0386, 0.0378, 0.0370, 0.0364, 0.0355,
		0.0334, 0.0322, 0.0307, 0.0296, 0.0286, 0.0276, 0.0268, 0.0262, 0.0256, 0.0250,
		0.0232, 0.0216, 0.0201, 0.0187, 0.0173, 0.0161, 0.0150, 0.0139, 0.0129, 0.0120,
	},
	["PRIEST"] = {
		0.0912, 0.0912, 0.0912, 0.0868, 0.0868, 0.0868, 0.0868, 0.0829, 0.0829, 0.0829,
		0.0829, 0.0793, 0.0793, 0.0793, 0.0793, 0.0760, 0.0760, 0.0760, 0.0729, 0.0729,
		0.0729, 0.0729, 0.0701, 0.0701, 0.0701, 0.0675, 0.0675, 0.0675, 0.0651, 0.0651,
		0.0651, 0.0629, 0.0629, 0.0629, 0.0608, 0.0608, 0.0608, 0.0588, 0.0588, 0.0588,
		0.0570, 0.0570, 0.0553, 0.0553, 0.0553, 0.0536, 0.0536, 0.0521, 0.0521, 0.0521,
		0.0507, 0.0507, 0.0493, 0.0493, 0.0480, 0.0480, 0.0468, 0.0468, 0.0456, 0.0456,
		0.0445, 0.0446, 0.0443, 0.0434, 0.0427, 0.0421, 0.0415, 0.0413, 0.0412, 0.0401,
		0.0372, 0.0344, 0.0320, 0.0299, 0.0276, 0.0257, 0.0240, 0.0222, 0.0207, 0.0192,
	},
	["DEATHKNIGHT"] = {
		0.2587, 0.2264, 0.2264, 0.2264, 0.2264, 0.2012, 0.2012, 0.2012, 0.2012, 0.2012,
		0.1811, 0.1811, 0.1646, 0.1646, 0.1509, 0.1509, 0.1509, 0.1393, 0.1393, 0.1293,
		0.1293, 0.1293, 0.1207, 0.1132, 0.1132, 0.1065, 0.1065, 0.1006, 0.1006, 0.0953,
		0.0953, 0.0905, 0.0905, 0.0862, 0.0862, 0.0823, 0.0823, 0.0787, 0.0787, 0.0755,
		0.0724, 0.0724, 0.0696, 0.0696, 0.0671, 0.0671, 0.0647, 0.0624, 0.0624, 0.0604,
		0.0604, 0.0584, 0.0566, 0.0566, 0.0549, 0.0549, 0.0533, 0.0517, 0.0517, 0.0503,
		0.0477, 0.0453, 0.0431, 0.0421, 0.0402, 0.0385, 0.0370, 0.0355, 0.0342, 0.0335,
		0.0312, 0.0287, 0.0266, 0.0248, 0.0232, 0.0216, 0.0199, 0.0185, 0.0172, 0.0160,
	},
	["SHAMAN"] = {
		0.1039, 0.1039, 0.0990, 0.0990, 0.0945, 0.0945, 0.0945, 0.0903, 0.0903, 0.0866,
		0.0866, 0.0831, 0.0831, 0.0799, 0.0770, 0.0742, 0.0742, 0.0717, 0.0717, 0.0670,
		0.0670, 0.0649, 0.0649, 0.0630, 0.0611, 0.0594, 0.0594, 0.0577, 0.0577, 0.0547,
		0.0547, 0.0533, 0.0520, 0.0520, 0.0495, 0.0483, 0.0483, 0.0472, 0.0472, 0.0452,
		0.0442, 0.0442, 0.0433, 0.0424, 0.0416, 0.0407, 0.0400, 0.0392, 0.0392, 0.0378,
		0.0371, 0.0365, 0.0365, 0.0358, 0.0346, 0.0341, 0.0335, 0.0335, 0.0330, 0.0320,
		0.0310, 0.0304, 0.0294, 0.0285, 0.0281, 0.0273, 0.0267, 0.0261, 0.0255, 0.0250,
		0.0232, 0.0216, 0.0201, 0.0187, 0.0173, 0.0161, 0.0150, 0.0139, 0.0129, 0.0120,
	},
	["MAGE"] = {
		0.0773, 0.0773, 0.0773, 0.0736, 0.0736, 0.0736, 0.0736, 0.0736, 0.0736, 0.0703,
		0.0703, 0.0703, 0.0703, 0.0703, 0.0672, 0.0672, 0.0672, 0.0672, 0.0672, 0.0644,
		0.0644, 0.0644, 0.0644, 0.0618, 0.0618, 0.0618, 0.0618, 0.0618, 0.0595, 0.0595,
		0.0595, 0.0595, 0.0573, 0.0573, 0.0573, 0.0552, 0.0552, 0.0552, 0.0552, 0.0533,
		0.0533, 0.0533, 0.0533, 0.0515, 0.0515, 0.0515, 0.0499, 0.0499, 0.0499, 0.0483,
		0.0483, 0.0483, 0.0468, 0.0468, 0.0468, 0.0455, 0.0455, 0.0455, 0.0442, 0.0442,
		0.0442, 0.0442, 0.0429, 0.0429, 0.0429, 0.0418, 0.0418, 0.0418, 0.0407, 0.0407,
		0.0377, 0.0351, 0.0329, 0.0303, 0.0281, 0.0262, 0.0242, 0.0227, 0.0209, 0.0196,
	},
	["WARLOCK"] = {
		0.1189, 0.1189, 0.1132, 0.1132, 0.1132, 0.1081, 0.1081, 0.1081, 0.1034, 0.1034,
		0.0991, 0.0991, 0.0991, 0.0959, 0.0944, 0.0928, 0.0914, 0.0899, 0.0885, 0.0871,
		0.0857, 0.0844, 0.0831, 0.0818, 0.0805, 0.0792, 0.0780, 0.0768, 0.0756, 0.0745,
		0.0733, 0.0722, 0.0711, 0.0700, 0.0690, 0.0679, 0.0669, 0.0659, 0.0649, 0.0639,
		0.0630, 0.0620, 0.0611, 0.0602, 0.0593, 0.0584, 0.0576, 0.0567, 0.0559, 0.0551,
		0.0543, 0.0535, 0.0527, 0.0519, 0.0512, 0.0504, 0.0497, 0.0490, 0.0483, 0.0476,
		0.0469, 0.0462, 0.0455, 0.0449, 0.0442, 0.0436, 0.0430, 0.0424, 0.0418, 0.0412,
		0.0384, 0.0355, 0.0330, 0.0309, 0.0287, 0.0264, 0.0245, 0.0229, 0.0212, 0.0198,
	},
	["DRUID"] = {
		0.1262, 0.1262, 0.1202, 0.1202, 0.1148, 0.1148, 0.1098, 0.1098, 0.1052, 0.0971,
		0.0935, 0.0935, 0.0902, 0.0902, 0.0842, 0.0842, 0.0814, 0.0789, 0.0789, 0.0701,
		0.0701, 0.0682, 0.0664, 0.0664, 0.0631, 0.0631, 0.0616, 0.0601, 0.0601, 0.0549,
		0.0537, 0.0537, 0.0526, 0.0515, 0.0505, 0.0495, 0.0485, 0.0485, 0.0476, 0.0443,
		0.0435, 0.0435, 0.0428, 0.0421, 0.0407, 0.0401, 0.0401, 0.0394, 0.0388, 0.0366,
		0.0361, 0.0356, 0.0351, 0.0351, 0.0341, 0.0337, 0.0332, 0.0328, 0.0324, 0.0308,
		0.0299, 0.0295, 0.0285, 0.0279, 0.0274, 0.0269, 0.0265, 0.0258, 0.0254, 0.0250,
		0.0232, 0.0216, 0.0201, 0.0187, 0.0173, 0.0161, 0.0150, 0.0139, 0.0129, 0.0120,
	},
}

-- Numbers reverse engineered by Whitetooth (hotdogee [at] gmail [dot] com)
addon.SpellCritPerInt = {
	["WARRIOR"] = addon.zero,
	["PALADIN"] = {
		0.0832, 0.0793, 0.0793, 0.0757, 0.0757, 0.0724, 0.0694, 0.0694, 0.0666, 0.0666,
		0.0640, 0.0616, 0.0594, 0.0574, 0.0537, 0.0537, 0.0520, 0.0490, 0.0490, 0.0462,
		0.0450, 0.0438, 0.0427, 0.0416, 0.0396, 0.0387, 0.0387, 0.0370, 0.0362, 0.0347,
		0.0340, 0.0333, 0.0326, 0.0320, 0.0308, 0.0303, 0.0297, 0.0287, 0.0282, 0.0273,
		0.0268, 0.0264, 0.0256, 0.0256, 0.0248, 0.0245, 0.0238, 0.0231, 0.0228, 0.0222,
		0.0219, 0.0216, 0.0211, 0.0208, 0.0203, 0.0201, 0.0198, 0.0191, 0.0189, 0.0185,
		0.0159, 0.0154, 0.0149, 0.0145, 0.0140, 0.0136, 0.0134, 0.0131, 0.0128, 0.0125,
		0.0116, 0.0108, 0.0101, 0.0093, 0.0087, 0.0081, 0.0075, 0.0070, 0.0065, 0.0060,
	},
	["HUNTER"] = {
		0.0699, 0.0666, 0.0666, 0.0635, 0.0635, 0.0608, 0.0608, 0.0583, 0.0583, 0.0559,
		0.0559, 0.0538, 0.0499, 0.0499, 0.0466, 0.0466, 0.0451, 0.0424, 0.0424, 0.0399,
		0.0388, 0.0388, 0.0368, 0.0358, 0.0350, 0.0341, 0.0333, 0.0325, 0.0318, 0.0304,
		0.0297, 0.0297, 0.0285, 0.0280, 0.0269, 0.0264, 0.0264, 0.0254, 0.0250, 0.0241,
		0.0237, 0.0237, 0.0229, 0.0225, 0.0218, 0.0215, 0.0212, 0.0206, 0.0203, 0.0197,
		0.0194, 0.0192, 0.0186, 0.0184, 0.0179, 0.0177, 0.0175, 0.0170, 0.0168, 0.0164,
		0.0157, 0.0154, 0.0150, 0.0144, 0.0141, 0.0137, 0.0133, 0.0130, 0.0128, 0.0125,
		0.0116, 0.0108, 0.0101, 0.0093, 0.0087, 0.0081, 0.0075, 0.0070, 0.0065, 0.0060,
	},
	["ROGUE"] = addon.zero,
	["PRIEST"] = {
		0.1710, 0.1636, 0.1568, 0.1505, 0.1394, 0.1344, 0.1297, 0.1254, 0.1214, 0.1140,
		0.1045, 0.0941, 0.0875, 0.0784, 0.0724, 0.0684, 0.0627, 0.0597, 0.0562, 0.0523,
		0.0502, 0.0470, 0.0453, 0.0428, 0.0409, 0.0392, 0.0376, 0.0362, 0.0348, 0.0333,
		0.0322, 0.0311, 0.0301, 0.0289, 0.0281, 0.0273, 0.0263, 0.0256, 0.0249, 0.0241,
		0.0235, 0.0228, 0.0223, 0.0216, 0.0210, 0.0206, 0.0200, 0.0196, 0.0191, 0.0186,
		0.0183, 0.0178, 0.0175, 0.0171, 0.0166, 0.0164, 0.0160, 0.0157, 0.0154, 0.0151,
		0.0148, 0.0145, 0.0143, 0.0139, 0.0137, 0.0134, 0.0132, 0.0130, 0.0127, 0.0125,
		0.0116, 0.0108, 0.0101, 0.0093, 0.0087, 0.0081, 0.0075, 0.0070, 0.0065, 0.0060,
	},
	["DEATHKNIGHT"] = addon.zero,
	["SHAMAN"] = {
		0.1333, 0.1272, 0.1217, 0.1217, 0.1166, 0.1120, 0.1077, 0.1037, 0.1000, 0.1000,
		0.0933, 0.0875, 0.0800, 0.0756, 0.0700, 0.0666, 0.0636, 0.0596, 0.0571, 0.0538,
		0.0518, 0.0500, 0.0474, 0.0459, 0.0437, 0.0424, 0.0412, 0.0394, 0.0383, 0.0368,
		0.0354, 0.0346, 0.0333, 0.0325, 0.0314, 0.0304, 0.0298, 0.0289, 0.0283, 0.0272,
		0.0267, 0.0262, 0.0254, 0.0248, 0.0241, 0.0235, 0.0231, 0.0226, 0.0220, 0.0215,
		0.0210, 0.0207, 0.0201, 0.0199, 0.0193, 0.0190, 0.0187, 0.0182, 0.0179, 0.0175,
		0.0164, 0.0159, 0.0152, 0.0147, 0.0142, 0.0138, 0.0134, 0.0131, 0.0128, 0.0125,
		0.0116, 0.0108, 0.0101, 0.0093, 0.0087, 0.0081, 0.0075, 0.0070, 0.0065, 0.0060,
	},
	["MAGE"] = {
		0.1637, 0.1574, 0.1516, 0.1411, 0.1364, 0.1320, 0.1279, 0.1240, 0.1169, 0.1137,
		0.1049, 0.0930, 0.0871, 0.0731, 0.0671, 0.0639, 0.0602, 0.0568, 0.0538, 0.0505,
		0.0487, 0.0460, 0.0445, 0.0422, 0.0405, 0.0390, 0.0372, 0.0338, 0.0325, 0.0312,
		0.0305, 0.0294, 0.0286, 0.0278, 0.0269, 0.0262, 0.0254, 0.0248, 0.0241, 0.0235,
		0.0230, 0.0215, 0.0211, 0.0206, 0.0201, 0.0197, 0.0192, 0.0188, 0.0184, 0.0179,
		0.0176, 0.0173, 0.0170, 0.0166, 0.0162, 0.0154, 0.0151, 0.0149, 0.0146, 0.0143,
		0.0143, 0.0143, 0.0143, 0.0143, 0.0142, 0.0138, 0.0134, 0.0131, 0.0128, 0.0125,
		0.0116, 0.0108, 0.0101, 0.0093, 0.0087, 0.0081, 0.0075, 0.0070, 0.0065, 0.0060,
	},
	["WARLOCK"] = {
		0.1500, 0.1435, 0.1375, 0.1320, 0.1269, 0.1222, 0.1179, 0.1138, 0.1100, 0.1065,
		0.0971, 0.0892, 0.0825, 0.0767, 0.0717, 0.0688, 0.0635, 0.0600, 0.0569, 0.0541,
		0.0516, 0.0493, 0.0471, 0.0446, 0.0429, 0.0418, 0.0398, 0.0384, 0.0367, 0.0355,
		0.0347, 0.0333, 0.0324, 0.0311, 0.0303, 0.0295, 0.0284, 0.0277, 0.0268, 0.0262,
		0.0256, 0.0248, 0.0243, 0.0236, 0.0229, 0.0224, 0.0220, 0.0214, 0.0209, 0.0204,
		0.0200, 0.0195, 0.0191, 0.0186, 0.0182, 0.0179, 0.0176, 0.0172, 0.0168, 0.0165,
		0.0159, 0.0154, 0.0148, 0.0143, 0.0138, 0.0135, 0.0130, 0.0127, 0.0126, 0.0125,
		0.0116, 0.0108, 0.0101, 0.0093, 0.0087, 0.0081, 0.0075, 0.0070, 0.0065, 0.0060,
	},
	["DRUID"] = {
		0.1431, 0.1369, 0.1312, 0.1259, 0.1211, 0.1166, 0.1124, 0.1124, 0.1086, 0.0984,
		0.0926, 0.0851, 0.0807, 0.0750, 0.0684, 0.0656, 0.0617, 0.0594, 0.0562, 0.0516,
		0.0500, 0.0477, 0.0463, 0.0437, 0.0420, 0.0409, 0.0394, 0.0384, 0.0366, 0.0346,
		0.0339, 0.0325, 0.0318, 0.0309, 0.0297, 0.0292, 0.0284, 0.0276, 0.0269, 0.0256,
		0.0252, 0.0244, 0.0240, 0.0233, 0.0228, 0.0223, 0.0219, 0.0214, 0.0209, 0.0202,
		0.0198, 0.0193, 0.0191, 0.0186, 0.0182, 0.0179, 0.0176, 0.0173, 0.0169, 0.0164,
		0.0162, 0.0157, 0.0150, 0.0146, 0.0142, 0.0137, 0.0133, 0.0131, 0.0128, 0.0125,
		0.0116, 0.0108, 0.0101, 0.0093, 0.0087, 0.0081, 0.0075, 0.0070, 0.0065, 0.0060,
	},
}

-- Most classes have a static ratio between crit and dodge per agi per level.
-- While the concept is inspired by TrinityCore, these values were confirmed by collecting the results of
-- StatLogic:GetDodgePerAgi() via addon comms for every level for every class.
-- Hunters and Warlocks are *not* a static ratio in Wrath Classic, which disagrees with TrinityCore.
local DodgePerCrit = {
	["WARRIOR"]     = 0.85 / 1.15,
	["PALADIN"]     = 1.00 / 1.15,
	["ROGUE"]       = 2.00 / 1.15,
	["PRIEST"]      = 1.00 / 1.15,
	["DEATHKNIGHT"] = 0.85 / 1.15,
	["SHAMAN"]      = 1.60 / 1.15,
	["MAGE"]        = 1.00 / 1.15,
	["DRUID"]       = 2.00 / 1.15,
}

addon.DodgePerAgi = setmetatable({
	["HUNTER"] = {
		0.3951, 0.3786, 0.3635, 0.3366, 0.3245, 0.3133, 0.3029, 0.2931, 0.2754, 0.2673,
		0.2456, 0.2164, 0.1975, 0.1817, 0.1652, 0.1567, 0.1466, 0.1356, 0.1280, 0.1196,
		0.1150, 0.1082, 0.1033, 0.0977, 0.0937, 0.0900, 0.0857, 0.0826, 0.0790, 0.0757,
		0.0739, 0.0710, 0.0683, 0.0663, 0.0640, 0.0622, 0.0602, 0.0582, 0.0564, 0.0551,
		0.0538, 0.0522, 0.0508, 0.0494, 0.0481, 0.0471, 0.0459, 0.0445, 0.0435, nil,
		[67] = 0.0258,
		[68] = 0.0253,
		[69] = 0.0247,
		[70] = 0.0241,
		[75] = 0.0167,
		[76] = 0.0155,
		[77] = 0.0144,
		[78] = 0.0134,
		[80] = 0.0116,
	},
	["WARLOCK"] = {
		0.1289, 0.1289, 0.1228, 0.1228, nil,    nil,    nil,    0.1172, 0.1121, 0.1121,
		0.1074, 0.1074, 0.1074, 0.1031, 0.0992, 0.0955, 0.0955, 0.0955, 0.0921, 0.0889,
		0.0859, 0.0859, 0.0832, 0.0832, 0.0781, 0.0781, 0.0781, 0.0758, 0.0758, 0.0716,
		0.0716, 0.0697, 0.0697, 0.0678, 0.0661, 0.0645, 0.0629, 0.0629, 0.0614, 0.0600,
		0.0586, 0.0586, 0.0573, 0.0573, 0.0549, 0.0537, 0.0537, 0.0526, 0.0516, 0.0506,
		0.0496, 0.0496, 0.0486, 0.0477, 0.0469, 0.0460, 0.0452, 0.0445, 0.0445, 0.0430,
		0.0416, 0.0414, 0.0404, 0.0391, 0.0385, 0.0374, 0.0374, 0.0365, 0.0356, 0.0348,
		0.0323, 0.0300, 0.0279, 0.0260, nil,    nil,    nil,    nil,    nil,    0.0167,
	},
}, {
	__index = function (t, class)
		t[class] = setmetatable({}, {__index = function(classTable, level)
			classTable[level] = DodgePerCrit[class] * addon.CritPerAgi[class][level]
			return classTable[level]
		end })
		return t[class]
	end
})

addon.bonusArmorItemEquipLoc = {
	["INVTYPE_WEAPON"] = true,
	["INVTYPE_2HWEAPON"] = true,
	["INVTYPE_WEAPONMAINHAND"] = true,
	["INVTYPE_WEAPONOFFHAND"] = true,
	["INVTYPE_HOLDABLE"] = true,
	["INVTYPE_RANGED"] = true,
	["INVTYPE_THROWN"] = true,
	["INVTYPE_RANGEDRIGHT"] = true,
	["INVTYPE_NECK"] = true,
	["INVTYPE_FINGER"] = true,
	["INVTYPE_TRINKET"] = true,
}

-- Generated using scripts/GenerateBaseArmor/GenerateBaseArmor.mjs
addon.baseArmorTable = {
	[Enum.ItemQuality.Epic] = {
		[SECONDARYHANDSLOT] = {
			[Enum.ItemArmorSubclass.Shield] = {
				[46] = 2063,
				[65] = 2836,
				[90] = 3854,
			},
		},
		[CHESTSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[62] = 455,
				[63] = 461,
				[74] = 537,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[74] = 129,
				[85] = 147,
				[88] = 151,
				[136] = 228,
				[146] = 244,
				[159] = 266,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[65] = 225,
				[69] = 237,
				[74] = 251,
				[75] = 254,
				[83] = 276,
				[105] = 333,
				[123] = 389,
				[136] = 428,
				[146] = 459,
				[159] = 499,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[65] = 842,
				[74] = 954,
				[251] = 2526,
				[264] = 2641,
				[277] = 2756,
			},
		},
		[FEETSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[71] = 85,
				[78] = 93,
				[146] = 168,
				[159] = 183,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[71] = 167,
				[77] = 178,
				[83] = 190,
				[123] = 267,
				[136] = 294,
				[146] = 315,
				[159] = 343,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[71] = 355,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[70] = 621,
				[71] = 630,
				[73] = 647,
			},
		},
		[HANDSSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[71] = 78,
				[136] = 143,
				[146] = 153,
				[159] = 166,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[71] = 152,
				[78] = 164,
				[81] = 169,
				[105] = 208,
				[123] = 243,
				[136] = 268,
				[146] = 287,
				[159] = 312,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[71] = 323,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[71] = 573,
				[251] = 1579,
				[264] = 1650,
				[277] = 1723,
			},
		},
		[HEADSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[74] = 105,
				[81] = 114,
				[136] = 185,
				[146] = 199,
				[159] = 216,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[74] = 204,
				[75] = 206,
				[105] = 271,
				[123] = 316,
				[136] = 348,
				[146] = 373,
				[159] = 405,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[74] = 436,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[66] = 695,
				[74] = 775,
				[105] = 1080,
			},
		},
		[LEGSSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[65] = 100,
				[71] = 109,
				[81] = 123,
				[136] = 200,
				[146] = 214,
				[159] = 232,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[65] = 197,
				[71] = 212,
				[105] = 292,
				[123] = 340,
				[136] = 375,
				[146] = 401,
				[159] = 436,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[71] = 452,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[60] = 683,
				[61] = 694,
				[71] = 802,
				[232] = 2107,
				[264] = 2310,
			},
		},
		[SHOULDERSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[65] = 86,
				[74] = 97,
				[78] = 102,
				[136] = 171,
				[146] = 183,
				[159] = 199,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[65] = 169,
				[74] = 188,
				[105] = 250,
				[123] = 291,
				[136] = 321,
				[146] = 344,
				[159] = 374,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[71] = 387,
				[74] = 403,
			},
		},
		[WRISTSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[59] = 336,
				[251] = 1105,
				[264] = 1155,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[61] = 93,
				[113] = 157,
				[126] = 174,
				[141] = 194,
				[154] = 211,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[141] = 103,
				[154] = 113,
			},
		},
		[BACKSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[72] = 63,
				[73] = 64,
				[77] = 67,
				[83] = 72,
				[105] = 89,
				[110] = 93,
				[115] = 97,
				[128] = 108,
				[200] = 150,
				[213] = 154,
				[232] = 159,
				[264] = 177,
			},
		},
		[WAISTSLOT] = {
			[Enum.ItemArmorSubclass.Leather] = {
				[61] = 120,
				[66] = 128,
				[76] = 144,
				[123] = 219,
				[136] = 241,
				[146] = 258,
				[159] = 280,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[146] = 138,
				[159] = 149,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[264] = 1485,
			},
		},
	},
	[Enum.ItemQuality.Rare] = {
		[CHESTSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[25] = 201,
				[30] = 218,
				[36] = 238,
				[62] = 365,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[59] = 617,
				[62] = 647,
				[63] = 657,
				[65] = 676,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[63] = 89,
				[68] = 96,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[68] = 188,
				[115] = 292,
			},
		},
		[SECONDARYHANDSLOT] = {
			[Enum.ItemArmorSubclass.Shield] = {
				[20] = 471,
				[30] = 661,
				[52] = 1803,
				[59] = 2026,
			},
		},
		[WAISTSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[36] = 134,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[55] = 324,
				[63] = 369,
				[71] = 414,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[33] = 61,
				[43] = 73,
				[53] = 86,
				[60] = 95,
				[63] = 99,
				[100] = 144,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[33] = 28,
				[43] = 35,
				[53] = 43,
				[61] = 49,
				[63] = 50,
				[109] = 83,
				[115] = 88,
			},
		},
		[HEADSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[43] = 341,
				[53] = 453,
				[60] = 509,
				[63] = 534,
				[115] = 946,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[63] = 73,
				[71] = 81,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[71] = 158,
				[100] = 208,
				[115] = 237,
			},
		},
		[WRISTSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[42] = 115,
				[62] = 160,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[50] = 231,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[61] = 38,
			},
		},
		[LEGSSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[37] = 211,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[52] = 479,
				[57] = 522,
				[62] = 566,
				[65] = 592,
				[114] = 1010,
				[166] = 1650,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[52] = 132,
				[68] = 165,
				[71] = 170,
				[100] = 224,
				[115] = 256,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[62] = 77,
				[68] = 84,
			},
		},
		[SHOULDERSLOT] = {
			[Enum.ItemArmorSubclass.Leather] = {
				[52] = 113,
				[68] = 141,
				[71] = 146,
				[115] = 219,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[59] = 463,
				[61] = 478,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[61] = 65,
				[71] = 75,
			},
		},
		[BACKSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[35] = 26,
				[50] = 36,
				[52] = 37,
				[56] = 40,
				[62] = 44,
				[63] = 45,
				[71] = 50,
				[91] = 63,
				[112] = 76,
				[115] = 78,
				[167] = 127,
				[187] = 140,
			},
		},
		[HANDSSLOT] = {
			[Enum.ItemArmorSubclass.Leather] = {
				[61] = 107,
				[65] = 113,
				[66] = 115,
				[71] = 122,
				[115] = 183,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[61] = 398,
				[114] = 722,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[62] = 228,
				[63] = 231,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[61] = 54,
				[66] = 58,
			},
		},
		[FEETSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[63] = 452,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[41] = 177,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[33] = 74,
				[43] = 89,
				[53] = 105,
				[63] = 121,
				[66] = 126,
				[71] = 134,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[33] = 34,
				[43] = 43,
				[53] = 52,
				[61] = 60,
				[63] = 61,
				[66] = 64,
			},
		},
	},
	[Enum.ItemQuality.Good] = {
		[WRISTSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[33] = 91,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[61] = 253,
			},
		},
		[SECONDARYHANDSLOT] = {
			[Enum.ItemArmorSubclass.Shield] = {
				[41] = 1051,
			},
		},
		[CHESTSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[16] = 151,
				[20] = 168,
				[40] = 231,
				[56] = 303,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[46] = 446,
				[60] = 570,
				[62] = 588,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[57] = 148,
			},
		},
		[HANDSSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[28] = 120,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[45] = 273,
			},
		},
		[LEGSSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[45] = 382,
				[62] = 515,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[54] = 124,
			},
		},
		[FEETSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[47] = 312,
				[60] = 392,
			},
		},
		[HEADSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[47] = 369,
				[61] = 471,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[114] = 114,
			},
		},
		[SHOULDERSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[58] = 414,
				[60] = 427,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[61] = 117,
			},
		},
		[BACKSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[60] = 39,
				[108] = 67,
			},
		},
		[WAISTSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[174] = 889,
			},
		},
	},
	[Enum.ItemQuality.Standard] = {
		[SECONDARYHANDSLOT] = {
			[Enum.ItemArmorSubclass.Shield] = {
				[1] = 10,
			},
		},
		[HANDSSLOT] = {
			[Enum.ItemArmorSubclass.Leather] = {
				[1] = 10,
			},
		},
		[CHESTSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[60] = 541,
			},
		},
	},
}

StatLogic.StatModTable = {}
if addon.class == "DRUID" then
	StatLogic.StatModTable["DRUID"] = {
		["ADD_AP_MOD_FERAL_AP"] = {
			-- Cat Form
			{
				["value"] = 1,
				["aura"] = 768,
				["group"] = addon.ExclusiveGroup.Feral,
			},
			-- Bear Form
			{
				["value"] = 1,
				["aura"] = 5487,
				["group"] = addon.ExclusiveGroup.Feral,
			},
			-- Dire Bear Form
			{
				["value"] = 1,
				["aura"] = 9634,
				["group"] = addon.ExclusiveGroup.Feral,
			},
			-- Moonkin Form
			{
				["value"] = 1,
				["aura"] = 24858,
				["group"] = addon.ExclusiveGroup.Feral,
			},
		},
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_AP_MOD_AGI"] = {
			-- Druid: Cat Form - Buff
			{
				["value"] = 1,
				["aura"] = 768,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		-- Druid: Improved Moonkin Form (Rank 3) - 1,19
		--        Your Moonkin Aura also causes affected targets to gain 1%/2%/3% haste and you to gain 10/20/30% of your spirit as additional spell damage.
		["ADD_SPELL_DMG_MOD_SPI"] = {
			{
				["tab"] = 1,
				["num"] = 19,
				["rank"] = {
					0.1, 0.2, 0.3,
				},
				["aura"] = 24858, -- ["Moonkin Form"],
			},
		},
		-- Druid: Improved Tree of Life (Rank 3) - 3,24
		--        Increases your Armor while in Tree of Life Form by 33%/66%/100%, and increases your healing spell power by 5%/10%/15% of your spirit while in Tree of Life Form.
		["ADD_HEALING_MOD_SPI"] = {
			{
				["tab"] = 3,
				["num"] = 24,
				["rank"] = {
					0.05, 0.10, 0.15,
				},
				["aura"] = 33891, -- ["Tree of Life"],
			},
		},
		-- Druid: Lunar Guidance (Rank 3) - 1,12
		--        Increases your spell damage and healing by 8%/16%/25% of your total Intellect.
		-- 3.0.1: Increases your spell damage and healing by 4%/8%/12% of your total Intellect.
		["ADD_SPELL_DMG_MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 12,
				["rank"] = {
					0.04, 0.08, 0.12,
				},
			},
		},
		-- Druid: Lunar Guidance (Rank 3) - 1,12
		--        Increases your spell damage and healing by 8%/16%/25% of your total Intellect.
		-- 3.0.1: Increases your spell damage and healing by 4%/8%/12% of your total Intellect.
		["ADD_HEALING_MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 12,
				["rank"] = {
					0.04, 0.08, 0.12,
				},
			},
		},
		-- Druid: Nurturing Instinct (Rank 2) - 2,14
		--        Increases your healing spells by up to 25%/50% of your Strength.
		-- 2.4.0: Increases your healing spells by up to 50%/100% of your Agility, and increases healing done to you by 10%/20% while in Cat form.
		-- 3.0.1: 2,15: Increases your healing spells by up to 35%/70% of your Agility, and increases healing done to you by 10%/20% while in Cat form.
		["ADD_HEALING_MOD_AGI"] = {
			{
				["tab"] = 2,
				["num"] = 15,
				["rank"] = {
					0.35, 0.7,
				},
			},
		},
		-- Druid: Intensity (Rank 3) - 3,6
		--        Allows 17/33/50% of your Mana regeneration to continue while casting and causes your Enrage ability to instantly generate 10 rage.
		["ADD_MANA_REG_MOD_NORMAL_MANA_REG"] = {
			{
				["tab"] = 3,
				["num"] = 7,
				["rank"] = {
					0.17, 0.33, 0.50,
				},
			},
		},
		-- Druid: Dreamstate (Rank 3) - 1,15
		--        Regenerate mana equal to 4%/7%/10% of your Intellect every 5 sec, even while casting.
		["ADD_MANA_REG_MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 15,
				["rank"] = {
					0.04, 0.07, 0.10,
				},
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 5.6097,
			},
			-- Talent: Feral Swiftness (Cat Form)
			{
				["tab"] = 2,
				["num"] = 6,
				["rank"] = {
					2, 4,
				},
				["aura"] = 32356,
			},
			-- Talent: Feral Swiftness (Bear Form)
			{
				["tab"] = 2,
				["num"] = 6,
				["rank"] = {
					2, 4,
				},
				["aura"] = 32357,
			},
			-- Feral Swiftness (Dire Bear Form)
			{
				["tab"] = 2,
				["num"] = 6,
				["rank"] = {
					2, 4,
				},
				["aura"] = 9634,
			},
			-- Talent: Natural Reaction (Bear Form)
			{
				["tab"] = 2,
				["num"] = 16,
				["rank"] = {
					2, 4, 6,
				},
				["aura"] = 32357,
			},
			-- Talent: Natural Reaction (Dire Bear Form)
			{
				["tab"] = 2,
				["num"] = 16,
				["rank"] = {
					2, 4, 6,
				},
				["aura"] = 9634,
			},
		},
		-- Druid: Thick Hide (Rank 3) - 2,5
		--        Increases your Armor contribution from items by 4%/7%/10%.
		-- Druid: Bear Form - buff (didn't use stance because Bear Form and Dire Bear Form has the same icon)
		--        Shapeshift into a bear, increasing melee attack power by 30, armor contribution from items by 180%, and stamina by 25%.
		-- Druid: Dire Bear Form - Buff
		--        Shapeshift into a dire bear, increasing melee attack power by 120, armor contribution from items by 370%, and stamina by 25%.
		-- Druid: Moonkin Form - Buff
		--        While in this form the armor contribution from items is increased by 370% and
		--        all party and raid members within 45 yards have their spell critical chance increased by 5%.
		--        Spell critical strikes in this form have a chance to instantly regenerate 2% of your total mana.
		-- Druid: Improved Tree of Life (Rank 3) - 3,24
		--        Increases your Armor while in Tree of Life Form by 67%/133%/200%
		-- Druid: Survival of the Fittest (Rank 3) - 2,18
		--        Increases all attributes by 2%/4%/6% and reduces the chance you'll be critically hit by melee attacks by 2%/4%/6%.
		--        , and increases your armor contribution from cloth and leather items in Bear Form and Dire Bear Form by 11/22/33%.
		["MOD_ARMOR"] = {
			{
				["tab"] = 2,
				["num"] = 5,
				["rank"] = {
					0.04, 0.07, 0.1,
				},
			},
			{
				["value"] = 1.8,
				["aura"] = 32357,		-- ["Bear Form"],
			},
			{
				["value"] = 3.7,
				["aura"] = 9634,		-- ["Dire Bear Form"],
			},
			{
				["value"] = 3.7,
				["aura"] = 24858,		-- ["Moonkin Form"],
			},
			{
				["tab"] = 3,
				["num"] = 24,
				["rank"] = {
					0.67, 1.33, 2,
				},
				["aura"] = 33891,		-- ["Tree of Life"],
			},
			{
				["tab"] = 2,
				["num"] = 18,
				["rank"] = {
					0.11, 0.22, 0.33,
				},
				["aura"] = 32357,		-- ["Bear Form"],
			},
			{
				["tab"] = 2,
				["num"] = 18,
				["rank"] = {
					0.11, 0.22, 0.33,
				},
				["aura"] = 9634,		-- ["Dire Bear Form"],
			},
		},
		-- Druid: Predatory Strikes (Rank 3) - 2,10
		--   Increases your melee attack power in Cat, Bear and Dire Bear Forms by
		--   7,14,20% of any attack power on your equipped weapon.
		["MOD_FERAL_AP"] = {
			{
				["tab"] = 2,
				["num"] = 10,
				["rank"] = {
					0.07, 0.14, 0.20,
				},
				["aura"] = 32356,		-- ["Cat Form"],
			},
			{
				["tab"] = 2,
				["num"] = 10,
				["rank"] = {
					0.07, 0.14, 0.20,
				},
				["aura"] = 32357,		-- ["Bear Form"],
			},
			{
				["tab"] = 2,
				["num"] = 10,
				["rank"] = {
					0.07, 0.14, 0.20,
				},
				["aura"] = 9634,		-- ["Dire Bear Form"],
			},
		},
		-- Druid: Survival Instincts - Buff
		--        Health increased by 30% of maximum while in Bear Form, Cat Form, or Dire Bear Form.
		--        Patch 3.0.8: The extra health from this ability now persists in all forms,
		--        but the ability can only be activated in Cat Form, Bear Form, or Dire Bear Form.
		["MOD_HEALTH"] = {
			{
				["value"] = 0.3,
				["aura"] = 50322,		-- ["Survival Instincts"],
			},
		},
		-- Druid: Improved Mark of the Wild (Rank 2) - 3,1
		--        increases all of your total attributes by 1/2%.
		-- Druid: Heart of the Wild (Rank 5) - 2,17
		--        Increases your Intellect by 4%/8%/12%/16%/20%. In addition,
		--        while in Bear or Dire Bear Form your Stamina is increased by 2/4/6/8/10% and
		--        while in Cat Form your attack power is increased by 2/4/6/8/10%.
		-- Druid: Bear Form - Stance (use stance because bear and dire bear increases are the same)
		--        Shapeshift into a bear, increasing melee attack power by 30, armor contribution from items by 180%, and stamina by 25%.
		-- Druid: Dire Bear Form - Stance (use stance because bear and dire bear increases are the same)
		--        Shapeshift into a dire bear, increasing melee attack power by 120, armor contribution from items by 400%, and stamina by 25%.
		-- 9038:  Shapeshift into a dire bear, increasing melee attack power by 120, armor contribution from items by 370%, and stamina by 25%.
		-- Druid: Survival of the Fittest (Rank 3) - 2,18
		--        Increases all attributes by 2%/4%/6% and reduces the chance you'll be critically hit by melee attacks by 2%/4%/6%.
		["MOD_STA"] = {
			-- Improved Mark of the Wild
			{
				["tab"] = 3,
				["num"] = 1,
				["rank"] = {
					0.01, 0.02,
				},
			},
			-- Heart of the Wild: +2/4/6/8/10% stamina in bear / dire bear
			{
				["tab"] = 2,
				["num"] = 17,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
				["aura"] = 32357,		-- ["Bear Form"],
			},
			{
				["tab"] = 2,
				["num"] = 17,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
				["aura"] = 9634,		-- ["Dire Bear Form"],
			},
			-- Survival of the Fittest: 2%/4%/6% all stats
			{
				["tab"] = 2,
				["num"] = 18,
				["rank"] = {
					0.02, 0.04, 0.06,
				},
			},
			-- Bear Form / Dire Bear Form: +25% stamina
			{
				["value"] = 0.25,
				["aura"] = 32357,		-- ["Bear Form"],
			},
			-- Bear Form / Dire Bear Form: +25% stamina
			{
				["value"] = 0.25,
				["aura"] = 9634,		-- ["Dire Bear Form"],
			},
		},
		-- Druid: Improved Mark of the Wild (Rank 2) - 3,1
		--        increases all of your total attributes by 1/2%.
		-- Druid: Survival of the Fittest (Rank 3) - 2,18
		--        Increases all attributes by 2%/4%/6% and reduces the chance you'll be critically hit by melee attacks by 2%/4%/6%.
		["MOD_STR"] = {
			-- Improved Mark of the Wild
			{
				["tab"] = 3,
				["num"] = 1,
				["rank"] = {
					0.01, 0.02,
				},
			},
			{
				["tab"] = 2,
				["num"] = 18,
				["rank"] = {
					0.02, 0.04, 0.06,
				},
			},
		},
		-- Druid: Improved Mark of the Wild (Rank 2) - 3,1
		--        increases all of your total attributes by 1/2%.
		-- Druid: Heart of the Wild (Rank 5) - 2,17
		--        Increases your Intellect by 4%/8%/12%/16%/20%. In addition,
		--        while in Bear or Dire Bear Form your Stamina is increased by 2/4/6/8/10% and
		--        while in Cat Form your attack power is increased by 2/4/6/8/10%.
		-- Druid: Protector of the Pack (Rank 5) - 2,22
		--        Increases your attack power in Bear Form and Dire Bear Form by 2%/4%/6%, and for each friendly player in your party when you enter Bear Form or Dire Bear Form, damage you take is reduced while in Bear Form and Dire Bear Form by 1%/2%/3%.
		["MOD_AP"] = {
			{
				["tab"] = 2,
				["num"] = 17,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
				["aura"] = 32356,		-- ["Cat Form"],
			},
			{
				["tab"] = 2,
				["num"] = 22,
				["rank"] = {
					0.02, 0.04, 0.06,
				},
				["aura"] = 32357,		-- ["Bear Form"],
			},
			{
				["tab"] = 2,
				["num"] = 22,
				["rank"] = {
					0.02, 0.04, 0.06,
				},
				["aura"] = 9634,		-- ["Dire Bear Form"],
			},
		},
		-- Druid: Improved Mark of the Wild (Rank 2) - 3,1
		--        increases all of your total attributes by 1/2%.
		-- Druid: Survival of the Fittest (Rank 3) - 2,18
		--        Increases all attributes by 2%/4%/6% and reduces the chance you'll be critically hit by melee attacks by 2%/4%/6%.
		["MOD_AGI"] = {
			-- Improved Mark of the Wild
			{
				["tab"] = 3,
				["num"] = 1,
				["rank"] = {
					0.01, 0.02,
				},
			},
			{
				["tab"] = 2,
				["num"] = 18,
				["rank"] = {
					0.02, 0.04, 0.06,
				},
			},
		},
		-- Druid: Improved Mark of the Wild (Rank 2) - 3,1
		--        increases all of your total attributes by 1/2%.
		-- Druid: Heart of the Wild (Rank 5) - 2,17
		--        Increases your Intellect by 4%/8%/12%/16%/20%. In addition,
		--        while in Bear or Dire Bear Form your Stamina is increased by 2/4/6/8/10% and
		--        while in Cat Form your attack power is increased by 2/4/6/8/10%.
		-- Druid: Survival of the Fittest (Rank 3) - 2,18
		--        Increases all attributes by 2%/4%/6% and reduces the chance you'll be critically hit by melee attacks by 2%/4%/6%.
		-- Druid: Furor (Rank 5) - 3,3
		--        Increases your total Intellect while in Moonkin form by 2%/4%/6%/8%/10%.
		["MOD_INT"] = {
			-- Improved Mark of the Wild
			{
				["tab"] = 3,
				["num"] = 1,
				["rank"] = {
					0.01, 0.02,
				},
			},
			{
				["tab"] = 2,
				["num"] = 17,
				["rank"] = {
					0.04, 0.08, 0.12, 0.16, 0.2,
				},
			},
			{
				["tab"] = 2,
				["num"] = 18,
				["rank"] = {
					0.02, 0.04, 0.06,
				},
			},
			{
				["tab"] = 3,
				["num"] = 3,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
				["aura"] = 24858,		-- ["Moonkin Form"],
			},
		},
		-- Druid: Improved Mark of the Wild (Rank 2) - 3,1
		--        increases all of your total attributes by 1/2%.
		-- Druid: Living Spirit (Rank 3) - 3,17
		--        Increases your total Spirit by 5%/10%/15%.
		-- Druid: Survival of the Fittest (Rank 3) - 2,18
		--        Increases all attributes by 2%/4%/6% and reduces the chance you'll be critically hit by melee attacks by 2%/4%/6%.
		["MOD_SPI"] = {
			-- Improved Mark of the Wild
			{
				["tab"] = 3,
				["num"] = 1,
				["rank"] = {
					0.01, 0.02,
				},
			},
			{
				["tab"] = 3,
				["num"] = 17,
				["rank"] = {
					0.05, 0.1, 0.15,
				},
			},
			{
				["tab"] = 2,
				["num"] = 18,
				["rank"] = {
					0.02, 0.04, 0.06,
				},
			},
		},
	}
elseif addon.class == "DEATHKNIGHT" then
	StatLogic.StatModTable["DEATHKNIGHT"] = {
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		-- Death Knight: Forceful Deflection - Passive
		--               Increases your Parry Rating by 25% of your total Strength.
		["ADD_PARRY_RATING_MOD_STR"] = {
			-- Base
			{
				["value"] = 0.25,
			},
		},
		-- Death Knight: Bladed Armor (Rank 5) - 1,4
		--               You gain 5/10/15/20/25 attack power for every 1000 points of your armor value.
		--         9014: Increases your attack power by 1/2/3/4/5 for every 180 armor value you have.
		["ADD_AP_MOD_ARMOR"] = {
			{
				["tab"] = 1,
				["num"] = 4,
				["rank"] = {
					1/180, 2/180, 3/180, 4/180, 5/180,
				},
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 3.6640,
			},
			-- Talent: Anticipation
			{
				["tab"] = 3,
				["num"] = 3,
				["rank"] = {
					1, 2, 3, 4, 5,
				},
			},
		},
		-- Death Knight: Toughness (Rank 5) - 2,3
		--               Increases your armor value from items by 2/4/6/8/10% and reduces the duration of all movement slowing effects by 50%.
		-- Death Knight: Unbreakable Armor - Buff
		--               Increases your armor by 25%, your total Strength by 20%
		-- Death Knight: Glyph of Unbreakable Armor - Major Glyph
		--               Increases the armor granted by Unbreakable Armor by 20%.
		-- Death Knight: Frost Presence - Buff
		--               Increasing Stamina by 6%, armor contribution from cloth, leather, mail and plate items by 60%, and reducing damage taken by 5%.
		["MOD_ARMOR"] = {
			{
				["tab"] = 2,
				["num"] = 3,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.10,
				},
			},
			{
				["value"] = 0.25,
				["aura"] = 51271,		-- ["Unbreakable Armor"],
			},
			{
				["value"] = 0.2,
				["aura"] = 51271,		-- ["Unbreakable Armor"],
				["glyph"] = 58635,		-- ["Glyph of Unbreakable Armor"],
			},
			{
				["value"] = 0.6,
				["stance"] = "Interface\\Icons\\Spell_Deathknight_FrostPresence",
			},
		},
		["MOD_STA"] = {
			-- Talent: Veteran of the Third War
			{
				["tab"] = 1,
				["num"] = 14,
				["rank"] = {
					0.01, 0.02, 0.03,
				},
			},
			-- Enchant: Rune of the Stoneskin Gargoyle
			{
				["value"] = 0.02,
				["slot"] = INVSLOT_MAINHAND,
				["enchant"] = 3847,
			},
			-- Enchant: Rune of the Nerubian Carapace (Mainhand)
			{
				["value"] = 0.01,
				["slot"] = INVSLOT_MAINHAND,
				["enchant"] = 3883,
			},
			-- Enchant: Rune of the Nerubian Carapace (Offhand)
			{
				["value"] = 0.01,
				["slot"] = INVSLOT_OFFHAND,
				["enchant"] = 3883,
			},
			-- Stance: Frost Presence
			{
				["value"] = 0.08,
				["stance"] = "Interface\\Icons\\Spell_Deathknight_FrostPresence",
			},
			-- Talent: Improved Frost Presence (Blood Presence)
			{
				["tab"] = 2,
				["num"] = 21,
				["rank"] = {
					0.04, 0.08,
				},
				["stance"] = "Interface\\Icons\\Spell_Deathknight_BloodPresence",
			},
			-- Talent: Improved Frost Presence (Unholy Presence)
			{
				["tab"] = 2,
				["num"] = 21,
				["rank"] = {
					0.04, 0.08,
				},
				["stance"] = "Interface\\Icons\\Spell_Deathknight_UnholyPresence",
			},
		},
		-- Death Knight: Veteran of the Third War (Rank 3) - 1,14
		--               Increases your total Strength by 6% and your total Stamina by 3%.
		-- Death Knight: Unbreakable Armor - Buff
		--               Increasing your armor by 25% and increasing your Strength by 20% for 20 sec.
		-- Death Knight: Ravenous Dead (Rank 3) - 3,7
		--               Increases your total Strength 1%/2%/3% and the contribution your Ghouls get from your Strength and Stamina by 20%/40%/60%
		-- Death Knight: Abomination's Might - 1,17
		--               Also increases your total Strength by 1%/2%.
		-- Death Knight: Endless Winter (Rank 2) - 2,12
		--               Your strength is increased by 2%/4%.
		["MOD_STR"] = {
			{
				["tab"] = 1,
				["num"] = 14,
				["rank"] = {
					0.02, 0.04, 0.06,
				},
			},
			{
				["value"] = 0.2,
				["aura"] = 51271,		-- ["Unbreakable Armor"],
			},
			{
				["tab"] = 3,
				["num"] = 7,
				["rank"] = {
					0.01, 0.02, 0.03,
				},
			},
			{
				["tab"] = 1,
				["num"] = 17,
				["rank"] = {
					0.01, 0.02,
				},
			},
			-- Endless Winter
			{
				["tab"] = 2,
				["num"] = 12,
				["rank"] = {
					0.02, 0.04,
				},
			},
		},
	}
elseif addon.class == "HUNTER" then
	StatLogic.StatModTable["HUNTER"] = {
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 1,
			},
			-- Hunter: Expose Weakness (Rank 3) - 3,19
			--   Expose Weakness increases your attack power by 25% of your Agility.
			{
				["tab"] = 3,
				["num"] = 19,
				["value"] = 0.25,
				["aura"] = 34501,
			}
		},
		["ADD_RANGED_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 1,
			},
			-- Hunter: Expose Weakness (Rank 3) - 3,19
			--   Expose Weakness increases your attack power by 25% of your Agility.
			{
				["tab"] = 3,
				["num"] = 19,
				["value"] = 0.25,
				["aura"] = 34501,
			}
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		["ADD_MANA_REG_MOD_MANA"] = {
			-- Buff: Aspect of the Viper
			{
				["aura"] = 34074,
				["value"] = 0.04 * 5/3,
			},
		},
		-- Hunter: Hunter vs. Wild (Rank 3) - 3,14
		--         Increases you and your pet's attack power and ranged attack power equal to 10%/20%/30% of your total Stamina.
		["ADD_AP_MOD_STA"] = {
			{
				["tab"] = 3,
				["num"] = 14,
				["rank"] = {
					0.1, 0.2, 0.3,
				},
			},
		},
		-- Hunter: Careful Aim (Rank 3) - 2,4
		--         Increases your ranged attack power by an amount equal to 33%/66%/100% of your total Intellect.
		["ADD_RANGED_AP_MOD_INT"] = {
			{
				["tab"] = 2,
				["num"] = 4,
				["rank"] = {
					0.33, 0.66, 1,
				},
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = -4.0873,
			},
			-- Talent: Catlike Reflexes
			{
				["tab"] = 1,
				["num"] = 19,
				["rank"] = {
					1, 2, 3,
				},
			},
			-- Buff: Aspect of the Monkey
			{
				["value"] = 18,
				["aura"] = 13163,
			},
			-- Talent: Improved Aspect of the Monkey (Aspect of the Monkey)
			{
				["tab"] = 1,
				["num"] = 4,
				["rank"] = {
					2, 4, 6,
				},
				["aura"] = 13163,
			},
			-- Buff: Aspect of the Dragonhawk
			{
				["value"] = 18,
				["aura"] = 61846,
			},
			-- Talent: Improved Aspect of the Monkey (Aspect of the Dragonhawk)
			{
				["tab"] = 1,
				["num"] = 4,
				["rank"] = {
					2, 4, 6,
				},
				["aura"] = 61846,
			},
		},
		-- Hunter: Thick Hide (Rank 3) - 1,5
		--         Increases the armor rating of your pets by 20% and your armor contribution from items by 4%/7%/10%.
		["MOD_ARMOR"] = {
			{
				["tab"] = 1,
				["num"] = 5,
				["rank"] = {
					0.04, 0.07, 0.1,
				},
			},
		},
		-- Hunter: Endurance Training (Rank 5) - 1,2
		--         Increases the Health of your pet by 2%/4%/6%/8%/10% and your total health by 1%/2%/3%/4%/5%.
		["MOD_HEALTH"] = {
			{
				["tab"] = 1,
				["num"] = 2,
				["rank"] = {
					0.01, 0.02, 0.03, 0.04, 0.05,
				},
			},
		},
		-- Hunter: Survivalist (Rank 5) - 3,8
		--         Increases your Stamina by 2%/4%/6%/8%/10%.
		["MOD_STA"] = {
			{
				["tab"] = 3,
				["num"] = 8,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
			},
		},
		-- Hunter: Hunting Party (Rank 3) - 3,27
		--         Increases your total Agility by an additional 1/2/3%
		-- Hunter: Combat Experience (Rank 2) - 2,16
		--         Increases your total Agility and Intellect by 2%/4%.
		-- Hunter: Lightning Reflexes (Rank 5) - 3,17
		--         Increases your Agility by 3%/6%/9%/12%/15%.
		["MOD_AGI"] = {
			{
				["tab"] = 3,
				["num"] = 27,
				["rank"] = {
					0.01, 0.02, 0.03,
				},
			},
			{
				["tab"] = 2,
				["num"] = 16,
				["rank"] = {
					0.02, 0.04,
				},
			},
			{
				["tab"] = 3,
				["num"] = 17,
				["rank"] = {
					0.03, 0.06, 0.09, 0.12, 0.15,
				},
			},
		},
		-- Hunter: Combat Experience (Rank 2) - 2,16
		--         Increases your total Agility and Intellect by 2%/4%.
		["MOD_INT"] = {
			{
				["tab"] = 2,
				["num"] = 16,
				["rank"] = {
					0.02, 0.04,
				},
			},
		},
	}
elseif addon.class == "MAGE" then
	StatLogic.StatModTable["MAGE"] = {
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 3.6587,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		["ADD_SPELL_CRIT_RATING_MOD_SPI"] = {
			-- Mage: Molten Armor (Rank 3) - Buff
			--       increases your critical strike rating by 35% of your spirit
			{
				["value"] = 0.35,
				["aura"] = 30482, -- ["Molten Armor"],
			},
			-- Mage: Glyph of Molten Armor - Major Glyph
			--       Your Molten Armor grants an additional 20% of your spirit as critical strike rating.
			{
				["value"] = 0.2,
				["aura"] = 30482, -- ["Molten Armor"],
				["glyph"] = 56382, -- Glyph of Molten Armor,
			},
			-- Mage: Khadgar's Regalia(843), Sunstrider's Regalia(844) 2pc - Item Set
			--       converts an additional 15% of your spirit into critical strike rating when Molten Armor is active.
			{
				["value"] = 0.15,
				["aura"] = 30482, -- ["Molten Armor"],
				-- Khadgar's Regalia
				["set"] = 843,
				["pieces"] = 2,
			},
			{
				["value"] = 0.15,
				["aura"] = 30482, -- ["Molten Armor"],
				-- Sunstrider's Regalia
				["set"] = 844,
				["pieces"] = 2,
			},
		},
		-- Mage: Arcane Fortitude - 1,4
		--       Increases your armor by an amount equal to 50%/100%/150% of your Intellect.
		["ADD_BONUS_ARMOR_MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 4,
				["rank"] = {
					0.5, 1, 1.5,
				},
			},
		},
		-- Mage: Arcane Meditation (Rank 3) - 1,13
		--       Allows 17/33/50% of your Mana regeneration to continue while casting.
		-- Mage: Mage Armor (Rank 6) - Buff
		--       Resistance to all magic schools increased by 40 and allows 50% of your mana regeneration to continue while casting.
		-- Mage: Khadgar's Regalia(843), Sunstrider's Regalia(844) 2pc - Item Set
		--       Increases the armor you gain from Ice Armor by 20%, the mana regeneration you gain from Mage Armor by 10%,
		--       and converts an additional 15% of your spirit into critical strike rating when Molten Armor is active.
		-- Mage: Glyph of Mage Armor - Major Glyph
		--       Your Mage Armor spell grants an additional 20% mana regeneration while casting.
		-- Mage: Pyromaniac (Rank 3) - 2,19
		--       Increases chance to critically hit by 1%/2%/3% and allows 17/33/50% of your mana regeneration to continue while casting.
		["ADD_MANA_REG_MOD_NORMAL_MANA_REG"] = {
			{
				["tab"] = 1,
				["num"] = 13,
				["rank"] = {
					0.17, 0.33, 0.5,
				},
			},
			{
				["value"] = 0.5,
				["aura"] = 6117, -- ["Mage Armor"],
			},
			{
				["value"] = 0.1,
				["aura"] = 6117, -- ["Mage Armor"],
				-- Khadgar's Regalia
				["set"] = 843,
				["pieces"] = 2,
			},
			{
				["value"] = 0.1,
				["aura"] = 6117, -- ["Mage Armor"],
				-- Sunstrider's Regalia
				["set"] = 844,
				["pieces"] = 2,
			},
			{
				["value"] = 0.2,
				["aura"] = 6117, -- ["Mage Armor"],
				["glyph"] = 56383, -- Glyph of Mage Armor,
			},
			{
				["tab"] = 2,
				["num"] = 19,
				["rank"] = {
					0.17, 0.33, 0.5,
				},
			},
		},
		-- Mage: Mind Mastery (Rank 5) - 1,25
		--       Increases spell damage by up to 3%/6%/9%/12%/15% of your total Intellect.
		["ADD_SPELL_DMG_MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 25,
				["rank"] = {
					0.03, 0.06, 0.09, 0.12, 0.15,
				},
			},
		},
		["ADD_HEALING_MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 25,
				["rank"] = {
					0.03, 0.06, 0.09, 0.12, 0.15,
				},
			},
		},
		-- Mage: Arcane Mind (Rank 5) - 1,15
		--       Increases your total Intellect by 3%/6%/9%/12%/15%.
		-- 3.0.1: 1,17
		["MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 17,
				["rank"] = {
					0.03, 0.06, 0.09, 0.12, 0.15,
				},
			},
		},
		-- Mage: Student of the Mind (Rank 3) - 1,9
		--       Increases your total Spirit by 4%/7%/10%.
		["MOD_SPI"] = {
			{
				["tab"] = 1,
				["num"] = 9,
				["rank"] = {
					0.04, 0.07, 0.1,
				},
			},
		},
	}
elseif addon.class == "PALADIN" then
	StatLogic.StatModTable["PALADIN"] = {
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		["ADD_BLOCK_VALUE_MOD_STR"] = {
			-- Base
			{
				["value"] = BLOCK_PER_STRENGTH,
			},
		},
		-- Paladin: Sheath of Light (Rank 3) - 3,24
		--          Increases your spell power by an amount equal to 10%/20%/30% of your attack power
		--   3.1.0: 3,24
		["ADD_SPELL_DMG_MOD_AP"] = {
			{
				["tab"] = 3,
				["num"] = 24,
				["rank"] = {
					0.1, 0.2, 0.3,
				},
			},
		},
		["ADD_HEALING_MOD_AP"] = {
			{
				["tab"] = 3,
				["num"] = 24,
				["rank"] = {
					0.1, 0.2, 0.3,
				},
			},
		},
		-- Paladin: Touched by the Light (Rank 3) - 2,21
		--          Increases your spell power by an amount equal to 20/40/60% of your Strength
		["ADD_SPELL_DMG_MOD_STR"] = {
			{
				["tab"] = 2,
				["num"] = 21,
				["rank"] = {
					0.2, 0.4, 0.6,
				},
			},
		},
		["ADD_HEALING_MOD_STR"] = {
			{
				["tab"] = 2,
				["num"] = 21,
				["rank"] = {
					0.2, 0.4, 0.6,
				},
			},
		},
		-- Paladin: Holy Guidance (Rank 5) - 1,21
		--          Increases your spell power by 4%/8%/12%/16%/20% of your total Intellect.
		["ADD_SPELL_DMG_MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 21,
				["rank"] = {
					0.04, 0.08, 0.12, 0.16, 0.2,
				},
			},
		},
		-- Paladin: Holy Guidance (Rank 5) - 1,21
		--          Increases your spell damage and healing by 7%/14%/21%/28%/35% of your total Intellect.
		["ADD_HEALING_MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 21,
				["rank"] = {
					0.04, 0.08, 0.12, 0.16, 0.2,
				},
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 3.4943,
			},
			-- Talent: Anticipation
			{
				["tab"] = 2,
				["num"] = 5,
				["rank"] = {
					1, 2, 3, 4, 5,
				},
			},
		},
		-- Paladin: Toughness (Rank 5) - 2,8
		--          Increases your armor value from items by 2%/4%/6%/8%/10%.
		["MOD_ARMOR"] = {
			{
				["tab"] = 2,
				["num"] = 8,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
			},
		},
		-- Paladin: Divine Strength (Rank 5) - 2,2
		--          Increases your total Strength by 3%/6%/9%/12%/15%.
		["MOD_STR"] = {
			{
				["tab"] = 2,
				["num"] = 2,
				["rank"] = {
					0.03, 0.06, 0.09, 0.12, 0.15,
				},
			},
		},
		-- Paladin: Sacred Duty (Rank 2) - 2,14
		--          Increases your total Stamina by 4%/8%
		--          Sacred Duty now provides 2 / 4% Stamina, down from 4 / 8% Stamina.
		-- Paladin: Combat Expertise (Rank 3) - 2,20
		--          Increases your expertise by 2/4/6, total Stamina and chance to critically hit by 2%/4%/6%.
		["MOD_STA"] = {
			{
				["tab"] = 2,
				["num"] = 14,
				["rank"] = {
					0.02, 0.04,
				},
			},
			{
				["tab"] = 2,
				["num"] = 20,
				["rank"] = {
					0.02, 0.04, 0.06,
				},
			},
		},
		-- Paladin: Divine Intellect (Rank 5) - 1,4
		--          Increases your total Intellect by 2/4/6/8/10%.
		["MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 4,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.10,
				},
			},
		},
		-- Paladin: Redoubt (Rank 3) - 2,19
		--          Increases your block value by 10%/20%/30% and
		--          damaging melee and ranged attacks against you have a 10% chance to increase your chance to block by 30%.  Lasts 10 sec or 5 blocks.
		["MOD_BLOCK_VALUE"] = {
			{
				["tab"] = 2,
				["num"] = 19,
				["rank"] = {
					0.1, 0.2, 0.3,
				},
			},
		},
	}
elseif addon.class == "PRIEST" then
	StatLogic.StatModTable["PRIEST"] = {
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 3.4178,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		["MOD_NORMAL_MANA_REG"] = {
			-- Priest: Holy Concentration (Rank 3) - 2,17
			--   Your mana regeneration from spirit is increased by 16/32/50%
			{
				["tab"] = 2,
				["num"] = 17,
				["aura"] = 34754,
				["rank"] = {
					0.16, 0.32, 0.50,
				},
			},
		},
		-- Priest: Meditation (Rank 3) - 1,7
		--         Allows 17/33/50% of your Mana regeneration to continue while casting.
		["ADD_MANA_REG_MOD_NORMAL_MANA_REG"] = {
			{
				["tab"] = 1,
				["num"] = 7,
				["rank"] = {
					0.17, 0.33, 0.5,
				},
			},
			-- Priest: Spirit Tap (Rank 3) - 3,1
			--	For the duration, your mana will regenerate at a 83% rate while casting.
			{
				["tab"] = 3,
				["num"] = 1,
				["aura"] = 15271,
				["value"] = 0.83,
			},
			-- Priest: Improved Spirit Tap (Rank 2) - 3,2
			--	For the duration, your mana will regenerate at a 33% rate while casting.
			{
				["tab"] = 3,
				["num"] = 2,
				["aura"] = 59000,
				["rank"] = {
					0.17, 0.33,
				},
			},
		},
		["ADD_MANA_REG_MOD_MANA"] = {
			-- Talent: Dispersion
			{
				["tab"] = 3,
				["num"] = 27,
				["value"] = 0.30,
				["aura"] = 47585,
			},
		},
		["ADD_SPELL_DMG_MOD_SPI"] = {
			-- Priest: Spiritual Guidance (Rank 5) - 2,14
			--         Increases spell power by up to 5%/10%/15%/20%/25% of your total Spirit.
			{
				["tab"] = 2,
				["num"] = 14,
				["rank"] = {
					0.05, 0.1, 0.15, 0.2, 0.25,
				},
			},
			-- Priest: Twisted Faith (Rank 5) - 3,26
			--         Increases your spell power by 4/8/12/16/20% of your total Spirit
			{
				["tab"] = 3,
				["num"] = 26,
				["rank"] = {
					0.04, 0.08, 0.12, 0.16, 0.2,
				},
			},
			-- Priest: Glyph of Shadow
			--	While in Shadowform, your non-periodic spell critical strikes increase
			--	your spell power by 30% of your Spirit for 10 sec.
			{
				["glyph"] = 55689,
				["aura"] = 61792,
				["value"] = 0.30,
			},
		},
		-- Priest: Spiritual Guidance (Rank 5) - 2,14
		--         Increases spell power by up to 5%/10%/15%/20%/25% of your total Spirit.
		-- Priest: Twisted Faith (Rank 5) - 3,26
		--         Increases your spell power by 4/8/12/16/20% of your total Spirit
		["ADD_HEALING_MOD_SPI"] = {
			{
				["tab"] = 2,
				["num"] = 14,
				["rank"] = {
					0.05, 0.1, 0.15, 0.2, 0.25,
				},
			},
			{
				["tab"] = 3,
				["num"] = 26,
				["rank"] = {
					0.04, 0.08, 0.12, 0.16, 0.2,
				},
			},
		},
		-- Priest: Enlightenment (Rank 5) - 1,17
		--         Increases your total Stamina and Spirit by 1%/2%/3%/4%/5% and increases your spell haste by 1%/2%/3%/4%/5%.
		-- Priest: Improved Power Word: Fortitude (Rank 2) - 1,5
		--         Increases your total Stamina by 2/4%.
		["MOD_STA"] = {
			{
				["tab"] = 1,
				["num"] = 17,
				["rank"] = {
					0.01, 0.02, 0.03, 0.04, 0.05,
				},
			},
			{
				["tab"] = 1,
				["num"] = 5,
				["rank"] = {
					0.02, 0.04,
				},
			},
		},
		-- Priest: Mental Strength (Rank 5) - 1,14
		--         Increases your total Intellect by 3%/6%/9%/12%/15%.
		["MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 14,
				["rank"] = {
					0.03, 0.06, 0.09, 0.12, 0.15,
				},
			},
		},
		["MOD_SPI"] = {
			-- Priest: Enlightenment (Rank 5) - 1,17
			--         Increases your total Stamina and Spirit by 1%/2%/3%/4%/5% and increases your spell haste by 1%/2%/3%/4%/5%.
			{
				["tab"] = 1,
				["num"] = 17,
				["rank"] = {
					0.01, 0.02, 0.03, 0.04, 0.05,
				},
			},
			-- Priest: Spirit of Redemption - 2,13
			--         Increases total Spirit by 5% and upon death, the priest becomes the Spirit of Redemption for 15 sec.
			{
				["tab"] = 2,
				["num"] = 13,
				["value"] = 0.05,
			},
			-- Priest: Spirit Tap (Rank 3) - 3,1
			--	Gives you a 100% chance to gain a 100% bonus to your Spirit
			--	after killing a target that yields experience or honor.
			{
				["tab"] = 3,
				["num"] = 1,
				["aura"] = 15271,
				["value"] = 1.00,
			},
			-- Priest: Improved Spirit Tap (Rank 2) - 3,2
			--	Your Mind Blast and Shadow Word: Death critical strikes
			--	have a 100% chance and your Mind Flay critical strikes
			--	have a 50% chance to increase your total Spirit by 10%.
			{
				["tab"] = 3,
				["num"] = 2,
				["aura"] = 59000,
				["rank"] = {
					0.05, 0.10,
				},
			},
		},
	}
elseif addon.class == "ROGUE" then
	StatLogic.StatModTable["ROGUE"] = {
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_RANGED_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		-- Rogue: Deadliness (Rank 5) - 3,18
		--        Increases your attack power by 2%/4%/6%/8%/10%.
		-- Rogue: Savage Combat (Rank 2) - 2,26
		--        Increases your total attack power by 2%/4%.
		["MOD_AP"] = {
			{
				["tab"] = 3,
				["num"] = 18,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
			},
			{
				["tab"] = 2,
				["num"] = 26,
				["rank"] = {
					0.02, 0.04,
				},
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 2.0957,
			},
			-- Talent: Lightning Reflexes
			{
				["tab"] = 2,
				["num"] = 12,
				["rank"] = {
					2, 4, 6,
				},
			},
			-- Buff: Evasion
			{
				["value"] = 50,
				["aura"] = 26669,
			},
			-- Buff: Ghostly Strike
			{
				["value"] = 15,
				["aura"] = 31022,
			},
		},
		-- Rogue: Sinister Calling (Rank 5) - 3,22
		--        Increases your total Agility by 3%/6%/9%/12%/15%.
		["MOD_AGI"] = {
			{
				["tab"] = 3,
				["num"] = 22,
				["rank"] = {
					0.03, 0.06, 0.09, 0.12, 0.15,
				},
			},
		},
		-- Rogue: Endurance (Rank 2) - 2,7
		--        increases your total Stamina by 2%/4%.
		["MOD_STA"] = {
			{
				["tab"] = 2,
				["num"] = 7,
				["rank"] = {
					0.02, 0.04,
				},
			},
		},
		[StatLogic.Stats.MeleeCrit] = {
			-- Talent: Close Quarters Combat
			{
				["tab"] = 2,
				["num"] = 9,
				["rank"] = {
					1, 2, 3, 4, 5,
				},
				["weapon"] = {
					[Enum.ItemWeaponSubclass.Dagger] = true,
					[Enum.ItemWeaponSubclass.Unarmed] = true,
				},
			},
		},
	}
elseif addon.class == "SHAMAN" then
	StatLogic.StatModTable["SHAMAN"] = {
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		["ADD_BLOCK_VALUE_MOD_STR"] = {
			-- Base
			{
				["value"] = BLOCK_PER_STRENGTH,
			},
		},
		-- Shaman: Mental Dexterity (Rank 3) - 2,15
		--         Increases your Attack Power by 33%/66%/100% of your Intellect.
		["ADD_AP_MOD_INT"] = {
			{
				["tab"] = 2,
				["num"] = 15,
				["rank"] = {
					0.33, 0.66, 1,
				},
			},
		},
		-- Shaman: Mental Quickness (Rank 3) - 2,25
		--         Reduces the mana cost of your instant cast spells by 2%/4%/6% and increases your spell power equal to 10%/20%/30% of your attack power.
		--  3.1.0: 2,25
		["ADD_SPELL_DMG_MOD_AP"] = {
			{
				["tab"] = 2,
				["num"] = 25,
				["rank"] = {
					0.1, 0.2, 0.3,
				},
			},
		},
		-- Shaman: Mental Quickness (Rank 3) - 2,25
		--         Reduces the mana cost of your instant cast spells by 2%/4%/6% and increases your spell power equal to 10%/20%/30% of your attack power.
		--  3.1.0: 2,25
		["ADD_HEALING_MOD_AP"] = {
			{
				["tab"] = 2,
				["num"] = 25,
				["rank"] = {
					0.1, 0.2, 0.3,
				},
			},
		},
		-- Shaman: Unrelenting Storm (Rank 3) - 1,13
		--         Regenerate mana equal to 4%/8%/12% of your Intellect every 5 sec, even while casting.
		["ADD_MANA_REG_MOD_INT"] = {
			{
				["tab"] = 1,
				["num"] = 13,
				["rank"] = {
					0.04, 0.08, 0.12,
				},
			},
		},
		-- Shaman: Nature's Blessing (Rank 3) - 3,21
		--         Increases your healing by an amount equal to 5%/10%/15% of your Intellect.
		["ADD_HEALING_MOD_INT"] = {
			{
				["tab"] = 3,
				["num"] = 21,
				["rank"] = {
					0.05, 0.1, 0.15,
				},
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 2.1080,
			},
			-- Talent: Anticipation
			{
				["tab"] = 2,
				["num"] = 10,
				["rank"] = {
					1, 2, 3,
				},
			},
		},
		-- Shaman: Toughness (Rank 5) - 2,12
		--         Increases your total stamina by 2/4/6/8/10%.
		["MOD_STA"] = {
			{
				["tab"] = 2,
				["num"] = 12,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
			},
		},
		-- Shaman: Ancestral Knowledge (Rank 5) - 2,3
		--         Increases your intellect by 2%/4%/6%/8%/10%.
		["MOD_INT"] = {
			{
				["tab"] = 2,
				["num"] = 3,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
			},
		},
	}
elseif addon.class == "WARLOCK" then
	StatLogic.StatModTable["WARLOCK"] = {
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 2.4211,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		-- Warlock: Metamorphosis - Buff
		--          This form increases your armor by 600%, damage by 20%, reduces the chance you'll be critically hit by melee attacks by 6% and reduces the duration of stun and snare effects by 50%.
		["MOD_ARMOR"] = {
			{
				["value"] = 6,
				["aura"] = 47241,		-- ["Metamorphosis"],
			},
		},
		-- Warlock: Demonic Pact - 2,26
		--          Your pet's criticals apply the Demonic Pact effect to your party or raid members. Demonic Pact increases spell power by 2%/4%/6%/8%/10% of your Spell Damage for 12 sec.
		["MOD_SPELL_DMG"] = {
			{
				["tab"] = 2,
				["num"] = 26,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
				["aura"] = 47240,		-- ["Demonic Pact"],
			},
		},
		-- Warlock: Demonic Pact - 2,26
		--          Your pet's criticals apply the Demonic Pact effect to your party or raid members. Demonic Pact increases spell power by 2%/4%/6%/8%/10% of your Spell Damage for 12 sec.
		["MOD_HEALING"] = {
			{
				["tab"] = 2,
				["num"] = 26,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
				["aura"] = 47240,		-- ["Demonic Pact"],
			},
		},
		-- Warlock: Fel Armor (Rank 4) - Buff
		--          Surrounds the caster with fel energy, increasing spell power by 50/100/150/180 plus additional spell power equal to 30% of your Spirit.
		-- Warlock: Demonic Aegis (Rank 3) - 2,11
		--          Increases the effectiveness of your Demon Armor and Fel Armor spells by 10%/20%/30%.
		-- Warlock: Glyph of Life Tap - Major Glyph
		--          When you use Life Tap, you gain 20% of your Spirit as spell power for 40 sec.
		--          Life Tap - Buff
		["ADD_SPELL_DMG_MOD_SPI"] = {
			{
				["value"] = 0.3,
				["aura"] = 28176, -- ["Fel Armor"],
			},
			{
				["tab"] = 2,
				["num"] = 11,
				["rank"] = {
					0.03, 0.06, 0.09,
				},
				["aura"] = 28176, -- ["Fel Armor"],
			},
			{
				["value"] = 0.2,
				["glyph"] = 63320,
				["aura"] = 63321, -- ["Life Tap"],
			},
		},
		-- Warlock: Fel Armor (Rank 4) - Buff
		--          Surrounds the caster with fel energy, increasing spell power by 50/100/150/180 plus additional spell power equal to 30% of your Spirit.
		-- Warlock: Demonic Aegis (Rank 3) - 2,11
		--          Increases the effectiveness of your Demon Armor and Fel Armor spells by 10%/20%/30%.
		--   3.1.0: 2,11
		["ADD_HEALING_MOD_SPI"] = {
			{
				["value"] = 0.2,
				["glyph"] = 63320,
				["aura"] = 63321, -- ["Life Tap"],
			},
		},
		["ADD_PET_STA_MOD_STA"] = {
			-- Base
			{
				["value"] = 0.75,
				["pet"] = true,
			},
		},
		["MOD_PET_STA"] = {
			-- 3.3.0 Imp stam total 233: pet base 118, player base 90, pet sta from player sta 0.75, pet kings 1.1, fel vitality 1.15
			-- /dump floor((118+floor(90*0.75))*1.1)*1.05 = 233.45 match
			-- /dump (118+floor(90*0.75))*1.1*1.05 = 224.025 wrong
			--{
			--	["value"] = 0.1, -- BoK, BoSanc
			--	["condition"] = "UnitBuff('pet', GetSpellInfo(20217)) or UnitBuff('pet', GetSpellInfo(25898)) or UnitBuff('pet', GetSpellInfo(20911)) or UnitBuff('pet', GetSpellInfo(25899))",
			--},
			-- Warlock: Fel Vitality (Rank 3) - 2,7
			--          Increases the Stamina and Intellect of your Imp, Voidwalker, Succubus, Felhunter and Felguard by 15% and increases your maximum health and mana by 1%/2%/3%.
			{
				["tab"] = 2,
				["num"] = 7,
				["rank"] = {
					0.05, 0.1, 0.15,
				},
				["pet"] = true,
			},
		},
		-- Warlock: Demonic Knowledge (Rank 3) - 2,20
		--          Increases your spell damage by an amount equal to 4/8/12% of the total of your active demon's Stamina plus Intellect.
		["ADD_SPELL_DMG_MOD_PET_STA"] = {
			{
				["tab"] = 2,
				["num"] = 20,
				["rank"] = {
					0.04, 0.08, 0.12,
				},
				["pet"] = true,
			},
		},
		["ADD_PET_INT_MOD_INT"] = {
			-- Base
			{
				["value"] = 0.3,
				["pet"] = true,
			},
		},
		["MOD_PET_INT"] = {
			-- Blessings on pet
			--{
			--	["value"] = 0.1,
			--	["condition"] = "UnitBuff('pet', GetSpellInfo(20217)) or UnitBuff('pet', GetSpellInfo(25898)) or UnitBuff('pet', GetSpellInfo(20911)) or UnitBuff('pet', GetSpellInfo(25899))",
			--},
			-- Warlock: Fel Vitality (Rank 3) - 2,7
			--          Increases the Stamina and Intellect of your Imp, Voidwalker, Succubus, Felhunter and Felguard by 15% and increases your maximum health and mana by 1%/2%/3%.
			{
				["tab"] = 2,
				["num"] = 7,
				["rank"] = {
					0.05, 0.1, 0.15,
				},
				["pet"] = true,
			},
		},
		-- Warlock: Demonic Knowledge (Rank 3) - 2,20
		--          Increases your spell damage by an amount equal to 4/8/12% of the total of your active demon's Stamina plus Intellect.
		["ADD_SPELL_DMG_MOD_PET_INT"] = {
			{
				["tab"] = 2,
				["num"] = 20,
				["rank"] = {
					0.04, 0.08, 0.12,
				},
				["pet"] = true,
			},
		},
		-- Warlock: Fel Vitality (Rank 3) - 2,7
		--          Increases the Stamina and Intellect of your Imp, Voidwalker, Succubus, Felhunter and Felguard by 5%/10%/15% and increases your maximum health and mana by 1%/2%/3%.
		["MOD_HEALTH"] = {
			{
				["tab"] = 2,
				["num"] = 7,
				["rank"] = {
					0.01, 0.02, 0.03,
				},
			},
		},
		-- Warlock: Fel Vitality (Rank 3) - 2,7
		--          Increases the Stamina and Intellect of your Imp, Voidwalker, Succubus, Felhunter and Felguard by 15% and increases your maximum health and mana by 1%/2%/3%.
		["MOD_MANA"] = {
			{
				["tab"] = 2,
				["num"] = 7,
				["rank"] = {
					0.01, 0.02, 0.03,
				},
			},
		},
		-- Warlock: Demonic Embrace (Rank 5) - 2,3
		--          Increases your total Stamina by 4/7/10%.
		["MOD_STA"] = {
			{
				["tab"] = 2,
				["num"] = 3,
				["rank"] = {
					0.04, 0.07, 0.1,
				},
			},
		},
	}
elseif addon.class == "WARRIOR" then
	StatLogic.StatModTable["WARRIOR"] = {
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_RANGED_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_BLOCK_VALUE_MOD_STR"] = {
			-- Base
			{
				["value"] = BLOCK_PER_STRENGTH,
			},
		},
		-- Warrior: Armored to the Teeth (Rank 3) - 2,1
		--          Increases your attack power by 1/2/3 for every 108 armor value you have.
		["ADD_AP_MOD_ARMOR"] = {
			{
				["tab"] = 2,
				["num"] = 1,
				["rank"] = {
					1/108, 2/108, 3/108,
				},
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 3.6640,
			},
			-- Talent: Anticipation
			{
				["tab"] = 3,
				["num"] = 5,
				["rank"] = {
					1, 2, 3, 4, 5,
				},
			},
		},
		-- Warrior: Last Stand - Buff
		--          When activated, this ability temporarily grants you 30% of your maximum health for 20 sec.
		["MOD_HEALTH"] = {
			{
				["value"] = 0.3,
				["aura"] = 12975,		-- ["Last Stand"],
			},
		},
		-- Warrior: Toughness (Rank 5) - 3,9
		--          Increases your armor value from items by 2%/4%/6%/8%/10%.
		["MOD_ARMOR"] = {
			{
				["tab"] = 3,
				["num"] = 9,
				["rank"] = {
					0.02, 0.04, 0.06, 0.08, 0.1,
				},
			},
		},
		-- Warrior: Vitality (Rank 3) - 3,20
		--          Increases your total Strength by 2%/4%/6%, Stamina by 3/6/9% and your Expertise by 2/4/6.
		-- Warrior: Strength of Arms (Rank 2) - 1,22
		--          Increases your total Strength and Stamina by 2%/4% and your Expertise by 2/4.
		["MOD_STA"] = {
			{
				["tab"] = 3,
				["num"] = 20,
				["rank"] = {
					0.03, 0.06, 0.09,
				},
			},
			{
				["tab"] = 1,
				["num"] = 22,
				["rank"] = {
					0.02, 0.04,
				},
			},
		},
		-- Warrior: Vitality (Rank 3) - 3,20
		--          Increases your total Strength by 2%/4%/6%, Stamina by 3/6/9% and your Expertise by 2/4/6.
		-- Warrior: Strength of Arms (Rank 2) - 1,22
		--          Increases your total Strength and total health by 2%/4%.
		-- Warrior: Improved Berserker Stance (Rank 5) - 2,22 - Stance
		--          Increases strength by 4/8/12/16/20% while in Berserker Stance.
		["MOD_STR"] = {
			{
				["tab"] = 3,
				["num"] = 20,
				["rank"] = {
					0.02, 0.04, 0.06,
				},
			},
			{
				["tab"] = 1,
				["num"] = 22,
				["rank"] = {
					0.02, 0.04,
				},
			},
			{
				["tab"] = 2,
				["num"] = 22,
				["rank"] = {
					0.04, 0.08, 0.12, 0.16, 0.2,
				},
				["stance"] = "Interface\\Icons\\Ability_Racial_Avatar",
			},
		},
		-- Warrior: Shield Mastery (Rank 2) - 3,8
		--          Increases your block value by 15%/30% and reduces the cooldown of your Shield Block ability by 10/20 sec.
		["MOD_BLOCK_VALUE"] = {
			{
				["tab"] = 3,
				["num"] = 8,
				["rank"] = {
					0.15, 0.3,
				},
			},
		},
		[StatLogic.Stats.MeleeCrit] = {
			-- Talent: Poleaxe Specialization
			{
				["tab"] = 1,
				["num"] = 13,
				["rank"] = {
					1, 2, 3, 4, 5,
				},
				["weapon"] = {
					[Enum.ItemWeaponSubclass.Axe1H] = true,
					[Enum.ItemWeaponSubclass.Axe2H] = true,
					[Enum.ItemWeaponSubclass.Polearm] = true,
				},
			},
		},
	}
end

if addon.playerRace == "Dwarf" then
	StatLogic.StatModTable["Dwarf"] = {
		[StatLogic.Stats.Expertise] = {
			{
				["value"] = 5,
				["weapon"] = {
					[Enum.ItemWeaponSubclass.Mace1H] = true,
					[Enum.ItemWeaponSubclass.Mace2H] = true,
				}
			}
		},
		[StatLogic.Stats.RangedCrit] = {
			{
				["value"] = 1,
				["weapon"] = {
					[Enum.ItemWeaponSubclass.Guns] = true,
				}
			}
		},
	}
elseif addon.playerRace == "Gnome" then
	StatLogic.StatModTable["Gnome"] = {
		["MOD_INT"] = {
			-- Gnome: Expansive Mind - Racial
			--        Increase Intelligence by 5%.
			{
				["value"] = 0.05,
				["race"] = "Gnome",
			},
		}
	}
elseif addon.playerRace == "Human" then
	StatLogic.StatModTable["Human"] = {
		["MOD_SPI"] = {
			-- Human: The Human Spirit - Racial
			--        Increase Spirit by 3%.
			{
				["value"] = 0.03,
				["race"] = "Human",
			},
		},
		[StatLogic.Stats.Expertise] = {
			{
				["value"] = 3,
				["weapon"] = {
					[Enum.ItemWeaponSubclass.Mace1H] = true,
					[Enum.ItemWeaponSubclass.Mace2H] = true,
					[Enum.ItemWeaponSubclass.Sword1H] = true,
					[Enum.ItemWeaponSubclass.Sword2H] = true,
				}
			}
		},
	}
elseif addon.playerRace == "Orc" then
	StatLogic.StatModTable["Orc"] = {
		[StatLogic.Stats.Expertise] = {
			{
				["value"] = 5,
				["weapon"] = {
					[Enum.ItemWeaponSubclass.Axe1H] = true,
					[Enum.ItemWeaponSubclass.Axe2H] = true,
					[Enum.ItemWeaponSubclass.Unarmed] = true,
				}
			}
		},
	}
elseif addon.playerRace == "Troll" then
	StatLogic.StatModTable["Troll"] = {
		["MOD_NORMAL_HEALTH_REG"] = {
			-- Troll: Regeneration - Racial
			--   Health regeneration rate increased by 10%.
			{
				["value"] = 0.1,
			},
		},
		["ADD_HEALTH_REG_MOD_NORMAL_HEALTH_REG"] = {
			-- Troll: Regeneration - Racial
			--   10% of total Health regeneration may continue during combat.
			{
				["value"] = 0.1,
				["spellid"] = 20555,
			},
		},
		[StatLogic.Stats.RangedCrit] = {
			{
				["value"] = 1,
				["weapon"] = {
					[Enum.ItemWeaponSubclass.Bows] = true,
					[Enum.ItemWeaponSubclass.Thrown] = true,
				}
			}
		},
	}
end

StatLogic.StatModTable["ALL"] = {
	["ADD_HEALTH_MOD_STA"] = {
		{
			["value"] = 10,
		},
	},
	["ADD_MANA_MOD_INT"] = {
		{
			["value"] = 15,
		},
	},
	["ADD_NORMAL_HEALTH_REG_MOD_SPI"] = {
		{
			["regen"] = NormalHealthRegenPerSpi,
		},
	},
	["ADD_BONUS_ARMOR_MOD_AGI"] = {
		{
			["value"] = ARMOR_PER_AGILITY,
		},
	},
	-- ICC: Chill of the Throne
	--      Chance to dodge reduced by 20%.
	["ADD_DODGE"] = {
		{
			["value"] = -20,
			["aura"] = 69127,		-- ["Chill of the Throne"],
		},
	},
	-- Replenishment - Buff
	--   Replenishes 1% of maximum mana per 5 sec.
	-- Priest: Vampiric Touch
	--         Priest's party or raid members gain 1% of their maximum mana per 5 sec when the priest deals damage from Mind Blast.
	-- Paladin: Judgements of the Wise
	--          Your damaging Judgement spells have a 100% chance to grant the Replenishment effect to
	--          up to 10 party or raid members mana regeneration equal to 1% of their maximum mana per 5 sec for 15 sec
	-- Hunter: Hunting Party
	--         Your Arcane Shot, Explosive Shot and Steady Shot critical strikes have a 100% chance to
	--         grant up to 10 party or raid members mana regeneration equal to 1% of the maximum mana per 5 sec.
	["ADD_MANA_REG_MOD_MANA"] = {
		{
			["value"] = 0.01,
			["aura"] = 57669,		-- ["Replenishment"],
		},
	},
	-- MetaGem: Eternal Earthsiege Diamond - 41396
	--          +21 Defense Rating and +5% Shield Block Value
	-- MetaGem: Eternal Earthstorm Diamond - 35501
	--          +12 Defense Rating and +5% Shield Block Value
	["MOD_BLOCK_VALUE"] = {
		{
			["value"] = 0.05,
			["meta"] = 41396,
		},
		{
			["value"] = 0.05,
			["meta"] = 35501,
		},
	},
	["MOD_ARMOR"] = {
		-- MetaGem: Austere Earthsiege Diamond - 41380
		--          +32 Stamina and 2% Increased Armor Value from Items
		{
			["value"] = 0.02,
			["meta"] = 41380,
		},
	},
	["MOD_AP"] = {
		-- Hunter: Trueshot Aura - Buff
		--         Attack power increased by 10%.
		{
			["value"] = 0.1,
			["aura"] = 19506,
			["group"] = addon.ExclusiveGroup.AttackPower,
		},
		-- Death Knight: Abomination's Might - Buff
		--               Attack power increased by 5/10%.
		{
			["rank"] = {
				0.05, 0.1,
			},
			["aura"] = 53138,
			["group"] = addon.ExclusiveGroup.AttackPower,
		},
		-- Shaman: Unleashed Rage - Buff
		--         Melee attack power increased by 4/7/10%.
		{
			["rank"] = {
				0.04, 0.07, 0.1,
			},
			["aura"] = 30809,
			["group"] = addon.ExclusiveGroup.AttackPower,
		},
	},
	-- MetaGem: Beaming Earthsiege Diamond - 41389
	--          +21 Critical Strike Rating and +2% Mana
	["MOD_MANA"] = {
		{
			["value"] = 0.02,
			["meta"] = 41389,
		},
	},
	["MOD_STR"] = {
		-- Paladin: Blessing of Kings, Greater Blessing of Kings - Buff
		--          Increases stats by 10%.
		{
			["value"] = 0.1,
			["aura"] = 20217,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		{
			["value"] = 0.1,
			["aura"] = 25898,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Blessing of Sanctuary
		{
			["value"] = 0.1,
			["aura"] = 20911,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Greater Blessing of Sanctuary
		{
			["value"] = 0.1,
			["aura"] = 25899,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Leatherworking: Blessing of Forgotten Kings - Buff
		--                 Increases stats by 8%.
		{
			["value"] = 0.08,
			["aura"] = 69378,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
	},
	["MOD_AGI"] = {
		-- Paladin: Blessing of Kings, Greater Blessing of Kings - Buff
		--          Increases stats by 10%.
		{
			["value"] = 0.1,
			["aura"] = 20217,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		{
			["value"] = 0.1,
			["aura"] = 25898,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Leatherworking: Blessing of Forgotten Kings - Buff
		--                 Increases stats by 8%.
		{
			["value"] = 0.08,
			["aura"] = 69378,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
	},
	["MOD_STA"] = {
		-- Paladin: Blessing of Kings, Greater Blessing of Kings - Buff
		--          Increases stats by 10%.
		{
			["value"] = 0.1,
			["aura"] = 20217,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		{
			["value"] = 0.1,
			["aura"] = 25898,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Blessing of Sanctuary
		{
			["value"] = 0.1,
			["aura"] = 20911,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Greater Blessing of Sanctuary
		{
			["value"] = 0.1,
			["aura"] = 25899,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Leatherworking: Blessing of Forgotten Kings - Buff
		--                 Increases stats by 8%.
		{
			["value"] = 0.08,
			["aura"] = 69378,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
	},
	["MOD_INT"] = {
		-- Paladin: Blessing of Kings, Greater Blessing of Kings - Buff
		--          Increases stats by 10%.
		{
			["value"] = 0.1,
			["aura"] = 20217,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		{
			["value"] = 0.1,
			["aura"] = 25898,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Leatherworking: Blessing of Forgotten Kings - Buff
		--                 Increases stats by 8%.
		{
			["value"] = 0.08,
			["aura"] = 69378,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- MetaGem: Ember Skyfire Diamond - 35503
		--          +14 Spell Power and +2% Intellect
		{
			["value"] = 0.02,
			["meta"] = 35503,
		},
		-- MetaGem: Ember Skyflare Diamond - 41333
		--          +25 Spell Power and +2% Intellect
		{
			["value"] = 0.02,
			["meta"] = 41333,
		},
	},
	["MOD_SPI"] = {
		-- Paladin: Blessing of Kings, Greater Blessing of Kings - Buff
		--          Increases stats by 10%.
		{
			["value"] = 0.1,
			["aura"] = 20217,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		{
			["value"] = 0.1,
			["aura"] = 25898,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Leatherworking: Blessing of Forgotten Kings - Buff
		--                 Increases stats by 8%.
		{
			["value"] = 0.08,
			["aura"] = 69378,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
	},
	["ADD_DODGE_REDUCTION_MOD_EXPERTISE"] = {
		-- Base
		{
			["value"] = 0.25,
		}
	},
	["ADD_PARRY_REDUCTION_MOD_EXPERTISE"] = {
		-- Base
		{
			["value"] = 0.25,
		}
	},
	["ADD_BLOCK_CHANCE_MOD_DEFENSE"] = {
		-- Passive: Block
		{
			["known"] = 107,
			["value"] = DODGE_PARRY_BLOCK_PERCENT_PER_DEFENSE,
		}
	},
	["ADD_CRIT_AVOIDANCE_MOD_DEFENSE"] = {
		-- Base
		{
			["value"] = DODGE_PARRY_BLOCK_PERCENT_PER_DEFENSE,
		}
	},
	["ADD_DODGE_MOD_DEFENSE"] = {
		-- Base
		{
			["value"] = DODGE_PARRY_BLOCK_PERCENT_PER_DEFENSE,
		}
	},
	["ADD_MISS_MOD_DEFENSE"] = {
		-- Base
		{
			["value"] = DODGE_PARRY_BLOCK_PERCENT_PER_DEFENSE,
		}
	},
	["ADD_PARRY_MOD_DEFENSE"] = {
		-- Passive: Parry
		{
			["known"] = 3127,
			["value"] = DODGE_PARRY_BLOCK_PERCENT_PER_DEFENSE,
		},
		-- Passive: Parry (Shaman)
		{
			["known"] = 18848,
			["value"] = DODGE_PARRY_BLOCK_PERCENT_PER_DEFENSE,
		},
	},
	["ADD_CRIT_AVOIDANCE_MOD_RESILIENCE"] = {
		-- Base
		{
			["value"] = 1,
		},
	},
	["ADD_CRIT_DAMAGE_REDUCTION_MOD_RESILIENCE"] = {
		-- Base
		{
			["value"] = -RESILIENCE_CRIT_CHANCE_TO_DAMAGE_REDUCTION_MULTIPLIER,
		},
	},
	["ADD_PVP_DAMAGE_REDUCTION_MOD_RESILIENCE"] = {
		-- Base
		{
			["value"] = -RESILIENCE_CRIT_CHANCE_TO_CONSTANT_DAMAGE_REDUCTION_MULTIPLIER,
		},
	},
}

--=====================================--
-- Avoidance stats diminishing returns --
--=====================================--
-- Formula reverse engineered by Whitetooth (hotdogee [at] gmail [dot] com)
--[[---------------------------------
This includes
1. Dodge from Dodge Rating, Defense, Agility.
2. Parry from Parry Rating, Defense.
3. Chance to be missed from Defense.

The following is the result of hours of work gathering data from beta servers and then spending even more time running multiple regression analysis on the data.

1. DR for Dodge, Parry, Missed are calculated separately.
2. Base avoidances are not affected by DR, (ex: Dodge from base Agility)
3. Death Knight's Parry from base Strength is affected by DR, base for parry is 5%.
4. Direct avoidance gains from talents and spells(ex: Evasion) are not affected by DR.
5. Indirect avoidance gains from talents and spells(ex: +Agility from Kings) are affected by DR
6. c and k values depend on class but does not change with level.

7. The DR formula:

1/x' = 1/c+k/x

x' is the diminished stat before converting to IEEE754.
x is the stat before diminishing returns.
c is the cap of the stat, and changes with class.
k is is a value that changes with class.
-----------------------------------]]
-- The following K, C_p, C_d are calculated by Whitetooth (hotdogee [at] gmail [dot] com)
local K = {
	["WARRIOR"]     = 0.956,
	["PALADIN"]     = 0.956,
	["HUNTER"]      = 0.988,
	["ROGUE"]       = 0.988,
	["PRIEST"]      = 0.983,
	["DEATHKNIGHT"] = 0.956,
	["SHAMAN"]      = 0.988,
	["MAGE"]        = 0.983,
	["WARLOCK"]     = 0.983,
	["DRUID"]       = 0.972,
}
local C_p = {
	["WARRIOR"]     = 1/0.021275,
	["PALADIN"]     = 1/0.021275,
	["HUNTER"]      = 1/0.006870,
	["ROGUE"]       = 1/0.006870,
	["PRIEST"]      = 0, --use tank stats
	["DEATHKNIGHT"] = 1/0.021275,
	["SHAMAN"]      = 1/0.006870,
	["MAGE"]        = 0, --use tank stats
	["WARLOCK"]     = 0, --use tank stats
	["DRUID"]       = 0, --use tank stats
}
local C_d = {
	["WARRIOR"]     = 1/0.011347,
	["PALADIN"]     = 1/0.011347,
	["HUNTER"]      = 1/0.006870,
	["ROGUE"]       = 1/0.006870,
	["PRIEST"]      = 1/0.006650,
	["DEATHKNIGHT"] = 1/0.011347,
	["SHAMAN"]      = 1/0.006870,
	["MAGE"]        = 1/0.006650,
	["WARLOCK"]     = 1/0.006650,
	["DRUID"]       = 1/0.008555,
}

-- I've done extensive tests that show the miss cap is 16% for warriors.
-- Because the only tank I have with 150 pieces of epic gear required for the tests is a warrior,
-- Until someone that has the will and gear to preform the tests for other classes, I'm going to assume the cap is the same(which most likely isn't)
local C_m = setmetatable({}, {
	__index = function()
		return 16
	end
})

function StatLogic:GetMissedChanceBeforeDR()
	local baseDefense, additionalDefense = UnitDefense("player")
	local defenseFromDefenseRating = floor(GetCombatRatingBonus(CR_DEFENSE_SKILL))
	local modMissed = defenseFromDefenseRating * 0.04
	local drFreeMissed = 5 + (baseDefense + additionalDefense - defenseFromDefenseRating) * 0.04
	return modMissed, drFreeMissed
end

local ModAgiClasses = {
	["DRUID"] = true,
	["HUNTER"] = true,
	["ROGUE"] = true,
}

--[[
Formula by Whitetooth (hotdogee [at] gmail [dot] com)
Calculates the dodge percentage per agility for your current class and level.
Only works for your currect class and current level, does not support class and level args.
Calculations got a bit more complicated with the introduction of the avoidance DR in WotLK, these are the values we know or can be calculated easily:
* D'=Total Dodge% after DR
* D_r=Dodge from Defense and Dodge Rating before DR
* D_b=Dodge unaffected by DR (BaseDodge + Dodge from talent/buffs + Lower then normal defense correction)
* A=Total Agility
* A_b=Base Agility (This is what you have with no gear on)
* A_g=Total Agility - Base Agility
* Let d be the Dodge/Agi value we are going to calculate.

```
 1     1     k
--- = --- + ---
 x'    c     x

x'=D'-D_b-A_b*d
x=A_g*d+D_r

1/(D'-D_b-A_b*d)=1/C_d+k/(A_g*d+D_r)=(A_g*d+D_r+C_d*k)/(C_d*A_g*d+C_d*D_r)

C_d*A_g*d+C_d*D_r=[(D'-D_b)-A_b*d]*[Ag*d+(D_r+C_d*k)]
```
After rearranging the terms, we get an equation of type `a*d^2+b*d+c` where
```
a=-A_g*A_b
b=A_g(D'-D_b)-A_b(D_r+C_d*k)-C_dA_g
c=(D'-D_b)(D_r+C_d*k)-C_d*D_r
Dodge/Agi=(-b-(b^2-4ac)^0.5)/(2a)
```
]]
---@return number dodge Dodge percentage per agility
function StatLogic:GetDodgePerAgi()
	local level = UnitLevel("player")
	-- Collect data
	local D_dr = GetDodgeChance()
	if D_dr == 0 then
		return 0
	end
	local dodgeFromDodgeRating = GetCombatRatingBonus(CR_DODGE)
	local baseDefense, modDefense = UnitDefense("player")
	local dodgeFromModDefense = modDefense * 0.04
	local D_r = dodgeFromDodgeRating + dodgeFromModDefense
	local D_b = self:GetStatMod("ADD_DODGE") + (baseDefense - level * 5) * 0.04
	local stat, effectiveStat, posBuff, negBuff = UnitStat("player", LE_UNIT_STAT_AGILITY)
	local modAgi = 1
	if ModAgiClasses[addon.class] then
		modAgi = self:GetStatMod("MOD_AGI")
		-- Talents that modify Agi will not add to posBuff, so we need to calculate baseAgi
		-- But Agi from Kings etc. will add to posBuff, so we subtract those if present
		for _, case in ipairs(StatLogic.StatModTable["ALL"]["MOD_AGI"]) do
			if case.group == addon.ExclusiveGroup.AllStats then
				if StatLogic:GetAuraInfo(case.aura) then
					modAgi = modAgi - case.value
				end
			end
		end
	end
	local A = effectiveStat
	local A_b = ceil((stat - posBuff - negBuff) / modAgi)
	local A_g = A - A_b
	local C = C_d[addon.class]
	local k = K[addon.class]
	-- Solve a*x^2+b*x+c
	local a = -A_g*A_b
	local b = A_g*(D_dr-D_b)-A_b*(D_r+C*k)-C*A_g
	local c = (D_dr-D_b)*(D_r+C*k)-C*D_r

	local dodgePerAgi
	if a == 0 then
		dodgePerAgi = -c / b
	else
		dodgePerAgi = (-b-(b^2-4*a*c)^0.5)/(2*a)
	end

	return dodgePerAgi
end

--[[
Calculates your current Dodge% before diminishing returns.
Dodge% = modDodge + drFreeDodge

drFreeDodge includes:
* Base dodge
* Dodge from base agility
* Dodge modifier from base defense
* Dodge modifers from talents or spells

modDodge includes
* Dodge from dodge rating
* Dodge from additional defense
* Dodge from additional dodge
]]
---@return number modDodge The part that is affected by diminishing returns.
---@return number drFreeDodge The part that isn't affected by diminishing returns.
function StatLogic:GetDodgeChanceBeforeDR()
	local stat, effectiveStat, posBuff, negBuff = UnitStat("player", LE_UNIT_STAT_AGILITY)
	local baseAgi = stat - posBuff - negBuff
	local dodgePerAgi = self:GetDodgePerAgi()
	local dodgeFromDodgeRating = GetCombatRatingBonus(CR_DODGE)
	local dodgeFromDefenceRating = floor(GetCombatRatingBonus(CR_DEFENSE_SKILL)) * 0.04
	local dodgeFromAdditionalAgi = dodgePerAgi * (effectiveStat - baseAgi)
	local modDodge = dodgeFromDodgeRating + dodgeFromDefenceRating + dodgeFromAdditionalAgi

	local drFreeDodge = GetDodgeChance() - self:GetAvoidanceAfterDR(StatLogic.Stats.Dodge, modDodge)

	return modDodge, drFreeDodge
end

--[[
Calculates your current Parry% before diminishing returns.
Parry% = modParry + drFreeParry

drFreeParry includes:
* Base parry
* Parry from base agility
* Parry modifier from base defense
* Parry modifers from talents or spells

modParry includes
* Parry from parry rating
* Parry from additional defense
* Parry from additional parry
]]
---@return number modParry The part that is affected by diminishing returns.
---@return number drFreeParry The part that isn't affected by diminishing returns.
function StatLogic:GetParryChanceBeforeDR()
	-- Defense is floored
	local parryFromParryRating = GetCombatRatingBonus(CR_PARRY)
	local parryFromDefenceRating = floor(GetCombatRatingBonus(CR_DEFENSE_SKILL)) * 0.04
	local modParry = parryFromParryRating + parryFromDefenceRating

	-- drFreeParry
	local drFreeParry = GetParryChance() - self:GetAvoidanceAfterDR(StatLogic.Stats.Parry, modParry)

	return modParry, drFreeParry
end

--[[
Avoidance DR formula and k, C_p, C_d constants derived by Whitetooth (hotdogee [at] gmail [dot] com)
avoidanceBeforeDR is the part that is affected by diminishing returns.
See :GetClassIdOrName(class) for valid class values.

Calculates the avoidance after diminishing returns, this includes:
* Dodge from Dodge Rating, Defense, Agility.
* Parry from Parry Rating, Defense.
* Chance to be missed from Defense.

The DR formula: 1/x' = 1/c+k/x
* x' is the diminished stat before converting to IEEE754.
* x is the stat before diminishing returns.
* c is the cap of the stat, and changes with class.
* k is is a value that changes with class.

Formula details:
* DR for Dodge, Parry, Missed are calculated separately.
* Base avoidances are not affected by DR, (ex: Dodge from base Agility)
* Death Knight's Parry from base Strength is affected by DR, base for parry is 5%.
* Direct avoidance gains from talents and spells(ex: Evasion) are not affected by DR.
* Indirect avoidance gains from talents and spells(ex: +Agility from Kings) are affected by DR
* c and k values depend on class but does not change with level.
]]
---@param stat `StatLogic.Stats.Dodge`|`StatLogic.Stats.Parry`|`StatLogic.Stats.Miss`
---@param avoidanceBeforeDR number Amount of avoidance before diminishing returns in percentages.
---@return number avoidanceAfterDR Avoidance after diminishing returns in percentages.
function StatLogic:GetAvoidanceAfterDR(stat, avoidanceBeforeDR)
	-- argCheck for invalid input
	self:argCheck(stat, 2, "table")
	self:argCheck(avoidanceBeforeDR, 3, "number")

	local C = C_d
	if stat == StatLogic.Stats.Parry then
		C = C_p
	elseif stat == StatLogic.Stats.Miss then
		C = C_m
	end

	if avoidanceBeforeDR > 0 then
		local class = addon.class
		return 1 / (1 / C[class] + K[class] / avoidanceBeforeDR)
	else
		return 0
	end
end

-- Calculates the avoidance gain after diminishing returns with player's current stats.
---@param stat `StatLogic.Stats.Dodge`|`StatLogic.Stats.Parry`|`StatLogic.Stats.Miss`
---@param gainBeforeDR number Avoidance gain before diminishing returns in percentages.
---@return number gainAfterDR Avoidance gain after diminishing returns in percentages.
function StatLogic:GetAvoidanceGainAfterDR(stat, gainBeforeDR)
	-- argCheck for invalid input
	self:argCheck(gainBeforeDR, 2, "number")

	if stat == StatLogic.Stats.Parry then
		local modAvoidance, drFreeAvoidance = self:GetParryChanceBeforeDR()
		local newAvoidanceChance = self:GetAvoidanceAfterDR(stat, modAvoidance + gainBeforeDR) + drFreeAvoidance
		if newAvoidanceChance < 0 then newAvoidanceChance = 0 end
		return newAvoidanceChance - GetParryChance()
	elseif stat == StatLogic.Stats.Dodge then
		local modAvoidance, drFreeAvoidance = self:GetDodgeChanceBeforeDR()
		local newAvoidanceChance = self:GetAvoidanceAfterDR(stat, modAvoidance + gainBeforeDR) + drFreeAvoidance
		if newAvoidanceChance < 0 then newAvoidanceChance = 0 end -- because GetDodgeChance() is 0 when negative
		return newAvoidanceChance - GetDodgeChance()
	elseif stat == StatLogic.Stats.Miss then
		local modAvoidance = self:GetMissedChanceBeforeDR()
		return self:GetAvoidanceAfterDR(stat, modAvoidance + gainBeforeDR) - self:GetAvoidanceAfterDR(stat, modAvoidance)
	else
		return gainBeforeDR
	end
end