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

-- Level 60 rating base
StatLogic.RatingBase = {
	[StatLogic.Stats.DodgeRating] = 13.8,
	[StatLogic.Stats.ParryRating] = 13.8,
	[StatLogic.Stats.BlockRating] = 6.9,
	[StatLogic.Stats.MeleeHitRating] = 9.37931,
	[StatLogic.Stats.RangedHitRating] = 9.37931,
	[StatLogic.Stats.SpellHitRating] = 8,
	[StatLogic.Stats.MeleeCritRating] = 14,
	[StatLogic.Stats.RangedCritRating] = 14,
	[StatLogic.Stats.SpellCritRating] = 14,
	[StatLogic.Stats.ResilienceRating] = 7.96417713165283,
	[StatLogic.Stats.MeleeHasteRating] = 10,
	[StatLogic.Stats.RangedHasteRating] = 10,
	[StatLogic.Stats.SpellHasteRating] = 10,
	[StatLogic.Stats.ExpertiseRating] = 2.34483,
	[StatLogic.Stats.MasteryRating] = 14,
}

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.020979, 0.020515, 0.020079, 0.019516, 0.018997, 0.018646, 0.018314, 0.017997, 0.017584, 0.017197,
	0.016551, 0.015729, 0.015229, 0.014580, 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,
	0.003345, 0.003345, 0.003345, 0.003345, 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 gtChanceToMeleeCrit.db2 or from gametables/chancetomeleecrit.txt
addon.CritPerAgi = {
	["WARRIOR"] = {
		0.24999999, 0.23809499, 0.23809499, 0.22727300, 0.21739099, 0.20833299, 0.20833299, 0.20000001, 0.19230800, 0.19230800,
		0.18518500, 0.17857100, 0.16666700, 0.16129001, 0.15625000, 0.15151500, 0.14705900, 0.13888900, 0.13513500, 0.12820500,
		0.12820500, 0.12500000, 0.11904800, 0.11627900, 0.11111100, 0.10869600, 0.10638300, 0.10204100, 0.10000000, 0.09615380,
		0.09433960, 0.09259260, 0.08928570, 0.08771930, 0.08474580, 0.08333330, 0.08196720, 0.07936510, 0.07812500, 0.07575760,
		0.07352940, 0.07246380, 0.07042250, 0.06944440, 0.06756760, 0.06666670, 0.06493510, 0.06329110, 0.06250000, 0.06097560,
		0.05952380, 0.05882350, 0.05747130, 0.05617980, 0.05494510, 0.05434780, 0.05319150, 0.05208330, 0.05102040, 0.05000000,
		0.04761900, 0.04545450, 0.04347830, 0.04166670, 0.04000000, 0.03846150, 0.03703700, 0.03571430, 0.03448280, 0.03333330,
		0.03105590, 0.02873560, 0.02673800, 0.02487560, 0.02314810, 0.02145920, 0.01992030, 0.01851850, 0.01724140, 0.01602560,
		0.01219510, 0.00929368, 0.00707214, 0.00538793, 0.00410509,
	},
	["PALADIN"] = {
		0.21740000, 0.20704800, 0.20704800, 0.19763601, 0.19763601, 0.18904300, 0.18904300, 0.18116700, 0.18116700, 0.17392000,
		0.17392000, 0.16723101, 0.15528600, 0.15528600, 0.14493300, 0.14493300, 0.14025799, 0.13175800, 0.13175800, 0.12422900,
		0.12077800, 0.12077800, 0.11442100, 0.11148700, 0.10870000, 0.10604900, 0.10352400, 0.10111600, 0.09881820, 0.09452170,
		0.09251060, 0.09251060, 0.08873470, 0.08696000, 0.08361540, 0.08203770, 0.08203770, 0.07905450, 0.07764290, 0.07496550,
		0.07369490, 0.07369490, 0.07127870, 0.07012900, 0.06793750, 0.06689230, 0.06587880, 0.06394120, 0.06301450, 0.06123940,
		0.06038890, 0.05956160, 0.05797330, 0.05721050, 0.05574360, 0.05503800, 0.05435000, 0.05302440, 0.05238550, 0.05115290,
		0.04940910, 0.04831110, 0.04726090, 0.04576840, 0.04482470, 0.04391920, 0.04262750, 0.04180770, 0.04101890, 0.04025930,
		0.03716240, 0.03450790, 0.03220740, 0.02978080, 0.02769430, 0.02572780, 0.02389010, 0.02229740, 0.02070480, 0.01923890,
		0.01463970, 0.01114870, 0.00849219, 0.00647024, 0.00492412,
	},
	["HUNTER"] = {
		0.28400000, 0.28343401, 0.27107401, 0.25299001, 0.24300499, 0.23373601, 0.22510700, 0.21705499, 0.20513700, 0.19836400,
		0.18475300, 0.16697299, 0.15469900, 0.14408800, 0.13299300, 0.12666400, 0.11942200, 0.11166499, 0.10597800, 0.09980580,
		0.09615530, 0.09103050, 0.08718610, 0.08293830, 0.07972230, 0.07674040, 0.07341370, 0.07086710, 0.06801100, 0.06537160,
		0.06374390, 0.06141140, 0.05923970, 0.05754870, 0.05563030, 0.05412970, 0.05242280, 0.05081710, 0.04930400, 0.04811060,
		0.04697090, 0.04566750, 0.04443200, 0.04325920, 0.04214440, 0.04125640, 0.04023690, 0.03910780, 0.03818660, 0.03730590,
		0.03659920, 0.03578580, 0.03500600, 0.03413840, 0.03342470, 0.03284840, 0.03207870, 0.03144320, 0.03073430, 0.03014770,
		0.02967120, 0.02903510, 0.02842440, 0.02791680, 0.02734930, 0.02695050, 0.02641880, 0.02590650, 0.02541250, 0.02499810,
		0.02323340, 0.02159330, 0.02006910, 0.01865240, 0.01733570, 0.01611190, 0.01497460, 0.01391750, 0.01293510, 0.01202200,
		0.00915552, 0.00697209, 0.00530727, 0.00404195, 0.00307831,
	},
	["ROGUE"] = {
		0.44760900, 0.42895800, 0.41180002, 0.38129601, 0.36767900, 0.35500000, 0.33209701, 0.32171900, 0.31196999, 0.29414301,
		0.26397400, 0.23941901, 0.21447900, 0.19798100, 0.17750000, 0.16604800, 0.15598499, 0.14500000, 0.13546100, 0.12709900,
		0.11970900, 0.11438900, 0.10836800, 0.10399000, 0.09804760, 0.09359090, 0.09030700, 0.08651260, 0.08302420, 0.07919230,
		0.07682840, 0.07406470, 0.07149310, 0.06909400, 0.06641940, 0.06434370, 0.06277440, 0.06091720, 0.05916670, 0.05719440,
		0.05564860, 0.05418420, 0.05279490, 0.05121890, 0.04973430, 0.04856130, 0.04744240, 0.04637390, 0.04535240, 0.04399570,
		0.04307530, 0.04219260, 0.04118000, 0.04037250, 0.03944440, 0.03855810, 0.03784930, 0.03703240, 0.03637810, 0.03550000,
		0.03343390, 0.03217750, 0.03063990, 0.02959690, 0.02861530, 0.02767470, 0.02680990, 0.02618690, 0.02560950, 0.02499880,
		0.02323930, 0.02158280, 0.02006820, 0.01865040, 0.01733160, 0.01611110, 0.01496370, 0.01391220, 0.01293340, 0.01202690,
		0.00915925, 0.00697493, 0.00530944, 0.00404360, 0.00307957,
	},
	["PRIEST"] = {
		0.09117500, 0.09117500, 0.09117500, 0.08683330, 0.08683330, 0.08683330, 0.08683330, 0.08288640, 0.08288640, 0.08288640,
		0.08288640, 0.07928260, 0.07928260, 0.07928260, 0.07928260, 0.07597920, 0.07597920, 0.07597920, 0.07294000, 0.07294000,
		0.07294000, 0.07294000, 0.07013460, 0.07013460, 0.07013460, 0.06753700, 0.06753700, 0.06753700, 0.06512500, 0.06512500,
		0.06512500, 0.06287930, 0.06287930, 0.06287930, 0.06078330, 0.06078330, 0.06078330, 0.05882260, 0.05882260, 0.05882260,
		0.05698440, 0.05698440, 0.05525760, 0.05525760, 0.05525760, 0.05363240, 0.05363240, 0.05210000, 0.05210000, 0.05210000,
		0.05065280, 0.05065280, 0.04928380, 0.04928380, 0.04798680, 0.04798680, 0.04675640, 0.04675640, 0.04558750, 0.04558750,
		0.04449120, 0.04458550, 0.04426580, 0.04344670, 0.04271900, 0.04207770, 0.04151880, 0.04133470, 0.04117830, 0.04014610,
		0.03721430, 0.03440570, 0.03199120, 0.02989340, 0.02762880, 0.02568310, 0.02399340, 0.02223780, 0.02072160, 0.01919470,
		0.01461810, 0.01113190, 0.00847380, 0.00645353, 0.00491496,
	},
	["DEATHKNIGHT"] = {
		0.24999999, 0.23809499, 0.23809499, 0.22727300, 0.21739099, 0.20833299, 0.20833299, 0.20000001, 0.19230800, 0.19230800,
		0.18518500, 0.17857100, 0.16666700, 0.16129001, 0.15625000, 0.15151500, 0.14705900, 0.13888900, 0.13513500, 0.12820500,
		0.12820500, 0.12500000, 0.11904800, 0.11627900, 0.11111100, 0.10869600, 0.10638300, 0.10204100, 0.10000000, 0.09615380,
		0.09433960, 0.09259260, 0.08928570, 0.08771930, 0.08474580, 0.08333330, 0.08196720, 0.07936510, 0.07812500, 0.07575760,
		0.07352940, 0.07246380, 0.07042250, 0.06944440, 0.06756760, 0.06666670, 0.06493510, 0.06329110, 0.06250000, 0.06097560,
		0.05952380, 0.05882350, 0.05747130, 0.05617980, 0.05494510, 0.05434780, 0.05319150, 0.05208330, 0.05102040, 0.05000000,
		0.04761900, 0.04545450, 0.04347830, 0.04166670, 0.04000000, 0.03846150, 0.03703700, 0.03571430, 0.03448280, 0.03333330,
		0.03105590, 0.02873560, 0.02673800, 0.02487560, 0.02314810, 0.02145920, 0.01992030, 0.01851850, 0.01724140, 0.01602560,
		0.01220460, 0.00929400, 0.00707475, 0.00538804, 0.00410348,
	},
	["SHAMAN"] = {
		0.10390000, 0.10390000, 0.09895239, 0.09895239, 0.09445450, 0.09445450, 0.09445450, 0.09034780, 0.09034780, 0.08658330,
		0.08658330, 0.08312000, 0.08312000, 0.07992310, 0.07696300, 0.07421430, 0.07421430, 0.07165520, 0.07165520, 0.06703230,
		0.06703230, 0.06493750, 0.06493750, 0.06296970, 0.06111760, 0.05937140, 0.05937140, 0.05772220, 0.05772220, 0.05468420,
		0.05468420, 0.05328210, 0.05195000, 0.05195000, 0.04947620, 0.04832560, 0.04832560, 0.04722730, 0.04722730, 0.04517390,
		0.04421280, 0.04421280, 0.04329170, 0.04240820, 0.04156000, 0.04074510, 0.03996150, 0.03920750, 0.03920750, 0.03778180,
		0.03710710, 0.03645610, 0.03645610, 0.03582760, 0.03463330, 0.03406560, 0.03351610, 0.03351610, 0.03298410, 0.03196920,
		0.03102490, 0.03040300, 0.02935380, 0.02848270, 0.02807010, 0.02734040, 0.02668210, 0.02608150, 0.02552060, 0.02499630,
		0.02323170, 0.02159180, 0.02006760, 0.01865100, 0.01733440, 0.01611080, 0.01497350, 0.01391650, 0.01293410, 0.01202110,
		0.00915486, 0.00697159, 0.00530689, 0.00404166, 0.00307809,
	},
	["MAGE"] = {
		0.07730000, 0.07730000, 0.07730000, 0.07361900, 0.07361900, 0.07361900, 0.07361900, 0.07361900, 0.07361900, 0.07027270,
		0.07027270, 0.07027270, 0.07027270, 0.07027270, 0.06721740, 0.06721740, 0.06721740, 0.06721740, 0.06721740, 0.06441670,
		0.06441670, 0.06441670, 0.06441670, 0.06184000, 0.06184000, 0.06184000, 0.06184000, 0.06184000, 0.05946150, 0.05946150,
		0.05946150, 0.05946150, 0.05725930, 0.05725930, 0.05725930, 0.05521430, 0.05521430, 0.05521430, 0.05521430, 0.05331030,
		0.05331030, 0.05331030, 0.05331030, 0.05153330, 0.05153330, 0.05153330, 0.04987100, 0.04987100, 0.04987100, 0.04831250,
		0.04831250, 0.04831250, 0.04684850, 0.04684850, 0.04684850, 0.04547060, 0.04547060, 0.04547060, 0.04417140, 0.04417140,
		0.04417140, 0.04417140, 0.04294440, 0.04294440, 0.04294440, 0.04178380, 0.04178380, 0.04178380, 0.04068420, 0.04068420,
		0.03770730, 0.03513640, 0.03289360, 0.03031370, 0.02810910, 0.02620340, 0.02415630, 0.02273530, 0.02089190, 0.01956960,
		0.01486540, 0.01136760, 0.00863687, 0.00657872, 0.00500324,
	},
	["WARLOCK"] = {
		0.11890000, 0.11890000, 0.11323800, 0.11323800, 0.11323800, 0.10809100, 0.10809100, 0.10809100, 0.10339100, 0.10339100,
		0.09908330, 0.09908330, 0.09908330, 0.09588690, 0.09435100, 0.09284450, 0.09136670, 0.08991690, 0.08849440, 0.08709860,
		0.08572890, 0.08438450, 0.08306500, 0.08176980, 0.08049830, 0.07924990, 0.07802420, 0.07682060, 0.07563860, 0.07447780,
		0.07333770, 0.07221780, 0.07111760, 0.07003690, 0.06897500, 0.06793170, 0.06690650, 0.06589910, 0.06490910, 0.06393600,
		0.06297960, 0.06203950, 0.06111540, 0.06020690, 0.05931370, 0.05843550, 0.05757210, 0.05672300, 0.05588810, 0.05506700,
		0.05425950, 0.05346520, 0.05268400, 0.05191560, 0.05115970, 0.05041610, 0.04968460, 0.04896490, 0.04825680, 0.04756000,
		0.04687440, 0.04619980, 0.04553590, 0.04488250, 0.04423950, 0.04360670, 0.04298380, 0.04237070, 0.04176730, 0.04117320,
		0.03835480, 0.03549250, 0.03302780, 0.03088310, 0.02865060, 0.02642220, 0.02451550, 0.02286540, 0.02123210, 0.01981670,
		0.01509170, 0.01149260, 0.00874836, 0.00666263, 0.00507420,
	},
	["DRUID"] = {
		0.12622500, 0.12622500, 0.12021400, 0.12021400, 0.11475000, 0.11475000, 0.10976100, 0.10976100, 0.10518699, 0.09709620,
		0.09350000, 0.09350000, 0.09016070, 0.09016070, 0.08415000, 0.08415000, 0.08143550, 0.07889060, 0.07889060, 0.07012500,
		0.07012500, 0.06822970, 0.06643420, 0.06643420, 0.06311250, 0.06311250, 0.06157320, 0.06010710, 0.06010710, 0.05488040,
		0.05371280, 0.05371280, 0.05259370, 0.05152040, 0.05049000, 0.04950000, 0.04854810, 0.04854810, 0.04763210, 0.04428950,
		0.04352590, 0.04352590, 0.04278810, 0.04207500, 0.04071770, 0.04007140, 0.04007140, 0.03944530, 0.03883850, 0.03658700,
		0.03606430, 0.03555630, 0.03506250, 0.03506250, 0.03411490, 0.03366000, 0.03321710, 0.03278570, 0.03236540, 0.03078660,
		0.02988460, 0.02950110, 0.02849640, 0.02791070, 0.02738060, 0.02690250, 0.02647340, 0.02577280, 0.02537310, 0.02499810,
		0.02323340, 0.02159330, 0.02006910, 0.01865240, 0.01733570, 0.01611190, 0.01497460, 0.01391750, 0.01293510, 0.01202200,
		0.00915552, 0.00697209, 0.00530727, 0.00404195, 0.00307831,
	},
}

-- Extracted from gtChanceToSpellCrit.db2 or from gametables/chancetospellcrit.txt
addon.SpellCritPerInt = {
	["WARRIOR"] = addon.zero,
	["PALADIN"] = {
		0.08322500, 0.07926190, 0.07926190, 0.07565910, 0.07565910, 0.07236960, 0.06935420, 0.06935420, 0.06658000, 0.06658000,
		0.06401920, 0.06164810, 0.05944640, 0.05739660, 0.05369350, 0.05369350, 0.05201560, 0.04895590, 0.04895590, 0.04623610,
		0.04498650, 0.04380260, 0.04267950, 0.04161250, 0.03963100, 0.03870930, 0.03870930, 0.03698890, 0.03618480, 0.03467710,
		0.03396940, 0.03329000, 0.03263730, 0.03200960, 0.03082410, 0.03026360, 0.02972320, 0.02869830, 0.02821190, 0.02728690,
		0.02684680, 0.02642060, 0.02560770, 0.02560770, 0.02484330, 0.02447790, 0.02377860, 0.02311810, 0.02280140, 0.02219330,
		0.02190130, 0.02161690, 0.02106960, 0.02080620, 0.02029880, 0.02005420, 0.01981550, 0.01913220, 0.01891480, 0.01849440,
		0.01585240, 0.01541200, 0.01486160, 0.01447390, 0.01398740, 0.01364340, 0.01342340, 0.01310630, 0.01280380, 0.01251500,
		0.01162640, 0.01079820, 0.01005530, 0.00934361, 0.00868896, 0.00807199, 0.00749542, 0.00697189, 0.00647547, 0.00601838,
		0.00458339, 0.00349034, 0.00265690, 0.00202346, 0.00154105, 0.00072153, 0.00050666, 0.00035578, 0.00024983, 0.00017543,
		0.00012319, 0.00008650, 0.00006074, 0.00004265, 0.00002995, 0.00002103, 0.00001477, 0.00001037, 0.00000728, 0.00000511,
	},
	["HUNTER"] = {
		0.06990000, 0.06657140, 0.06657140, 0.06354550, 0.06354550, 0.06078260, 0.06078260, 0.05825000, 0.05825000, 0.05592000,
		0.05592000, 0.05376920, 0.04992860, 0.04992860, 0.04660000, 0.04660000, 0.04509680, 0.04236360, 0.04236360, 0.03994290,
		0.03883330, 0.03883330, 0.03678950, 0.03584620, 0.03495000, 0.03409760, 0.03328570, 0.03251160, 0.03177270, 0.03039130,
		0.02974470, 0.02974470, 0.02853060, 0.02796000, 0.02688460, 0.02637740, 0.02637740, 0.02541820, 0.02496430, 0.02410340,
		0.02369490, 0.02369490, 0.02291800, 0.02254840, 0.02184380, 0.02150770, 0.02118180, 0.02055880, 0.02026090, 0.01969010,
		0.01941670, 0.01915070, 0.01864000, 0.01839470, 0.01792310, 0.01769620, 0.01747500, 0.01704880, 0.01684340, 0.01644710,
		0.01571290, 0.01539680, 0.01496970, 0.01442100, 0.01406840, 0.01375000, 0.01333460, 0.01303730, 0.01275940, 0.01250000,
		0.01162640, 0.01079820, 0.01005530, 0.00934361, 0.00868896, 0.00807199, 0.00749542, 0.00697189, 0.00647547, 0.00601838,
		0.00458339, 0.00349034, 0.00265690, 0.00202346, 0.00154105, 0.00072153, 0.00050666, 0.00035578, 0.00024983, 0.00017543,
		0.00012319, 0.00008650, 0.00006074, 0.00004265, 0.00002995, 0.00002103, 0.00001477, 0.00001037, 0.00000728, 0.00000511,
	},
	["ROGUE"] = addon.zero,
	["PRIEST"] = {
		0.17102300, 0.16358700, 0.15677100, 0.15050001, 0.13935200, 0.13437500, 0.12974100, 0.12541700, 0.12137101, 0.11401500,
		0.10451400, 0.09406250, 0.08750000, 0.07838540, 0.07235580, 0.06840910, 0.06270830, 0.05972220, 0.05615670, 0.05225690,
		0.05016670, 0.04703120, 0.04533130, 0.04275570, 0.04089670, 0.03919270, 0.03762500, 0.03617790, 0.03483800, 0.03329650,
		0.03215810, 0.03109500, 0.03010000, 0.02894230, 0.02807840, 0.02726450, 0.02631120, 0.02559520, 0.02491720, 0.02411860,
		0.02351560, 0.02280300, 0.02226330, 0.02162360, 0.02101960, 0.02056010, 0.02001330, 0.01959640, 0.01909900, 0.01862620,
		0.01826460, 0.01783180, 0.01750000, 0.01710230, 0.01664820, 0.01635870, 0.01601060, 0.01574270, 0.01535710, 0.01505000,
		0.01481300, 0.01447120, 0.01425190, 0.01393520, 0.01368180, 0.01343750, 0.01320180, 0.01297410, 0.01271110, 0.01250000,
		0.01162640, 0.01079820, 0.01005530, 0.00934361, 0.00868896, 0.00807199, 0.00749542, 0.00697189, 0.00647547, 0.00601838,
		0.00458339, 0.00349034, 0.00265690, 0.00202346, 0.00154105, 0.00072153, 0.00050666, 0.00035578, 0.00024983, 0.00017543,
		0.00012319, 0.00008650, 0.00006074, 0.00004265, 0.00002995, 0.00002103, 0.00001477, 0.00001037, 0.00000728, 0.00000511,
	},
	["DEATHKNIGHT"] = addon.zero,
	["SHAMAN"] = {
		0.13328600, 0.12722700, 0.12169600, 0.12169600, 0.11662500, 0.11196000, 0.10765400, 0.10366699, 0.09996430, 0.09996430,
		0.09330000, 0.08746880, 0.07997140, 0.07564860, 0.06997500, 0.06664290, 0.06361360, 0.05955320, 0.05712240, 0.05382690,
		0.05183330, 0.04998210, 0.04744070, 0.04588520, 0.04373440, 0.04240910, 0.04116180, 0.03942250, 0.03834250, 0.03682890,
		0.03543040, 0.03455560, 0.03332140, 0.03254650, 0.03144940, 0.03042390, 0.02977660, 0.02885570, 0.02827270, 0.02717480,
		0.02665710, 0.02615890, 0.02544550, 0.02476990, 0.02412930, 0.02352100, 0.02313220, 0.02257260, 0.02203940, 0.02153080,
		0.02104510, 0.02073330, 0.02013670, 0.01985110, 0.01930340, 0.01904080, 0.01866000, 0.01817530, 0.01794230, 0.01749370,
		0.01638980, 0.01585240, 0.01519880, 0.01467380, 0.01422450, 0.01378730, 0.01338800, 0.01307380, 0.01277850, 0.01250000,
		0.01162640, 0.01079820, 0.01005530, 0.00934361, 0.00868896, 0.00807199, 0.00749542, 0.00697189, 0.00647547, 0.00601838,
		0.00458339, 0.00349034, 0.00265690, 0.00202346, 0.00154105, 0.00072153, 0.00050666, 0.00035578, 0.00024983, 0.00017543,
		0.00012319, 0.00008650, 0.00006074, 0.00004265, 0.00002995, 0.00002103, 0.00001477, 0.00001037, 0.00000728, 0.00000511,
	},
	["MAGE"] = {
		0.16370000, 0.15740400, 0.15157399, 0.14112100, 0.13641700, 0.13201600, 0.12789100, 0.12401500, 0.11692900, 0.11368101,
		0.10493600, 0.09301140, 0.08707450, 0.07308040, 0.06709020, 0.06394530, 0.06018380, 0.05684030, 0.05384870, 0.05052470,
		0.04872020, 0.04598310, 0.04448370, 0.04219070, 0.04051980, 0.03897620, 0.03720450, 0.03382230, 0.03248020, 0.03124050,
		0.03054100, 0.02944240, 0.02861890, 0.02784010, 0.02692430, 0.02623400, 0.02541930, 0.02480300, 0.02407350, 0.02352010,
		0.02299160, 0.02153950, 0.02109540, 0.02056530, 0.02006130, 0.01967550, 0.01921360, 0.01877290, 0.01835200, 0.01794960,
		0.01764010, 0.01726790, 0.01698130, 0.01656880, 0.01624010, 0.01544340, 0.01510150, 0.01488180, 0.01456410, 0.01430940,
		0.01430940, 0.01430940, 0.01430940, 0.01425960, 0.01421010, 0.01377950, 0.01337420, 0.01311700, 0.01282920, 0.01251530,
		0.01162640, 0.01079820, 0.01005530, 0.00934361, 0.00868896, 0.00807199, 0.00749542, 0.00697189, 0.00647547, 0.00601838,
		0.00458339, 0.00349034, 0.00265690, 0.00202346, 0.00154105, 0.00072153, 0.00050666, 0.00035578, 0.00024983, 0.00017543,
		0.00012319, 0.00008650, 0.00006074, 0.00004265, 0.00002995, 0.00002103, 0.00001477, 0.00001037, 0.00000728, 0.00000511,
	},
	["WARLOCK"] = {
		0.15000000, 0.14347800, 0.13750000, 0.13200000, 0.12692300, 0.12222200, 0.11785700, 0.11379300, 0.11000000, 0.10645200,
		0.09705880, 0.08918920, 0.08250000, 0.07674420, 0.07173910, 0.06875000, 0.06346150, 0.06000000, 0.05689660, 0.05409840,
		0.05156250, 0.04925370, 0.04714290, 0.04459460, 0.04285710, 0.04177220, 0.03975900, 0.03837210, 0.03666670, 0.03548390,
		0.03473680, 0.03333330, 0.03235290, 0.03113210, 0.03027520, 0.02946430, 0.02844830, 0.02773110, 0.02682930, 0.02619050,
		0.02558140, 0.02481200, 0.02426470, 0.02357140, 0.02291670, 0.02244900, 0.02200000, 0.02142860, 0.02088610, 0.02037040,
		0.02000000, 0.01952660, 0.01907510, 0.01864410, 0.01823200, 0.01793480, 0.01755320, 0.01718750, 0.01683670, 0.01650000,
		0.01590570, 0.01540280, 0.01476210, 0.01428430, 0.01384890, 0.01345140, 0.01302730, 0.01273350, 0.01261620, 0.01250000,
		0.01162640, 0.01079820, 0.01005530, 0.00934361, 0.00868896, 0.00807199, 0.00749542, 0.00697189, 0.00647547, 0.00601838,
		0.00458339, 0.00349034, 0.00265690, 0.00202346, 0.00154105, 0.00072153, 0.00050666, 0.00035578, 0.00024983, 0.00017543,
		0.00012319, 0.00008650, 0.00006074, 0.00004265, 0.00002995, 0.00002103, 0.00001477, 0.00001037, 0.00000728, 0.00000511,
	},
	["DRUID"] = {
		0.14311400, 0.13689100, 0.13118699, 0.12594000, 0.12109600, 0.11661100, 0.11244600, 0.11244600, 0.10856900, 0.09839060,
		0.09260290, 0.08509460, 0.08073080, 0.07496430, 0.06844570, 0.06559370, 0.06173530, 0.05940570, 0.05622320, 0.05161480,
		0.04997620, 0.04770450, 0.04630150, 0.04372920, 0.04198000, 0.04088960, 0.03935630, 0.03839630, 0.03661050, 0.03459890,
		0.03385480, 0.03245880, 0.03180300, 0.03086760, 0.02970280, 0.02915280, 0.02836490, 0.02761840, 0.02691030, 0.02559760,
		0.02518800, 0.02440700, 0.02403440, 0.02332220, 0.02281520, 0.02232980, 0.02186460, 0.02141840, 0.02085100, 0.02018270,
		0.01980190, 0.01931600, 0.01908180, 0.01863020, 0.01819940, 0.01788920, 0.01758940, 0.01729950, 0.01692740, 0.01639840,
		0.01615360, 0.01565850, 0.01502430, 0.01457140, 0.01415760, 0.01373170, 0.01334290, 0.01305880, 0.01277080, 0.01250000,
		0.01162640, 0.01079820, 0.01005530, 0.00934361, 0.00868896, 0.00807199, 0.00749542, 0.00697189, 0.00647547, 0.00601838,
		0.00458339, 0.00349034, 0.00265690, 0.00202346, 0.00154105, 0.00072153, 0.00050666, 0.00035578, 0.00024983, 0.00017543,
		0.00012319, 0.00008650, 0.00006074, 0.00004265, 0.00002995, 0.00002103, 0.00001477, 0.00001037, 0.00000728, 0.00000511,
	},
}

-- DodgePerAgi does not exist as a GameTable.
-- Through observations of data gathered from the result of GetDodgePerAgi() through addon comms,
-- each class except Hunter and Warlock has a constant conversion of CritPerAgi to DodgePerAgi for 1-80.
-- These class constants are exactly 15% greater than WOTLK values, except rogue, which is slightly higher, at 2.06 instead of 2
-- Hunter and Warlock don't use this constant conversion for 1-80, but are exactly 15% greater than their WOTLK DodgePerAgi values.
-- DodgePerCrit = {
--   ["HUNTER"]   = 1.11, -- Only at 80-85
--   ["ROGUE"]    = 2.06,
--   ["PRIEST"]   = 1.00,
--   ["SHAMAN"]   = 1.60,
--   ["MAGE"]     = 1.00,
--   ["WARLOCK"]  = 0.97, -- Only at 80-85
--   ["DRUID"]    = 2.00,
-- }
-- Levels 81-85 appear to use that constant *and* an additional class-independent scalar, roughly:
-- DodgePerCritPerLevel = {
--   [1-80] = 1,
--   [81] = 0.9233,
--   [82] = 0.8532,
--   [83] = 0.7905,
--   [84] = 0.7281,
--   [85] = 0.6712,
-- }
-- DodgePerAgi = CritPerAgi[addon.class][level] * DodgePerCrit[addon.class] * DodgePerCritPerLevel[level]
-- For simplicity, I'm precalculating these tables or directly using observed values.
addon.DodgePerAgi = {
	["WARRIOR"] = addon.zero,
	["PALADIN"] = addon.zero,
	["HUNTER"] = {
		0.45430000, 0.43540000, 0.41800003, 0.38700000, 0.37320000, 0.36030003, 0.34830000, 0.33710001, 0.31670000, 0.30740000,
		0.28406771, 0.24880002, 0.22720002, 0.20900002, 0.19000001, 0.18019999, 0.16850000, 0.15600001, 0.14720001, 0.13823304,
		0.13299648, 0.12440000, 0.11870000, 0.11277684, 0.10797947, 0.10375140, 0.09908912, 0.09543693, 0.09129468, 0.08764639,
		0.08534061, 0.08160000, 0.07860000, 0.07656180, 0.07402871, 0.07160000, 0.06945697, 0.06724230, 0.06527123, 0.06350562,
		0.06200439, 0.06031990, 0.05862951, 0.05698667, 0.05550188, 0.05410000, 0.05290167, 0.05120000, 0.05000000, 0.04899452,
		0.04807170, 0.04707210, 0.04596346, 0.04478956, 0.04377858, 0.04307656, 0.04207840, 0.04134486, 0.04036202, 0.03959002,
		0.03710000, 0.03584363, 0.03434478, 0.03303029, 0.03198610, 0.03080000, 0.02970000, 0.02923543, 0.02859361, 0.02770000,
		0.02590579, 0.02399023, 0.02227764, nil,        0.01923143, nil,        0.01662007, nil,        0.01430000, 0.01333760,
		0.00932078, 0.00661464, 0.00460702, 0.00320337, 0.00230177,
	},
	["ROGUE"] = {
		0.92207454, 0.88365348, 0.84830804, 0.78546978, 0.75741874, 0.73130000, 0.68411984, 0.66274114, 0.64265818, 0.60593460,
		0.54378644, 0.49320316, 0.44182674, 0.40784086, 0.36565000, 0.34205888, 0.32132908, 0.29870000, 0.27904966, 0.26182394,
		0.24660054, 0.23564134, 0.22323808, 0.21421940, 0.20197806, 0.19279725, 0.18603242, 0.17821596, 0.17102985, 0.16313614,
		0.15826650, 0.15257328, 0.14727579, 0.14233364, 0.13682396, 0.13254802, 0.12931526, 0.12548943, 0.12188340, 0.11782046,
		0.11463612, 0.11161945, 0.10875749, 0.10551093, 0.10245266, 0.10003628, 0.09773134, 0.09553023, 0.09342594, 0.09063114,
		0.08873512, 0.08691676, 0.08483080, 0.08316735, 0.08125546, 0.07942969, 0.07796956, 0.07628674, 0.07493889, 0.07313000,
		0.06887383, 0.06628565, 0.06311819, 0.06096961, 0.05894752, 0.05700988, 0.05522839, 0.05394501, 0.05275557, 0.05149753,
		0.04787296, 0.04446057, 0.04134049, 0.03841982, 0.03570310, 0.03318887, 0.03082522, 0.02865913, 0.02664280, 0.02477541,
		0.01728571, 0.01225043, 0.00858262, 0.00604260, 0.00430335,
	},
	["PRIEST"] = {
		0.09117500, 0.09117500, 0.09117500, 0.08683330, 0.08683330, 0.08683330, 0.08683330, 0.08288640, 0.08288640, 0.08288640,
		0.08288640, 0.07928260, 0.07928260, 0.07928260, 0.07928260, 0.07597920, 0.07597920, 0.07597920, 0.07294000, 0.07294000,
		0.07294000, 0.07294000, 0.07013460, 0.07013460, 0.07013460, 0.06753700, 0.06753700, 0.06753700, 0.06512500, 0.06512500,
		0.06512500, 0.06287930, 0.06287930, 0.06287930, 0.06078330, 0.06078330, 0.06078330, 0.05882260, 0.05882260, 0.05882260,
		0.05698440, 0.05698440, 0.05525760, 0.05525760, 0.05525760, 0.05363240, 0.05363240, 0.05210000, 0.05210000, 0.05210000,
		0.05065280, 0.05065280, 0.04928380, 0.04928380, 0.04798680, 0.04798680, 0.04675640, 0.04675640, 0.04558750, 0.04558750,
		0.04449120, 0.04458550, 0.04426580, 0.04344670, 0.04271900, 0.04207770, 0.04151880, 0.04133470, 0.04117830, 0.04014610,
		0.03721430, 0.03440570, 0.03199120, 0.02989340, 0.02762880, 0.02568310, 0.02399340, 0.02223780, 0.02072160, 0.01919470,
		0.01350000, 0.00950000, 0.00670000, 0.00470000, 0.00330000,
	},
	["DEATHKNIGHT"] = addon.zero,
	["SHAMAN"] = {
		0.16624000, 0.16624000, 0.15832382, 0.15832382, 0.15112720, 0.15112720, 0.15112720, 0.14455648, 0.14455648, 0.13853328,
		0.13853328, 0.13299200, 0.13299200, 0.12787696, 0.12314080, 0.11874288, 0.11874288, 0.11464832, 0.11464832, 0.10725168,
		0.10725168, 0.10390000, 0.10390000, 0.10075152, 0.09778816, 0.09499424, 0.09499424, 0.09235552, 0.09235552, 0.08749472,
		0.08749472, 0.08525136, 0.08312000, 0.08312000, 0.07916192, 0.07732096, 0.07732096, 0.07556368, 0.07556368, 0.07227824,
		0.07074048, 0.07074048, 0.06926672, 0.06785312, 0.06649600, 0.06519216, 0.06393840, 0.06273200, 0.06273200, 0.06045088,
		0.05937136, 0.05832976, 0.05832976, 0.05732416, 0.05541328, 0.05450496, 0.05362576, 0.05362576, 0.05277456, 0.05115072,
		0.04963984, 0.04864480, 0.04696608, 0.04557232, 0.04491216, 0.04374464, 0.04269136, 0.04173040, 0.04083296, 0.03999408,
		0.03717072, 0.03454688, 0.03210816, 0.02984160, 0.02773504, 0.02577728, 0.02395760, 0.02226640, 0.02069456, 0.01923376,
		0.01350000, 0.00950000, 0.00670000, 0.00470000, 0.00330000,
	},
	["MAGE"] = {
		0.07730000, 0.07730000, 0.07730000, 0.07361900, 0.07361900, 0.07361900, 0.07361900, 0.07361900, 0.07361900, 0.07027270,
		0.07027270, 0.07027270, 0.07027270, 0.07027270, 0.06721740, 0.06721740, 0.06721740, 0.06721740, 0.06721740, 0.06441670,
		0.06441670, 0.06441670, 0.06441670, 0.06184000, 0.06184000, 0.06184000, 0.06184000, 0.06184000, 0.05946150, 0.05946150,
		0.05946150, 0.05946150, 0.05725930, 0.05725930, 0.05725930, 0.05521430, 0.05521430, 0.05521430, 0.05521430, 0.05331030,
		0.05331030, 0.05331030, 0.05331030, 0.05153330, 0.05153330, 0.05153330, 0.04987100, 0.04987100, 0.04987100, 0.04831250,
		0.04831250, 0.04831250, 0.04684850, 0.04684850, 0.04684850, 0.04547060, 0.04547060, 0.04547060, 0.04417140, 0.04417140,
		0.04417140, 0.04417140, 0.04294440, 0.04294440, 0.04294440, 0.04178380, 0.04178380, 0.04178380, 0.04068420, 0.04068420,
		0.03770730, 0.03513640, 0.03289360, 0.03031370, 0.02810910, 0.02620340, 0.02415630, 0.02273530, 0.02089190, 0.01956960,
		0.01370859, 0.00960890, 0.00680845, 0.00471064, 0.00331163,
	},
	["WARLOCK"] = {
		0.14830000, 0.14830000, 0.14120000, 0.14120003, 0.14120003, 0.13480000, nil,        nil,        0.12890000, 0.12890000,
		0.12349998, 0.12349999, 0.12349999, 0.11860001, 0.11400000, 0.10979999, 0.10979999, 0.10980000, 0.10589999, 0.10220001,
		0.09880000, 0.09880000, 0.09560000, 0.09560000, 0.08980000, 0.08980000, 0.08980000, 0.08720000, 0.08720000, 0.08240000,
		0.08240000, 0.08010000, 0.08010000, 0.07800000, 0.07600000, 0.07410000, 0.07230000, 0.07230000, 0.07060000, nil,
		nil,        nil,        nil,        nil,        nil,        nil,        nil,        nil,        nil,        nil,
		nil,        nil,        nil,        nil,        nil,        nil,        nil,        nil,        nil,        nil,
		nil,        nil,        0.04650000, 0.04500000, nil,        nil,        nil,        0.04200000, 0.04090000, 0.04000000,
		0.03720000, 0.03460000, 0.03210000, 0.02980000, 0.02770000, 0.02580000, nil,        nil,        nil,        0.01920000,
		0.01350000, 0.00950000, 0.00670000, 0.00470000, 0.00330000,
	},
	["DRUID"] = {
		0.25245000, 0.25245000, 0.24042800, 0.24042800, 0.22950000, 0.22950000, 0.21952200, 0.21952200, 0.21037398, 0.19419240,
		0.18700000, 0.18700000, 0.18032140, 0.18032140, 0.16830000, 0.16830000, 0.16287100, 0.15778120, 0.15778120, 0.14025000,
		0.14025000, 0.13645940, 0.13286840, 0.13286840, 0.12622500, 0.12622500, 0.12314640, 0.12021420, 0.12021420, 0.10976080,
		0.10742560, 0.10742560, 0.10518740, 0.10304080, 0.10098000, 0.09900000, 0.09709620, 0.09709620, 0.09526420, 0.08857900,
		0.08705180, 0.08705180, 0.08557620, 0.08415000, 0.08143540, 0.08014280, 0.08014280, 0.07889060, 0.07767700, 0.07317400,
		0.07212860, 0.07111260, 0.07012500, 0.07012500, 0.06822980, 0.06732000, 0.06643420, 0.06557140, 0.06473080, 0.06157320,
		0.05976920, 0.05900220, 0.05699280, 0.05582140, 0.05476120, 0.05380500, 0.05294680, 0.05154560, 0.05074620, 0.04999620,
		0.04646680, 0.04318660, 0.04013820, 0.03730480, 0.03467140, 0.03222380, 0.02994920, 0.02783500, 0.02587020, 0.02404400,
		0.01692088, 0.01190979, 0.00830446, 0.00580155, 0.00410000,
	},
}

addon.bonusArmorInventoryTypes = {
	["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
-- A few shields were zero so taken manually from ItemArmorShield.db2 instead
addon.baseArmorTable = {
	[Enum.ItemQuality.Epic] = {
		[SECONDARYHANDSLOT] = {
			[Enum.ItemArmorSubclass.Shield] = {
				[46] = 1766,
				[65] = 2186,
				[90] = 2477,
			},
		},
		[CHESTSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[62] = 506,
				[63] = 510,
				[74] = 549,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[74] = 246,
				[85] = 284,
				[88] = 301,
				[136] = 524,
				[146] = 571,
				[159] = 638,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[65] = 325,
				[69] = 337,
				[74] = 353,
				[75] = 357,
				[83] = 384,
				[90] = 438,
				[105] = 581,
				[123] = 662,
				[136] = 722,
				[146] = 790,
				[159] = 887,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[65] = 767,
				[74] = 804,
				[251] = 2534,
				[264] = 2642,
				[277] = 2756,
			},
		},
		[FEETSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[71] = 163,
				[78] = 178,
				[146] = 393,
				[159] = 439,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[71] = 236,
				[77] = 250,
				[83] = 264,
				[90] = 301,
				[123] = 455,
				[136] = 496,
				[146] = 543,
				[159] = 610,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[71] = 370,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[70] = 541,
				[71] = 544,
				[73] = 550,
			},
		},
		[HANDSSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[71] = 148,
				[136] = 328,
				[146] = 357,
				[159] = 399,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[71] = 215,
				[78] = 229,
				[81] = 235,
				[90] = 274,
				[105] = 363,
				[123] = 414,
				[136] = 451,
				[146] = 494,
				[159] = 555,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[71] = 336,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[71] = 495,
				[90] = 585,
				[130] = 910,
				[251] = 1584,
				[264] = 1651,
				[277] = 1723,
			},
		},
		[HEADSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[74] = 200,
				[81] = 217,
				[136] = 426,
				[146] = 464,
				[159] = 518,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[74] = 287,
				[75] = 290,
				[90] = 356,
				[105] = 472,
				[123] = 538,
				[136] = 587,
				[146] = 642,
				[159] = 721,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[74] = 446,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[66] = 626,
				[74] = 653,
				[105] = 1063,
			},
		},
		[LEGSSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[65] = 192,
				[71] = 207,
				[81] = 234,
				[136] = 459,
				[146] = 500,
				[159] = 558,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[65] = 284,
				[71] = 301,
				[90] = 383,
				[105] = 508,
				[123] = 580,
				[136] = 632,
				[146] = 691,
				[159] = 777,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[71] = 471,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[60] = 653,
				[61] = 657,
				[71] = 693,
				[232] = 2088,
				[264] = 2311,
			},
		},
		[SHOULDERSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[65] = 164,
				[74] = 184,
				[78] = 194,
				[136] = 393,
				[146] = 428,
				[159] = 479,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[65] = 243,
				[74] = 265,
				[90] = 328,
				[105] = 436,
				[123] = 497,
				[136] = 542,
				[146] = 592,
				[159] = 666,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[71] = 404,
				[74] = 412,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[90] = 702,
			},
		},
		[WRISTSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[59] = 325,
				[251] = 1109,
				[264] = 1156,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[61] = 137,
				[113] = 278,
				[126] = 293,
				[141] = 330,
				[154] = 371,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[141] = 239,
				[154] = 267,
			},
		},
		[BACKSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[72] = 120,
				[73] = 121,
				[77] = 128,
				[83] = 137,
				[105] = 207,
				[110] = 224,
				[115] = 230,
				[128] = 246,
				[200] = 404,
				[213] = 428,
				[232] = 462,
				[264] = 556,
				[353] = 604,
			},
		},
		[WAISTSLOT] = {
			[Enum.ItemArmorSubclass.Leather] = {
				[61] = 176,
				[66] = 184,
				[76] = 202,
				[123] = 373,
				[136] = 406,
				[146] = 444,
				[159] = 499,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[90] = 526,
				[264] = 1486,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[146] = 321,
				[159] = 359,
			},
		},
	},
	[Enum.ItemQuality.Rare] = {
		[CHESTSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[30] = 221,
				[36] = 259,
				[62] = 407,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[59] = 596,
				[63] = 609,
				[65] = 616,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[63] = 171,
				[68] = 183,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[68] = 268,
				[115] = 515,
			},
		},
		[SECONDARYHANDSLOT] = {
			[Enum.ItemArmorSubclass.Shield] = {
				[21] = 700,
				[30] = 945,
				[59] = 1687,
			},
		},
		[HEADSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[43] = 371,
				[60] = 487,
				[115] = 917,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[63] = 139,
				[71] = 155,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[71] = 224,
				[100] = 345,
				[115] = 419,
			},
		},
		[SHOULDERSLOT] = {
			[Enum.ItemArmorSubclass.Leather] = {
				[55] = 175,
				[68] = 201,
				[71] = 207,
				[115] = 386,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[61] = 125,
				[71] = 143,
			},
		},
		[BACKSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[35] = 51,
				[45] = 64,
				[50] = 70,
				[52] = 73,
				[62] = 85,
				[63] = 86,
				[71] = 95,
				[91] = 128,
				[112] = 182,
				[115] = 185,
				[167] = 312,
				[187] = 364,
			},
		},
		[WRISTSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[50] = 229,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[62] = 178,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[61] = 73,
			},
		},
		[FEETSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[41] = 200,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[33] = 101,
				[43] = 128,
				[53] = 155,
				[63] = 176,
				[66] = 181,
				[71] = 190,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[33] = 66,
				[43] = 84,
				[53] = 101,
				[61] = 115,
				[63] = 118,
				[66] = 123,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[56] = 399,
			},
		},
		[LEGSSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[52] = 475,
				[65] = 539,
				[114] = 985,
				[166] = 1697,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[52] = 194,
				[68] = 235,
				[71] = 241,
				[100] = 371,
				[115] = 451,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[62] = 148,
				[68] = 160,
			},
		},
		[WAISTSLOT] = {
			[Enum.ItemArmorSubclass.Leather] = {
				[33] = 83,
				[43] = 105,
				[53] = 127,
				[63] = 144,
				[100] = 239,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[33] = 54,
				[43] = 69,
				[53] = 83,
				[60] = 93,
				[63] = 96,
				[109] = 201,
				[115] = 208,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[71] = 358,
			},
		},
		[HANDSSLOT] = {
			[Enum.ItemArmorSubclass.Leather] = {
				[65] = 163,
				[66] = 164,
				[71] = 172,
				[115] = 322,
			},
			[Enum.ItemArmorSubclass.Mail] = {
				[62] = 254,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[61] = 104,
				[66] = 111,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[114] = 704,
			},
		},
	},
	[Enum.ItemQuality.Good] = {
		[WRISTSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[33] = 95,
			},
		},
		[SECONDARYHANDSLOT] = {
			[Enum.ItemArmorSubclass.Shield] = {
				[41] = 1110,
			},
		},
		[CHESTSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[16] = 120,
				[20] = 143,
				[40] = 259,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[46] = 441,
				[62] = 551,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[57] = 219,
			},
		},
		[HANDSSLOT] = {
			[Enum.ItemArmorSubclass.Mail] = {
				[28] = 118,
			},
			[Enum.ItemArmorSubclass.Plate] = {
				[45] = 270,
			},
		},
		[LEGSSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[45] = 378,
				[62] = 482,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[54] = 182,
			},
		},
		[FEETSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[47] = 309,
				[60] = 375,
			},
		},
		[HEADSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[47] = 365,
				[61] = 445,
			},
			[Enum.ItemArmorSubclass.Cloth] = {
				[114] = 271,
			},
		},
		[SHOULDERSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[60] = 409,
			},
			[Enum.ItemArmorSubclass.Leather] = {
				[61] = 171,
			},
		},
		[BACKSLOT] = {
			[Enum.ItemArmorSubclass.Cloth] = {
				[60] = 75,
				[108] = 160,
			},
		},
		[WAISTSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[174] = 934,
			},
		},
	},
	[Enum.ItemQuality.Standard] = {
		[SECONDARYHANDSLOT] = {
			[Enum.ItemArmorSubclass.Shield] = {
				[1] = 57,
			},
		},
		[HANDSSLOT] = {
			[Enum.ItemArmorSubclass.Leather] = {
				[1] = 12,
			},
		},
		[CHESTSLOT] = {
			[Enum.ItemArmorSubclass.Plate] = {
				[60] = 518,
			},
		},
	},
}


StatLogic.StatModTable = {}
if addon.class == "DRUID" then
	StatLogic.StatModTable["DRUID"] = {
		["ADD_MASTERY_EFFECT_MOD_MASTERY"] = {
			-- Mastery: Total Eclipse
			{
				["spec"] = 1,
				["value"] = 2,
			},
			-- Mastery: Razor Claws (Cat Form)
			{
				["spec"] = 2,
				["value"] = 3.1,
				["aura"] = 768,
			},
			-- Mastery: Savage Defender (Bear Form)
			{
				["spec"] = 2,
				["value"] = 4,
				["aura"] = 5487,
			},
			-- Mastery: Harmony
			{
				["spec"] = 3,
				["value"] = 1.25,
			},
		},
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_AP_MOD_AGI"] = {
			-- Druid: Cat Form - Buff
			{
				["value"] = 2,
				["aura"] = 768,
			},
			-- Druid: Bear Form - Buff
			{
				["value"] = 2,
				["aura"] = 5487,
			},
		},
		["ADD_AP_MOD_STA"] = {
			-- Buff: Vengeance (100% of Stamina, not 10% of HP)
			{
				["value"] = 1,
				["spec"] = 2,
				["aura"] = 76691,
			},
		},
		["ADD_SPELL_DMG_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_HEALING_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		["ADD_HEALING_MOD_AGI"] = {
			-- Talent: Nurturing Instinct
			{
				["tab"] = 2,
				["num"] = 14,
				["rank"] = {
					0.50, 1,
				},
			},
		},
		["ADD_MANA_REG_MOD_NORMAL_MANA_REG"] = {
			-- Passive: Meditation
			{
				["value"] = 0.50,
				["spellid"] = 85101,
				["spec"] = 3,
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 4.9510,
			},
			-- Talent: Feral Swiftness (Bear Form)
			{
				["tab"] = 2,
				["num"] = 1,
				["rank"] = {
					2, 4,
				},
				["aura"] = 5487,
			},
			-- Talent: Feral Swiftness (Cat Form)
			{
				["tab"] = 2,
				["num"] = 1,
				["rank"] = {
					2, 4,
				},
				["aura"] = 768,
			},
			-- Talent: Natural Reaction
			{
				["tab"] = 2,
				["num"] = 18,
				["rank"] = {
					3, 6,
				},
				["aura"] = 5487,
			},
		},
		["ADD_SPELL_HIT_RATING_MOD_SPI"] = {
			-- Talent: Balance of Power
			{
				["tab"] = 1,
				["num"] = 6,
				["rank"] = {
					0.5, 1,
				},
			},
		},
		-- Druid: Thick Hide (Rank 3) - 2,11
		-- 4.0.1: Increases your Armor contribution from cloth and leather items by 4/7/10%, increases armor while in Bear Form by an additional 11/22/33%, and reduces the chance you'll be critically hit by melee attacks by 2/4/6%.
		-- Druid: Bear Form - Buff
		-- 4.0.1: Increases melee attack power by 30, armor contribution from cloth and leather items by 65%/120%, and Stamina by 25%.  Also causes agility to increase attack power.
		-- Druid: Tree of Life - Buff
		-- 4.0.1: Armor increased by 120%.
		["MOD_ARMOR"] = {
			-- Thick Hide
			{
				["tab"] = 2,
				["num"] = 11,
				["rank"] = {
					0.04, 0.07, 0.1,
				},
			},
			-- Thick Hide
			{
				["tab"] = 2,
				["num"] = 11,
				["rank"] = {
					0.11, 0.22, 0.33,
				},
				["aura"] = 5487,        -- ["Bear Form"],
			},
			-- Bear Form < lv40
			{
				["aura"] = 5487,
				["level"] = setmetatable({}, {
					__index = function(_, level)
						return level >= 40 and 1.20 or 0.65
					end
				}),
			},
			{
				["value"] = 1.2,
				["aura"] = 33891,        -- ["Tree of Life"],
			},
		},
		-- Druid: Furor (Rank 3) - 2,2
		-- 4.0.1: Increases your maximum mana by 5/10/15%.
		["MOD_MANA"] = {
			{
				["tab"] = 2,
				["num"] = 2,
				["rank"] = {
					0.05, 0.1, 0.15,
				},
			},
		},
		-- Druid: Leather Specialization - Passive: 86530
		-- 4.0.1: Increases your primary attribute by 5% while wearing Leather in all armor slots.  Balance specialization grants Intellect, Feral specialization grants Agility while in Cat Form and Stamina while in Bear Form, and Restoration specialization grants Intellect.
		-- Druid: Heart of the Wild (Rank 5) - 3,4
		-- 4.0.1: Increases your Intellect by 2/4/6%. In addition, while in Bear Form your Stamina is increased by 3/7/10% and while in Cat Form your attack power is increased by 3/7/10%.
		-- Druid: Bear Form - Buff
		-- 4.0.1: Increases melee attack power by 30, armor contribution from cloth and leather items by 65%/120%, and Stamina by 25%.  Also causes agility to increase attack power.
		["MOD_STA"] = {
			-- Heart of the Wild: +2/4/6/8/10% stamina in bear / dire bear
			{
				["tab"] = 3,
				["num"] = 4,
				["rank"] = {
					0.03, 0.07, 0.1,
				},
				["aura"] = 5487,        -- ["Bear Form"],
			},
			-- Bear Form
			{
				["value"] = 0.25,
				["aura"] = 5487,        -- ["Bear Form"],
			},
			-- Leather Specialization
			{
				["value"] = 0.05,
				["armorspec"] = {
					[2] = true,
				},
				["known"] = 86530,
				["aura"] = 5487,        -- ["Bear Form"],
			},
		},
		-- Druid: Leather Specialization - Passive: 86530
		-- 4.0.1: Increases your primary attribute by 5% while wearing Leather in all armor slots.  Balance specialization grants Intellect, Feral specialization grants Agility while in Cat Form and Stamina while in Bear Form, and Restoration specialization grants Intellect.
		["MOD_AGI"] = {
			-- Leather Specialization
			{
				["value"] = 0.05,
				["armorspec"] = {
					[2] = true,
				},
				["known"] = 86530,
				["aura"] = 768,        -- ["Cat Form"],
			},
		},
		["MOD_AP"] = {
			-- Talent: Heart of the Wild (Cat Form)
			{
				["tab"] = 3,
				["num"] = 4,
				["rank"] = {
					0.03, 0.07, 0.1,
				},
				["aura"] = 768,
			},
			-- Passive: Aggression
			{
				["value"] = 0.25,
				["spellid"] = 84735,
				["spec"] = 2,
			},
		},
		-- Druid: Leather Specialization - Passive: 86530
		-- 4.0.1: Increases your primary attribute by 5% while wearing Leather in all armor slots.  Balance specialization grants Intellect, Feral specialization grants Agility while in Cat Form and Stamina while in Bear Form, and Restoration specialization grants Intellect.
		-- Druid: Heart of the Wild (Rank 5) - 3,4
		-- 4.0.1: Increases your Intellect by 2/4/6%. In addition, while in Bear Form your Stamina is increased by 3/7/10% and while in Cat Form your attack power is increased by 3/7/10%.
		["MOD_INT"] = {
			{
				["tab"] = 3,
				["num"] = 4,
				["rank"] = {
					0.02, 0.04, 0.06,
				},
			},
			-- Leather Specialization
			{
				["value"] = 0.05,
				["known"] = 86530,
				["armorspec"] = {
					[1] = true,
					[3] = true,
				},
			},
		},
	}
elseif addon.class == "DEATHKNIGHT" then
	StatLogic.StatModTable["DEATHKNIGHT"] = {
		["ADD_MASTERY_EFFECT_MOD_MASTERY"] = {
			-- Mastery: Blood Shield
			{
				["spec"] = 1,
				["value"] = 6.25,
			},
			-- Mastery: Frozen Heart
			{
				["spec"] = 2,
				["value"] = 2,
			},
			-- Mastery: Dreadblade
			{
				["spec"] = 3,
				["value"] = 2.5,
			},
		},
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_DODGE"] = {
			{
				["value"] = 5.0000,
			},
		},
		["ADD_PARRY_RATING_MOD_STR"] = {
			-- Passive: Forceful Deflection
			{
				["spellid"] = 49410,
				["value"] = 0.27,
			},
		},
		["ADD_AP_MOD_ARMOR"] = {
			-- Talent: Bladed Armor
			{
				["tab"] = 1,
				["num"] = 3,
				["rank"] = {
					2/180, 4/180, 6/180,
				},
			},
		},
		["MOD_ARMOR"] = {
			-- Stance: Blood Presence
			{
				["value"] = 0.6,
				["stance"] = "Interface\\Icons\\Spell_Deathknight_BloodPresence",
			},
			-- Talent: Toughness
			{
				["tab"] = 1,
				["num"] = 10,
				["rank"] = {
					0.03, 0.07, 0.1,
				},
			},
			-- Enchant: Rune of the Stoneskin Gargoyle
			{
				["value"] = 0.04,
				["slot"] = INVSLOT_MAINHAND,
				["enchant"] = 3847,
			},
			-- Enchant: Rune of the Nerubian Carapace (Mainhand)
			{
				["value"] = 0.02,
				["slot"] = INVSLOT_MAINHAND,
				["enchant"] = 3883,
			},
			-- Enchant: Rune of the Nerubian Carapace (Offhand)
			{
				["value"] = 0.02,
				["slot"] = INVSLOT_OFFHAND,
				["enchant"] = 3883,
			},
		},
		["MOD_HEALTH"] = {
			-- Buff: Vampiric Blood
			{
				["value"] = 0.15,
				["aura"] = 55233,
			},
			-- Glyph of Vampiric Blood
			{
				["value"] = -0.15 / (1 + 0.15),
				["aura"] = 55233,
				["glyph"] = 58676,
			},
		},
		["MOD_STA"] = {
			-- Plate Specialization (Blood)
			{
				["value"] = 0.05,
				["known"] = 86524,
				["armorspec"] = {
					[1] = true,
				},
			},
			-- Stance: Blood Presence
			{
				["value"] = 0.08,
				["stance"] = "Interface\\Icons\\Spell_Deathknight_BloodPresence",
			},
			-- Passive: Veteran of the Third War
			{
				["value"] = 0.09,
				["known"] = 50029,
			},
			-- 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,
			},
		},
		["ADD_AP_MOD_STA"] = {
			-- Buff: Vengeance (100% of Stamina, not 10% of HP)
			{
				["value"] = 1,
				["spec"] = 1,
				["aura"] = 76691,
			},
		},
		["MOD_STR"] = {
			-- Plate Specialization (Frost, Unholy)
			{
				["value"] = 0.05,
				["known"] = 86524,
				["armorspec"] = {
					[2] = true,
					[3] = true,
				},
			},
			-- Passive: Unholy Might
			{
				["value"] = 0.25,
				["spellid"] = 91107,
				["spec"] = 3,
			},
			-- Talent: Abomination's Might
			{
				["tab"] = 1,
				["num"] = 11,
				["rank"] = {
					0.01, 0.02,
				},
			},
			-- Buff: Pillar of Frost
			{
				["value"] = 0.2,
				["aura"] = 51271,
			},
			-- Talent: Brittle Bones
			{
				["tab"] = 2,
				["num"] = 14,
				["rank"] = {
					0.02, 0.04,
				},
			},
			-- Buff: Unholy Strength
			{
				["value"] = 0.15,
				["aura"] = 53365,
			},
		},
	}
elseif addon.class == "HUNTER" then
	StatLogic.StatModTable["HUNTER"] = {
		["ADD_MASTERY_EFFECT_MOD_MASTERY"] = {
			-- Mastery: Master of Beasts
			{
				["spec"] = 1,
				["value"] = 1.67,
			},
			-- Mastery: Wild Quiver
			{
				["spec"] = 2,
				["value"] = 2.1,
			},
			-- Mastery: Essence of the Viper
			{
				["spec"] = 3,
				["value"] = 1,
			},
		},
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_RANGED_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = -5.4500,
			},
		},
		["MOD_AP"] = {
			-- Passive: Animal Handler
			{
				["value"] = 0.25,
				["spellid"] = 87325,
				["spec"] = 1,
			},
		},
		-- Hunter: Hunter vs. Wild - Rank 3/3 - 3,1
		-- 4.0.1: Increases your total Stamina by 5/10/15%.
		["MOD_STA"] = {
			-- Hunter vs. Wild
			{
				["tab"] = 3,
				["num"] = 1,
				["rank"] = {
					0.05, 0.1, 0.15,
				},
			},
		},
		["MOD_AGI"] = {
			-- Mail Specialization
			{
				["value"] = 0.05,
				["known"] = 86528,
				["armorspec"] = {
					[0] = true,
					[1] = true,
					[2] = true,
					[3] = true,
				},
			},
			-- Passive: Into the Wilderness
			{
				["value"] = 0.1,
				["spellid"] = 84729,
				["spec"] = 3,
			},
			-- Talent: Hunting Party
			{
				["tab"] = 3,
				["num"] = 17,
				["value"] = 0.02,
			},
		},
	}
elseif addon.class == "MAGE" then
	StatLogic.StatModTable["MAGE"] = {
		["ADD_MASTERY_EFFECT_MOD_MASTERY"] = {
			-- Mastery: Mana Adept
			{
				["spec"] = 1,
				["value"] = 1.5,
			},
			-- Mastery: Flashburn
			{
				["spec"] = 2,
				["value"] = 2.8,
			},
			-- Mastery: Frostburn
			{
				["spec"] = 3,
				["value"] = 2.5,
			},
		},
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_SPELL_DMG_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_HEALING_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 3.4575,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		["MOD_INT"] = {
			-- Passive: Wizardry
			{
				["value"] = 0.05,
				["known"] = 89744,
			},
		},
		-- Improved Mana Gem - Rank 2/2 - 1,19 - Buff: 83098
		-- 4.0.1: Increases your spell power by 1/2% of your maximum mana
		["ADD_SPELL_DMG_MOD_MANA"] = {
			{
				["tab"] = 1,
				["num"] = 19,
				["rank"] = {
					0.01, 0.02,
				},
				["aura"] = 83098,        -- ["Improved Mana Gem"],
			},
		},
		-- Improved Mana Gem - Rank 2/2 - 1,19 - Buff: 83098
		-- 4.0.1: Increases your spell power by 1/2% of your maximum mana
		["ADD_HEALING_MOD_MANA"] = {
			{
				["tab"] = 1,
				["num"] = 19,
				["rank"] = {
					0.01, 0.02,
				},
				["aura"] = 83098,        -- ["Improved Mana Gem"],
			},
		},
		["ADD_MANA_REG_MOD_MANA"] = {
			-- Buff: Mage Armor
			{
				["value"] = 0.03,
				["aura"] = 6117,
			},
			-- Glyph of Mage Armor (Mage Armor)
			{
				["value"] = 0.006,
				["aura"] = 6117,
				["glyph"] = 56383
			},
			-- Glyph of Frost Armor
			{
				["value"] = 0.02,
				["aura"] = 7302,
				["glyph"] = 98397,
			},
		},
	}
elseif addon.class == "PALADIN" then
	StatLogic.StatModTable["PALADIN"] = {
		["ADD_MASTERY_EFFECT_MOD_MASTERY"] = {
			-- Mastery: Illuminated Healing
			{
				["spec"] = 1,
				["value"] = 1.5,
			},
			-- Mastery: Divine Bulwark
			{
				["spec"] = 2,
				["value"] = 2.25,
			},
			-- Mastery: Hand of Light
			{
				["spec"] = 3,
				["value"] = 2.1,
			},
		},
		["ADD_BLOCK_CHANCE_MOD_MASTERY_EFFECT"] = {
			-- Mastery: Divine Bulwark
			{
				["spec"] = 2,
				["value"] = 1,
			},
		},
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_AP_MOD_STA"] = {
			-- Buff: Vengeance (100% of Stamina, not 10% of HP)
			{
				["value"] = 1,
				["spec"] = 2,
				["aura"] = 76691,
			},
		},
		["ADD_SPELL_DMG_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_HEALING_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 5.0000,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		["ADD_MANA_REG_MOD_NORMAL_MANA_REG"] = {
			-- Passive: Meditation
			{
				["value"] = 0.50,
				["spellid"] = 95859,
				["spec"] = 1,
			},
			-- Talent: Judgements of the Pure
			{
				["tab"] = 1,
				["num"] = 3,
				["rank"] = {
					0.1, 0.2, 0.3,
				},
				["aura"] = 53655,
			},
		},
		["ADD_SPELL_HIT_RATING_MOD_SPI"] = {
			-- Talent: Enlightened Judgements
			{
				["tab"] = 1,
				["num"] = 11,
				["rank"] = {
					0.5, 1,
				},
			},
		},
		["ADD_PARRY_RATING_MOD_STR"] = {
			-- Passive: Forceful Deflection
			{
				["spellid"] = 49410,
				["value"] = 0.27,
			},
		},
		["ADD_SPELL_DMG_MOD_AP"] = {
			-- Passive: Sheath of Light
			{
				["value"] = 0.30,
				["spellid"] = 53503,
				["spec"] = 3,
			},
		},
		["ADD_HEALING_MOD_AP"] = {
			-- Passive: Sheath of Light
			{
				["value"] = 0.30,
				["spellid"] = 53503,
				["spec"] = 3,
			},
		},
		["ADD_SPELL_DMG_MOD_STR"] = {
			-- Passive: Touched by the Light
			{
				["value"] = 0.60,
				["spellid"] = 53592,
				["spec"] = 2,
			},
		},
		["ADD_HEALING_MOD_STR"] = {
			-- Passive: Touched by the Light
			{
				["value"] = 0.60,
				["spellid"] = 53592,
				["spec"] = 2,
			},
		},
		-- Paladin: Toughness - Rank 3/3 - 2,5
		-- 4.0.1: Increases your armor value from items by 3/6/10%.
		["MOD_ARMOR"] = {
			{
				["tab"] = 2,
				["num"] = 5,
				["rank"] = {
					0.03, 0.06, 0.1,
				},
			},
		},
		["MOD_STA"] = {
			-- Plate Specialization
			{
				["value"] = 0.05,
				["known"] = 86525,
				["armorspec"] = {
					[2] = true,
				},
			},
			-- Passive: Touched by the Light
			{
				["value"] = 0.15,
				["spellid"] = 53592,
				["spec"] = 2,
			},
		},
		-- Paladin: Plate Specialization - Passive: 86525
		-- 4.0.1: Increases your primary attribute by 5% while wearing Plate in all armor slots. Holy specialization grants Intellect, Protection specialization grants Stamina, and Retribution specialization grants Strength.
		["MOD_STR"] = {
			-- Plate Specialization
			{
				["value"] = 0.05,
				["known"] = 86525,
				["armorspec"] = {
					[3] = true,
				},
			},
		},
		-- Paladin: Plate Specialization - Passive: 86525
		-- 4.0.1: Increases your primary attribute by 5% while wearing Plate in all armor slots. Holy specialization grants Intellect, Protection specialization grants Stamina, and Retribution specialization grants Strength.
		["MOD_INT"] = {
			-- Plate Specialization
			{
				["value"] = 0.05,
				["known"] = 86525,
				["armorspec"] = {
					[1] = true,
				},
			},
		},
	}
elseif addon.class == "PRIEST" then
	StatLogic.StatModTable["PRIEST"] = {
		["ADD_MASTERY_EFFECT_MOD_MASTERY"] = {
			-- Mastery: Shield Discipline
			{
				["spec"] = 1,
				["value"] = 2.5,
			},
			-- Mastery: Echo of Light
			{
				["spec"] = 2,
				["value"] = 1.25,
			},
			-- Mastery: Shadow Orb Power
			{
				["spec"] = 3,
				["value"] = 1.45,
			},
		},
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_SPELL_DMG_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_HEALING_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 3.1830,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		["ADD_MANA_REG_MOD_NORMAL_MANA_REG"] = {
			-- Passive: Meditation (Discipline)
			{
				["value"] = 0.5,
				["spellid"] = 95860,
				["spec"] = 1,
			},
			-- Passive: Meditation (Holy)
			{
				["value"] = 0.5,
				["spellid"] = 95861,
				["spec"] = 2,
			},
			-- Talent: Holy Concentration
			{
				["tab"] = 2,
				["num"] = 8,
				["rank"] = {
					0.15, 0.30,
				},
			},
		},
		["ADD_MANA_REG_MOD_MANA"] = {
			-- Talent: Dispersion
			{
				["tab"] = 3,
				["num"] = 21,
				["value"] = 0.30,
				["aura"] = 47585,
			},
		},
		["ADD_SPELL_HIT_RATING_MOD_SPI"] = {
			-- Talent: Twisted Faith
			{
				["tab"] = 3,
				["num"] = 7,
				["rank"] = {
					0.5, 1,
				},
			},
		},
		-- Priest: Inner Fire - Buff: 588
		-- 4.0.1: Increases armor from items by 60% and spell power by 1080.
		-- Priest: Glyph of Inner Fire - Glyph: 55686 - Buff: 588
		-- 4.0.1: Increases the armor from your Inner Fire spell by 50%.
		["MOD_ARMOR"] = {
			-- Inner Fire
			{
				["value"] = 0.6,
				["aura"] = 588,        -- ["Inner Fire"],
			},
			-- Glyph of Inner Fire
			{
				["rank"] = {
					0.1875, -- 1.9/1.6=1.1875
				},
				["aura"] = 588,        -- ["Inner Fire"],
				["glyph"] = 55686,        -- ["Glyph of Inner Fire"],
			},
		},
		["MOD_INT"] = {
			-- Passive: Enlightenment
			{
				["value"] = 0.15,
				["spellid"] = 84732,
				["spec"] = 1,
			},
			-- Passive: Mysticism
			{
				["value"] = 0.05,
				["known"] = 89745,
			},
		},
	}
elseif addon.class == "ROGUE" then
	StatLogic.StatModTable["ROGUE"] = {
		["ADD_MASTERY_EFFECT_MOD_MASTERY"] = {
			-- Mastery: Potent Poisons
			{
				["spec"] = 1,
				["value"] = 3.5,
			},
			-- Mastery: Main Gauche
			{
				["spec"] = 2,
				["value"] = 2,
			},
			-- Mastery: Executioner
			{
				["spec"] = 3,
				["value"] = 2.5,
			},
		},
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_RANGED_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["MOD_AP"] = {
			-- Talent: Savage Combat
			{
				["tab"] = 2,
				["num"] = 16,
				["rank"] = {
					0.03, 0.06,
				},
			},
			-- Passive: Vitality
			{
				["value"] = 0.30,
				["spellid"] = 61329,
				["spec"] = 2,
			},
		},
		-- Rogue: Reinforced Leather - Rank 2/2 - 2,10
		-- 4.0.1: Increases your armor contribution from cloth and leather items by 25/50%.
		["MOD_ARMOR"] = {
			-- Reinforced Leather
			{
				["tab"] = 2,
				["num"] = 10,
				["rank"] = {
					0.25, 0.5,
				},
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = -0.5900,
			},
			-- Talent: Lightning Reflexes
			{
				["tab"] = 2,
				["num"] = 8,
				["rank"] = {
					3, 6, 9,
				},
			},
			-- Buff: Evasion
			{
				["value"] = 50,
				["aura"] = 5277,
			},
			-- Buff: Ghostly Strike
			{
				["value"] = 15,
				["aura"] = 31022,
			},
		},
		["MOD_AGI"] = {
			-- Leather Specialization
			{
				["value"] = 0.05,
				["known"] = 86531,
				["armorspec"] = {
					[0] = true,
					[1] = true,
					[2] = true,
					[3] = true,
				},
			},
			-- Passive: Sinister Calling
			{
				["value"] = 0.30,
				["spellid"] = 31220,
				["spec"] = 3,
			},
		},
	}
elseif addon.class == "SHAMAN" then
	StatLogic.StatModTable["SHAMAN"] = {
		["ADD_MASTERY_EFFECT_MOD_MASTERY"] = {
			-- Mastery: Elemental Overload
			{
				["spec"] = 1,
				["value"] = 2,
			},
			-- Mastery: Enhanced Elements
			{
				["spec"] = 2,
				["value"] = 2.5,
			},
			-- Mastery: Deep Healing
			{
				["spec"] = 3,
				["value"] = 3,
			},
		},
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_SPELL_DMG_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
			-- Passive: Mental Quickness
			{
				["value"] = -1,
				["spellid"] = 30814,
				["spec"] = 2,
			},
		},
		["ADD_HEALING_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
			-- Passive: Mental Quickness
			{
				["value"] = -1,
				["spellid"] = 30814,
				["spec"] = 2,
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 1.6750,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		["ADD_SPELL_HIT_RATING_MOD_SPI"] = {
			-- Talent: Elemental Precision
			{
				["tab"] = 1,
				["num"] = 7,
				["rank"] = {
					0.33, 0.66, 1,
				},
			},
		},
		["ADD_MANA_REG_MOD_NORMAL_MANA_REG"] = {
			-- Passive: Meditation
			{
				["value"] = 0.50,
				["spellid"] = 95862,
				["spec"] = 3,
			},
		},
		["ADD_SPELL_DMG_MOD_AP"] = {
			-- Passive: Mental Quickness
			{
				["value"] = 0.55,
				["spellid"] = 30814,
				["spec"] = 2,
			},
		},
		["ADD_HEALING_MOD_AP"] = {
			-- Passive: Mental Quickness
			{
				["value"] = 0.55,
				["spellid"] = 30814,
				["spec"] = 2,
			},
		},
		-- Shaman: Toughness - Rank 3/3 - 2,8
		-- 4.0.1: Increases your Stamina by 3/7/10%
		["MOD_STA"] = {
			{
				["tab"] = 2,
				["num"] = 8,
				["rank"] = {
					0.03, 0.07, 0.1,
				},
			},
		},
		-- Shaman: Mail Specialization - Passive: 86529
		-- 4.0.1: Increases your primary attribute by 5% while wearing Mail in all armor slots. Elemental specialization grants Intellect, Enhancement specialization grants Agility, and Restoration specialization grants Intellect.
		["MOD_AGI"] = {
			-- Mail Specialization
			{
				["value"] = 0.05,
				["known"] = 86529,
				["armorspec"] = {
					[2] = true,
				},
			},
		},
		-- Shaman: Mail Specialization - Passive: 86529
		-- 4.0.1: Increases your primary attribute by 5% while wearing Mail in all armor slots. Elemental specialization grants Intellect, Enhancement specialization grants Agility, and Restoration specialization grants Intellect.
		["MOD_INT"] = {
			-- Mail Specialization
			{
				["value"] = 0.05,
				["known"] = 86529,
				["armorspec"] = {
					[1] = true,
				},
			},
			-- Mail Specialization
			{
				["value"] = 0.05,
				["known"] = 86529,
				["armorspec"] = {
					[3] = true,
				},
			},
		},
	}
elseif addon.class == "WARLOCK" then
	StatLogic.StatModTable["WARLOCK"] = {
		["ADD_MASTERY_EFFECT_MOD_MASTERY"] = {
			-- Mastery: Potent Afflictions
			{
				["spec"] = 1,
				["value"] = 1.63,
			},
			-- Mastery: Master Demonologist
			{
				["spec"] = 2,
				["value"] = 2.3,
			},
			-- Mastery: Fiery Apocalypse
			{
				["spec"] = 3,
				["value"] = 1.35,
			},
		},
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_SPELL_DMG_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_HEALING_MOD_INT"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 2.0350,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_SPI"] = {
			{
				["regen"] = NormalManaRegenPerSpi,
			},
		},
		["ADD_NORMAL_MANA_REG_MOD_INT"] = {
			{
				["regen"] = NormalManaRegenPerInt,
			},
		},
		-- Warlock: Metamorphosis - Buff: 47241
		-- 4.0.1: Armor contribution from items increased by 600%. Chance to be critically hit by melee reduced by 6%.
		["MOD_ARMOR"] = {
			-- Metamorphosis
			{
				["value"] = 6,
				["aura"] = 47241,
			},
		},
		-- Warlock: Demonic Embrace - Rank 3/3 - 2,1
		--          Increases your total Stamina by 4/7/10%.
		["MOD_STA"] = {
			{
				["tab"] = 2,
				["num"] = 1,
				["rank"] = {
					0.04, 0.07, 0.1,
				},
			},
		},
		["MOD_INT"] = {
			-- Passive: Nethermancy
			{
				["value"] = 0.05,
				["known"] = 86091,
			},
		},
	}
elseif addon.class == "WARRIOR" then
	StatLogic.StatModTable["WARRIOR"] = {
		["ADD_MASTERY_EFFECT_MOD_MASTERY"] = {
			-- Mastery: Strikes of Opportunity
			{
				["spec"] = 1,
				["value"] = 2.2,
			},
			-- Mastery: Unshackled Fury
			{
				["spec"] = 2,
				["value"] = 5.6,
			},
			-- Mastery: Critical Block
			{
				["spec"] = 3,
				["value"] = 1.5,
			},
		},
		["ADD_BLOCK_CHANCE_MOD_MASTERY_EFFECT"] = {
			-- Mastery: Critical Block
			{
				["spec"] = 3,
				["value"] = 1,
			},
		},
		["ADD_AP_MOD_STR"] = {
			-- Base
			{
				["value"] = 2,
			},
		},
		["ADD_AP_MOD_STA"] = {
			-- Buff: Vengeance (100% of Stamina, not 10% of HP)
			{
				["value"] = 1,
				["spec"] = 3,
				["aura"] = 76691,
			},
		},
		["ADD_RANGED_AP_MOD_AGI"] = {
			-- Base
			{
				["value"] = 1,
			},
		},
		["ADD_DODGE"] = {
			-- Base
			{
				["value"] = 5.0000,
			},
		},
		["ADD_PARRY_RATING_MOD_STR"] = {
			-- Passive: Forceful Deflection
			{
				["spellid"] = 49410,
				["value"] = 0.27,
			},
		},
		-- Warrior: Last Stand - Buff: 12976
		-- 4.0.1: Health increased by 30% of maximum.
		["MOD_HEALTH"] = {
			-- Last Stand
			{
				["value"] = 0.3,
				["aura"] = 12975,        -- ["Last Stand"],
			},
		},
		-- Warrior: Toughness - Rank 3/3 - 3,2
		-- 4.0.1: Increases your armor value from items by 3/6/10%.
		["MOD_ARMOR"] = {
			-- Toughness
			{
				["tab"] = 3,
				["num"] = 2,
				["rank"] = {
					0.03, 0.06, 0.1,
				},
			},
		},
		["MOD_STA"] = {
			-- Plate Specialization
			{
				["value"] = 0.05,
				["known"] = 86526,
				["armorspec"] = {
					[3] = true,
				},
			},
			-- Passive: Sentinel
			{
				["value"] = 0.15,
				["spellid"] = 29144,
				["spec"] = 3,
			},
		},
		-- Warrior: Plate Specialization - Passive: 86526
		-- 4.0.1: Increases your primary attribute by 5% while wearing Plate in all armor slots. Arms specialization grants Strength, Fury specialization grants Strength, and Protection specialization grants Stamina.
		["MOD_STR"] = {
			-- Plate Specialization
			{
				["value"] = 0.05,
				["known"] = 86526,
				["armorspec"] = {
					[1] = true,
					[2] = true,
				},
			},
		},
	}
end

if addon.playerRace == "Dwarf" then
	StatLogic.StatModTable["Dwarf"] = {
		[StatLogic.Stats.Expertise] = {
			{
				["value"] = 3,
				["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_MANA"] = {
			-- Gnome: Expansive Mind - Racial
			-- 4.0.1: Mana pool increased by 5%.
			{
				["value"] = 0.05,
			},
		},
		[StatLogic.Stats.Expertise] = {
			{
				["value"] = 3,
				["weapon"] = {
					[Enum.ItemWeaponSubclass.Dagger] = true,
					[Enum.ItemWeaponSubclass.Sword1H] = true,
				}
			}
		},
	}
elseif addon.playerRace == "Human" then
	StatLogic.StatModTable["Human"] = {
		["MOD_SPI"] = {
			-- Human: The Human Spirit - Racial
			-- 4.0.1: Spirit increased by 3%.
			{
				["value"] = 0.03,
			},
		},
		[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"] = 3,
				["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"] = {
		{
			["level"] = setmetatable({
				[81] = 10.8,
				[82] = 11.6,
				[83] = 12.4,
				[84] = 13.2,
				[85] = 14.0,
			}, {
				__index = function()
					return 10
				end
			})
		},
	},
	["ADD_NORMAL_HEALTH_REG_MOD_HEALTH"] = {
		{
			-- Levels 1-19 are likely two piecewise linear sections,
			-- with the intersection at roughly 15
			["level"] = setmetatable({
				0.6250,
				0.5938,
				0.5625,
				0.5313,
				0.5000,
				0.4688,
				0.4375,
				0.4063,
				0.3750,
				0.3438,
				0.3125,
				0.2813,
				0.2500,
				0.2188,
				0.1875,
				0.1528,
				0.1212,
				0.0893,
				0.0574,
			}, {
				-- Levels 20-85 are all 2.5% HP5 (1% HP2)
				__index = function()
					return 0.025
				end
			})
		},
	},
	["ADD_MANA_MOD_INT"] = {
		{
			["value"] = 15,
		},
	},
	["ADD_MANA_REG_MOD_MANA"] = {
		-- Replenishment - Buff
		-- 4.0.1: Replenishes 1% of maximum mana per 10 sec.
		{
			["value"] = 0.005,
			["aura"] = 57669,
		},
	},
	["MOD_SPELL_DMG"] = {
		-- Warlock: Demonic Pact - Buff: 53646
		-- 4.0.1: Spell Power increased by 10%.
		{
			["value"] = 0.1,
			["aura"] = 53646,
			["group"] = addon.ExclusiveGroup.SpellPower,
		},
		-- Shaman: Totemic Wrath - Buff: 77747
		-- 4.0.1: Spell Power increased by 10%.
		{
			["value"] = 0.1,
			["aura"] = 77747,
			["group"] = addon.ExclusiveGroup.SpellPower,
		},
		-- Shaman: Flametongue Totem - Buff: 52109
		-- 4.0.1: Spell Power increased by 6%.
		{
			["value"] = 0.06,
			["aura"] = 52109,
			["group"] = addon.ExclusiveGroup.SpellPower,
		},
		-- Mage: Arcane Brilliance - Buff: 79058
		-- 4.0.1: Spell Power increased by 6%.
		{
			["value"] = 0.06,
			["aura"] = 79058,
			["group"] = addon.ExclusiveGroup.SpellPower,
		},
		-- Mage: Dalaran Brilliance - Buff: 61316
		-- 4.0.1: Spell Power increased by 6%.
		{
			["value"] = 0.06,
			["aura"] = 61316,
			["group"] = addon.ExclusiveGroup.SpellPower,
		},
	},
	["MOD_HEALING"] = {
		-- Warlock: Demonic Pact - Buff: 53646
		-- 4.0.1: Spell Power increased by 10%.
		{
			["value"] = 0.1,
			["aura"] = 53646,
			["group"] = addon.ExclusiveGroup.SpellPower,
		},
		-- Shaman: Totemic Wrath - Buff: 77747
		-- 4.0.1: Spell Power increased by 10%.
		{
			["value"] = 0.1,
			["aura"] = 77747,
			["group"] = addon.ExclusiveGroup.SpellPower,
		},
		-- Shaman: Flametongue Totem - Buff: 52109
		-- 4.0.1: Spell Power increased by 6%.
		{
			["value"] = 0.06,
			["aura"] = 52109,
			["group"] = addon.ExclusiveGroup.SpellPower,
		},
		-- Mage: Arcane Brilliance - Buff: 79058
		-- 4.0.1: Spell Power increased by 6%.
		{
			["value"] = 0.06,
			["aura"] = 79058,
			["group"] = addon.ExclusiveGroup.SpellPower,
		},
		-- Mage: Dalaran Brilliance - Buff: 61316
		-- 4.0.1: Spell Power increased by 6%.
		{
			["value"] = 0.06,
			["aura"] = 61316,
			["group"] = addon.ExclusiveGroup.SpellPower,
		},
	},
	["MOD_ARMOR"] = {
		-- MetaGem: Austere Earthsiege Diamond - Meta: 41380
		-- 4.0.1: 2% Increased Armor Value from Items
		{
			["value"] = 0.02,
			["meta"] = 41380,
		},
		-- MetaGem: Austere Shadowspirit Diamond - Meta: 52294
		-- 4.0.1: 2% Increased Armor Value from Items
		{
			["value"] = 0.02,
			["meta"] = 52294,
		},
	},
	["MOD_AP"] = {
		-- Hunter: Trueshot Aura - Buff: 19506
		-- 4.0.1: Attack power increased by 10%.
		{
			["value"] = 0.1,
			["aura"] = 19506,
			["group"] = addon.ExclusiveGroup.AttackPower,
		},
		-- Death Knight: Abomination's Might - Buff: 55972
		-- 4.0.1: Attack power increased by 5/10%.
		{
			["rank"] = {
				0.05, 0.1,
			},
			["aura"] = 55972,
			["group"] = addon.ExclusiveGroup.AttackPower,
		},
		-- Shaman: Unleashed Rage - Buff: 30809
		-- 4.0.1: Melee attack power increased by 4/7/10%.
		{
			["rank"] = {
				0.04, 0.07, 0.1,
			},
			["aura"] = 30802,
			["group"] = addon.ExclusiveGroup.AttackPower,
		},
		-- Paladin: Blessing of Might - Buff: 19740
		-- 4.0.1: Increasing attack power by 10%.
		{
			["value"] = 0.1,
			["aura"] = 19740,
			["group"] = addon.ExclusiveGroup.AttackPower,
		},
	},
	["MOD_MANA"] = {
		-- MetaGem: Beaming Earthsiege Diamond - Meta: 41389
		-- 4.0.1: +2% Mana
		{
			["value"] = 0.02,
			["meta"] = 41389,
		},
		-- MetaGem: Ember Skyfire Diamond - Meta: 35503
		-- 4.0.1: +2% Maximum Mana
		{
			["value"] = 0.02,
			["meta"] = 35503,
		},
		-- MetaGem: Ember Skyflare Diamond - Meta: 41333
		-- 4.0.1: +2% Maximum Mana
		{
			["value"] = 0.02,
			["meta"] = 41333,
		},
		-- MetaGem: Ember Shadowspirit Diamond - Meta: 52296
		-- 4.0.1: +2% Maximum Mana
		{
			["value"] = 0.02,
			["meta"] = 52296,
		},
	},
	["MOD_STR"] = {
		-- Paladin: Blessing of Kings - Buff: 20217
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 20217,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Druid: Mark of the Wild - Buff: 79061
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 79061,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Hunter: Embrace of the Shale Spider - Buff: 90363
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 90363,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Leatherworking: Blessing of Forgotten Kings - Buff: 69378
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 4%.
		{
			["value"] = 0.04,
			["aura"] = 69378,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
	},
	["MOD_AGI"] = {
		-- Paladin: Blessing of Kings - Buff: 20217
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 20217,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Druid: Mark of the Wild - Buff: 79061
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 79061,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Hunter: Embrace of the Shale Spider - Buff: 90363
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 90363,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Leatherworking: Blessing of Forgotten Kings - Buff: 69378
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 4%.
		{
			["value"] = 0.04,
			["aura"] = 69378,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
	},
	["MOD_STA"] = {
		-- Paladin: Blessing of Kings - Buff: 20217
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 20217,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Druid: Mark of the Wild - Buff: 79061
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 79061,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Hunter: Embrace of the Shale Spider - Buff: 90363
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 90363,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Leatherworking: Blessing of Forgotten Kings - Buff: 69378
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 4%.
		{
			["value"] = 0.04,
			["aura"] = 69378,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
	},
	["MOD_INT"] = {
		-- Paladin: Blessing of Kings - Buff: 20217
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 20217,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Druid: Mark of the Wild - Buff: 79061
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 79061,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Hunter: Embrace of the Shale Spider - Buff: 90363
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 5%.
		{
			["value"] = 0.05,
			["aura"] = 90363,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
		-- Leatherworking: Blessing of Forgotten Kings - Buff: 69378
		-- 4.0.1: Strength, Agility, Stamina, and Intellect increased by 4%.
		{
			["value"] = 0.04,
			["aura"] = 69378,
			["group"] = addon.ExclusiveGroup.AllStats,
		},
	},
	["MOD_SPI"] = {
		-- Shaman: Mana Tide - Buff: 16191
		-- 4.0.1: Spirit increased by 350%.
		{
			["value"] = 3.5,
			["aura"] = 16191,
		},
	},
	["MOD_HEALTH"] = {
		-- Buff: Rallying Cry
		{
			["value"] = 0.20,
			["aura"] = 97463,
		},
	},
	["ADD_DODGE_REDUCTION_MOD_EXPERTISE"] = {
		-- Base
		{
			["value"] = 0.25,
		}
	},
	["ADD_PARRY_REDUCTION_MOD_EXPERTISE"] = {
		-- Base
		{
			["value"] = 0.25,
		}
	},
	["ADD_PVP_DAMAGE_REDUCTION_MOD_RESILIENCE"] = {
		-- Base
		{
			["value"] = -1,
		},
	},
}

--=====================================--
-- 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.0152366,
	["PALADIN"]     = 1/0.0152366,
	["HUNTER"]      = 1/0.006870,
	["ROGUE"]       = 1/0.006870,
	["PRIEST"]      = 1/0.0152366,
	["DEATHKNIGHT"] = 1/0.0152366,
	["SHAMAN"]      = 1/0.006870,
	["MAGE"]        = 1/0.0152366,
	["WARLOCK"]     = 1/0.0152366,
	["DRUID"]       = 1/0.0152366,
}
local C_d = {
	["WARRIOR"]     = 1/0.0152366,
	["PALADIN"]     = 1/0.0152366,
	["HUNTER"]      = 1/0.006870,
	["ROGUE"]       = 1/0.006870,
	["PRIEST"]      = 1/0.006650,
	["DEATHKNIGHT"] = 1/0.0152366,
	["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 = {16, 16, 16, 16, 16, 16, 16, 16, 16, 16, }

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,
	["SHAMAN"] = 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()
	-- Collect data
	local D_dr = GetDodgeChance()
	if D_dr == 0 then
		return 0
	end
	local dodgeFromDodgeRating = GetCombatRatingBonus(CR_DODGE)
	local D_r = dodgeFromDodgeRating
	local D_b = self:GetStatMod("ADD_DODGE")
	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

function StatLogic:GetResilienceEffectAfterDR(damageReductionBeforeDR)
	-- argCheck for invalid input
	self:argCheck(damageReductionBeforeDR, 2, "number")
	return 100 - 100 * 0.99 ^ damageReductionBeforeDR
end

function StatLogic:GetResilienceEffectGainAfterDR(resAfter, resBefore)
	-- argCheck for invalid input
	self:argCheck(resAfter, 2, "number")
	self:argCheck(resBefore, 2, "nil", "number")
	local resCurrent = GetCombatRating(COMBAT_RATING_RESILIENCE_PLAYER_DAMAGE_TAKEN)
	local drBefore
	if resBefore then
		drBefore = self:GetResilienceEffectAfterDR(self:GetEffectFromRating(resCurrent + resBefore, StatLogic.Stats.ResilienceRating))
	else
		drBefore = GetCombatRatingBonus(COMBAT_RATING_RESILIENCE_PLAYER_DAMAGE_TAKEN)
	end
	return self:GetResilienceEffectAfterDR(self:GetEffectFromRating(resCurrent + resAfter, StatLogic.Stats.ResilienceRating)) - drBefore
end
