Site News
Warning: This wiki contains spoilers. Read at your own risk!

Module:PromoGains

From Fire Emblem Wiki, your source on Fire Emblem information. By fans, for fans.

Syntax

Use with Template:PromotionGains Auto instead of invoking directly.

Normal

{{PromotionGains Auto|FE<number>|baseClass|promoClass|promoClass2 (optional)|promoClass3 (optional)|promoClass4 (optional)}}

Games tend to only support the number of promoted classes that they need. For most games 2, 3, and 4 are further options from the base class, but for Gaiden, Echoes, and Radiant Dawn they are sequential promotions.

For units with Holy Blood in Genealogy of the Holy War

{{PromotionGains Auto|FE<number>|baseClass|promoClass|holyBlood|bloodLevel|holyBlood2|bloodLevel2}}

Blood level is Major or Minor (case insensitive). You can omit the last two parameters if the unit only has one holy blood type, or the last four parameters if the unit has none.

For Engage

{{PromotionGains Auto|FE<number>|baseClass|promoClass|promoClass2|innateProficiency}}

promoClass2 can be left blank if needed.


--To do:
	--1: Add Radiant Dawn
	--2: Add Gaiden
	--3: Add Echoes
	--4: Add weapon level functionality for Genealogy (DONE)
	--5: For FE8, add functionality for Pupil to lose Anima when promoting to Shaman
	--6: Add skill functionality for FE8 (DONE)

local getArgs = require('Module:Arguments').getArgs
local p = {}

local prefix = "''x'' to "

local function createLink(classData,class)
	return "[[" .. classData[class].article .. "|" .. classData[class].name .. "]]"
end

local function statSign(stat)
	if stat < 0 then
		return "−"
	else
		return "+"
	end
end

local function arrayContains(array,value) --Use to see if an array contains a value
	for i = 1,#array do
		if (array[i] == value) then
			return true
		end
	end
	return false
end

local function deleteComma(str) --Used for deleting commas with trailing space if at end of string
	if string.sub(str, -2) == ", " then
		return string.sub(str, 1, -3)
	else
		return str
	end
end

local function FE1(frame,classData,baseClass,promoClass)
	local promoLink = createLink(classData,promoClass)
	local hp = classData[promoClass].hp
	local str = classData[promoClass].str
	local skl = classData[promoClass].skl
	local spd = classData[promoClass].spd
	local def = classData[promoClass].def
	local mov = classData[promoClass].mov
	local wlv = classData[promoClass].wlv
	--Checking if promoted stat is lower or equal to base class's stat, and if so, setting to zero; doing this because of how the manual entries are set up at time of writing
	local function gainCheck(class, stat, statName)
		if stat > classData[baseClass][statName] then
			return prefix .. stat
		else
			return 0
		end
	end
	hp = gainCheck(promoClass,hp,"hp")
	str = gainCheck(promoClass,str,"str")
	skl = gainCheck(promoClass,skl,"skl")
	spd = gainCheck(promoClass,spd,"spd")
	def = gainCheck(promoClass,def,"def")
	mov = gainCheck(promoClass,mov,"mov")
	wlv = gainCheck(promoClass,wlv,"wlv")
	return frame:expandTemplate{ title = 'PromotionGains', args = { movelabel = "Move", lcklabel = "Luck", class = promoLink, hp = hp, str = str, skill = skl, spd = spd, def = def, res = 0, move = mov, weaponlvl = "+" .. wlv } } .. string.char(10) .. ":In ''Shadow Dragon & the Blade of Light'', promotion gains consist on giving the character as many points as necessary—the ''x'' value shown in the table—to reach the promoted class's base stats. If the character's stats are higher than their promoted class' base stats, they will not receive any bonus."
end

local function FE2(frame,classData,baseClass,promoClass,promoClass2,promoClass3)
	return "Gaiden placeholder"
end

local function FE3(frame,classData,baseClass,promoClass)
	local promoLink = createLink(classData,promoClass)
	local function gainCheck(class, stat, statName)
	--	if stat > classData[baseClass][statName] then
			return prefix .. stat
	--	else
	--		return 0
	--	end
	end
	local hp = classData[promoClass].hp
	local wlv = classData[promoClass].wlv
	hp = gainCheck(promoClass,hp,"hp")
	wlv = gainCheck(promoClass,wlv,"wlv")
	local function generateGain(stat)
		return classData[promoClass][stat] - classData[baseClass][stat]
	end
	local str = generateGain("str")
	local skl = generateGain("skl")
	local spd = generateGain("spd")
	local def = generateGain("def")
	local res = generateGain("res")
	local mov = generateGain("mov")
	local strSign = statSign(str)
	local sklSign = statSign(skl)
	local spdSign = statSign(spd)
	local defSign = statSign(def)
	local resSign = statSign(res)
	local movSign = statSign(mov)
	return frame:expandTemplate{ title = 'PromotionGains', args = { class = promoLink, hp = hp, str = math.abs(str), skill = math.abs(skl), spd = math.abs(spd), def = math.abs(def), res = math.abs(res), move = math.abs(mov), weaponlvl = "+" .. wlv, strsign = strSign, skillsign = sklSign, spdsign = spdSign, defsign = defSign, ressign = resSign, movesign = movSign } } .. string.char(10) .. ":In ''Mystery of the Emblem'', promotion gains for HP and weapon level consist of giving the character as many points as necessary—the ''x'' value shown in the table—to reach the promoted class's base value. If the character's value for one of those two stats is higher than their promoted class's base value, they will not receive any bonus in that stat."
end

local function FE4(frame,classData,baseClass,promoClass,holyBlood,bloodLevel,holyBlood2,bloodLevel2)
	local promoLink = createLink(classData,promoClass)
	local wlv = ""
	local function generateGain(stat)
		return classData[promoClass][stat] - classData[baseClass][stat]
	end
	local str = generateGain("str")
	local mag = generateGain("mag")
	local skl = generateGain("skl")
	local spd = generateGain("spd")
	local def = generateGain("def")
	local res = generateGain("res")
	local mov = generateGain("mov")
	local skills = ""
	local baseSkills = classData[baseClass]["skills"]
	local promoSkills = classData[promoClass]["skills"]
	local weapons = { "sword", "lance", "axe", "bow", "staff", "fire", "thunder", "wind", "light", "dark" }
	local wlvNumericToLetter = {
		[1] = "C",
		[2] = "B",
		[3] = "A",
		[10] = "★"
	}
	local holyBloodWeapons = {
		Baldr = "sword",
		Od = "sword",
		["Dáinn"] = "lance",
		Ullr = "bow",
		Bragi = "staff",
		Thrud = "thunder",
		Fjalar = "fire",
		["Hoðr"] = "sword",
		["Njörun"] = "lance",
		["Nál"] = "axe",
		Naga = "light",
		Forseti = "wind",
		Loptous = "dark"
	}
	local unitWeaponLevels = {
		swordLevel = classData[promoClass]["sword"],
		lanceLevel = classData[promoClass]["lance"],
		axeLevel = classData[promoClass]["axe"],
		bowLevel = classData[promoClass]["bow"],
		staffLevel = classData[promoClass]["staff"],
		fireLevel = classData[promoClass]["fire"],
		thunderLevel = classData[promoClass]["thunder"],
		windLevel = classData[promoClass]["wind"],
		lightLevel = classData[promoClass]["light"],
		darkLevel = classData[promoClass]["dark"]
	}
	local function calculateWlvs(holyBlood,bloodLevel)
		if holyBloodWeapons[holyBlood] then
			if bloodLevel == "minor" then
				for i, weapon in ipairs(weapons) do
					if unitWeaponLevels[weapon.."Level"] > 0 and holyBloodWeapons[holyBlood] == weapon then
						unitWeaponLevels[weapon.."Level"] = unitWeaponLevels[weapon.."Level"] + 1
					end
				end
			elseif bloodLevel == "major" then
				for i, weapon in ipairs(weapons) do
					if unitWeaponLevels[weapon.."Level"] > 0 and holyBloodWeapons[holyBlood] == weapon then
						unitWeaponLevels[weapon.."Level"] = 10
					end
				end
			end
		end
	end
	local function generateWlv(weapon)
		local weaponLevel = unitWeaponLevels[weapon .. "Level"]
		if weaponLevel > 3 and weaponLevel < 10 then
			weaponLevel = 3
		elseif weaponLevel > 10 then
			weaponLevel = 10
		end
		local suffix = ""
		if weaponLevel ~= 0 then
			suffix = wlvNumericToLetter[weaponLevel]
			if promoClass == "Master Knight" and weapon == "bow" then
				suffix = suffix .. "<br>"
			end
			wlv = wlv .. frame:expandTemplate{ title = weapon .. "SNES", args = { "4" } } .. " " .. suffix .. " "
		end
	end
	if holyBlood and bloodLevel then
		calculateWlvs(holyBlood,bloodLevel)
	end
	if holyBlood2 and bloodLevel2 then
		calculateWlvs(holyBlood2,bloodLevel2)
	end
	for i, weapon in ipairs(weapons) do
		generateWlv(weapon)
	end
	for i, skill in ipairs(promoSkills) do
		if arrayContains(baseSkills, skill) == false then
			skills = skills .. "+[[" .. skill .. "]], "
		end
	end
	for i, skill in ipairs(baseSkills) do
		if arrayContains(promoSkills, skill) == false then
			skills = skills .. "−[[" .. skill .. "]], "
		end
	end
	skills = deleteComma(skills)
	if wlv == "" then
		wlv = frame:expandTemplate{ title = "nwh" }
	end
	return frame:expandTemplate{ title = 'PromotionGains', args = { class = promoLink, hp = 0, str = str, mag = mag, skill = skl, spd = spd, def = def, res = res, move = mov, skills = skills, weaponlvl = wlv } }
end

local function FE5(frame,classData,baseClass,promoClass,promoClass2)
	local promoLink = createLink(classData,promoClass)
	local function generateGain(class,stat)
		return classData[class][stat] - classData[baseClass][stat]
	end
	local str = generateGain(promoClass,"str")
	local mag = generateGain(promoClass,"mag")
	local skl = generateGain(promoClass,"skl")
	local spd = generateGain(promoClass,"spd")
	local def = generateGain(promoClass,"def")
	local con = generateGain(promoClass,"con")
	local mov = generateGain(promoClass,"mov")
	local strSign = statSign(str)
	local magSign = statSign(mag)
	local sklSign = statSign(skl)
	local spdSign = statSign(spd)
	local defSign = statSign(def)
	local conSign = statSign(con)
	local movSign = statSign(mov)
	local wlvTable = {
		[50] = "E",
		[100] = "D",
		[150] = "C",
		[200] = "B",
		[250] = "A",
	}
	
	local wlv = ""
	local wlv2 = ""
	local function generateWlv(class,weapon)
		local change = generateGain(class,weapon)
		local suffix = ""
		if wlvTable[change] and classData[baseClass][weapon] == 0 then
			suffix = wlvTable[change]
		elseif change < 0 then
			suffix = "−" .. math.abs(change) .. " WEXP"
		else
			suffix = "+" .. change .. " WEXP"
		end
		if change ~= 0 then
			if class == promoClass then
				wlv = wlv .. frame:expandTemplate{ title = weapon .. "SNES", args = { "5" } } .. " " .. suffix .. " "
			elseif class == promoClass2 then
				wlv2 = wlv2 .. frame:expandTemplate{ title = weapon .. "SNES", args = { "5" } } .. " " .. suffix .. " "
			end
		end
	end
	local weapons = { "sword", "lance", "axe", "bow", "staff", "fire", "thunder", "wind", "light", "dark" }
	for i, weapon in ipairs(weapons) do
		generateWlv(promoClass,weapon)
	end
	if wlv == "" then
		wlv = frame:expandTemplate{ title = "nwh" }
	end
	
	local baseSkills = classData[baseClass]["skills"]
	local promoSkills = classData[promoClass]["skills"]
	local skills = ""
	for i, skill in ipairs(promoSkills) do
		if arrayContains(baseSkills, skill) == false and skill ~= "Steal" then --Purposefully don't add Steal because of Lara's personal Steal skill.
			skills = skills .. "+[[" .. skill .. "]], "
		end
	end
	for i, skill in ipairs(baseSkills) do
		if arrayContains(promoSkills, skill) == false and skill ~= "Steal" then --Purposefully don't remove Steal because of Lara's personal Steal skill.
			skills = skills .. "−[[" .. skill .. "]], "
		end
	end
	skills = deleteComma(skills)
	
	if promoClass2 == nil then
		return frame:expandTemplate{ title = 'PromotionGains', args = { class = promoLink, hp = 0, str = math.abs(str), mag = math.abs(mag), skill = math.abs(skl), spd = math.abs(spd), def = math.abs(def), con = math.abs(con), move = math.abs(mov), skills = skills, weaponlvl = wlv, strsign = strSign, magsign = magSign, skillsign = sklSign, spdsign = spdSign, defsign = defSign, consign = conSign, movesign = movSign } }
	else
		local promoLink2 = createLink(classData,promoClass2)
		local str2 = generateGain(promoClass2,"str")
		local mag2 = generateGain(promoClass2,"mag")
		local skl2 = generateGain(promoClass2,"skl")
		local spd2 = generateGain(promoClass2,"spd")
		local def2 = generateGain(promoClass2,"def")
		local con2 = generateGain(promoClass2,"con")
		local mov2 = generateGain(promoClass2,"mov")
		local strSign2 = statSign(str2)
		local magSign2 = statSign(mag2)
		local sklSign2 = statSign(skl2)
		local spdSign2 = statSign(spd2)
		local defSign2 = statSign(def2)
		local conSign2 = statSign(con2)
		local movSign2 = statSign(mov2)
		for i, weapon in ipairs(weapons) do
			generateWlv(promoClass2,weapon)
		end
		if wlv2 == "" then
			wlv2 = frame:expandTemplate{ title = "nwh" }
		end
		local skills2 = ""
		local promoSkills2 = classData[promoClass2]["skills"]
			for i, skill in ipairs(promoSkills2) do
			if arrayContains(baseSkills, skill) == false and skill ~= "Steal" then --Purposefully don't add Steal because of Lara's personal Steal skill.
				skills2 = skills2 .. "+[[" .. skill .. "]], "
			end
		end
		for i, skill in ipairs(baseSkills) do
			if arrayContains(promoSkills2, skill) == false and skill ~= "Steal" then --Purposefully don't remove Steal because of Lara's personal Steal skill.
				skills2 = skills2 .. "−[[" .. skill .. "]], "
			end
		end
		skills2 = deleteComma(skills2)
		return frame:expandTemplate{ title = 'PromotionGains', args = { class1 = promoLink, hp1 = 0, str1 = math.abs(str), mag1 = math.abs(mag), skill1 = math.abs(skl), spd1 = math.abs(spd), def1 = math.abs(def), con1 = math.abs(con), move1 = math.abs(mov), skills1 = skills, weaponlvl1 = wlv, str1sign = strSign, mag1sign = magSign, skill1sign = sklSign, spd1sign = spdSign, def1sign = defSign, con1sign = conSign, move1sign = movSign, class = promoLink2, hp = 0, str = math.abs(str2), mag = math.abs(mag2), skill = math.abs(skl2), spd = math.abs(spd2), def = math.abs(def2), con = math.abs(con2), move = math.abs(mov2), skills = skills2, weaponlvl = wlv2, strsign = strSign2, magsign = magSign2, skillsign = sklSign2, spdsign = spdSign2, defsign = defSign2, consign = conSign2, movesign = movSign2 } }
	end
end

local function FE6(frame,classData,baseClass,promoClass)
	local promoLink = createLink(classData,promoClass)
	local function generateGain(stat)
		return classData[promoClass][stat] - classData[baseClass][stat]
	end
	local hp = generateGain("hp")
	local str = generateGain("str")
	local skl = generateGain("skl")
	local spd = generateGain("spd")
	local def = generateGain("def")
	local res = generateGain("res")
	local con = generateGain("con")
	local mov = generateGain("mov")
	local wlv = ""
	local strLabel = "Str"
	local wlvTable = {
		[1] = "E",
		[51] = "D",
		[101] = "C",
		[151] = "B",
		[201] = "A",
		[251] = "S"
	}
	local function generateWlv(weapon)
		local change = generateGain(weapon)
		local suffix = ""
		if wlvTable[change] then
			suffix = wlvTable[change]
		elseif change < 0 then
			suffix = "−" .. math.abs(change) .. " WEXP"
		else
			suffix = "+" .. change .. " WEXP"
		end
		if change ~= 0 then
			wlv = wlv .. frame:expandTemplate{ title = weapon .. "GBA" } .. " " .. suffix .. " "
		end
	end
	local physWeapons = { "sword", "lance", "axe", "bow" }
	local magWeapons = { "staff", "anima", "light", "dark" }
	if classData[promoClass].staff == 0 and classData[promoClass].anima == 0 and classData[promoClass].light == 0 and classData[promoClass].dark == 0 then
		for i, weapon in ipairs(physWeapons) do
			generateWlv(weapon)
		end
	else
		strLabel = "Mag"
		for i, weapon in ipairs(magWeapons) do
			generateWlv(weapon)
		end
	end
	if wlv == "" then
		wlv = frame:expandTemplate{ title = "nwh" }
	end
	return frame:expandTemplate{ title = 'PromotionGains', args = { movelabel = "Move", lcklabel = "Luck", strlabel = strLabel, class = promoLink, hp = hp, str = str, skill = skl, spd = spd, def = def, res = res, con = con, move = mov, weaponlvl = wlv } }
end

local function FE7(frame,classData,baseClass,promoClass)
	local promoLink = createLink(classData,promoClass)
	local function generateGain(stat)
		return classData[promoClass][stat] - classData[baseClass][stat]
	end
	local hp = classData[promoClass].hpPromoGain
	local str = classData[promoClass].strPromoGain
	local skl = classData[promoClass].sklPromoGain
	local spd = classData[promoClass].spdPromoGain
	local def = classData[promoClass].defPromoGain
	local res = classData[promoClass].resPromoGain
	local con = generateGain("con")
	local mov = generateGain("mov")
	local movSign = statSign(mov)
	local strLabel = "Str"
	local wlv = ""
	local wlv2 = ""
	local wlv3 = ""
	local wlvTable = {
		[1] = "E",
		[31] = "D",
		[71] = "C",
		[121] = "B",
		[181] = "A",
		[251] = "S"
	}
	local function generateWlv(weapon)
		local change = generateGain(weapon)
		local suffix = ""
		if wlvTable[change] then
			suffix = wlvTable[change]
		elseif change < 0 then
			suffix = "−" .. math.abs(change) .. " WEXP"
		else
			suffix = "+" .. change .. " WEXP"
		end
		if change ~= 0 then
			wlv = wlv .. frame:expandTemplate{ title = weapon .. "GBA" } .. " " .. suffix .. " "
		end
	end
	local physWeapons = { "sword", "lance", "axe", "bow" }
	local magWeapons = { "staff", "anima", "light", "dark" }
	if classData[promoClass].staff == 0 and classData[promoClass].anima == 0 and classData[promoClass].light == 0 and classData[promoClass].dark == 0 then
		for i, weapon in ipairs(physWeapons) do
			generateWlv(weapon)
		end
	else
		strLabel = "Mag"
		for i, weapon in ipairs(magWeapons) do
			generateWlv(weapon)
		end
	end
	if wlv == "" then
		wlv = frame:expandTemplate{ title = "nwh" }
	end
	return frame:expandTemplate{ title = 'PromotionGains', args = { movelabel = "Move", lcklabel = "Luck", strlabel = strLabel, class = promoLink, hp = hp, str = str, skill = skl, spd = spd, def = def, res = res, con = con, move = math.abs(mov), weaponlvl = wlv, movesign = movSign } }
end

local function FE8(frame,classData,baseClass,promoClass,promoClass2,promoClass3)
	local promoLink = createLink(classData,promoClass)
	local function generateGain(class,stat)
		return classData[class][stat] - classData[baseClass][stat]
	end
	local hp = classData[promoClass].hpPromoGain
	local str = classData[promoClass].strPromoGain
	local skl = classData[promoClass].sklPromoGain
	local spd = classData[promoClass].spdPromoGain
	local def = classData[promoClass].defPromoGain
	local res = classData[promoClass].resPromoGain
	local con = generateGain(promoClass,"con")
	local mov = generateGain(promoClass,"mov")
	local movSign = statSign(mov)
	local strLabel = "Str"
	local wlv = ""
	local wlv2 = ""
	local wlv3 = ""
	local skills = ""
	local hasSkills = false
	local wlvTable = {
		[1] = "E",
		[31] = "D",
		[71] = "C",
		[121] = "B",
		[181] = "A",
		[251] = "S"
	}
	local skillLinkTable = {
		["Silencer"] = "[[Lethality|Silencer]]"
	}
	local function getSkillLink(skill)
		if skillLinkTable[skill] then
			return skillLinkTable[skill]
		else
			return "[[" .. skill .. "]]"
		end
	end
	local function generateWlv(class,weapon)
		local change = generateGain(class,weapon)
		local suffix = ""
		if wlvTable[change] then
			suffix = wlvTable[change]
		elseif change < 0 then
			suffix = "−" .. math.abs(change) .. " WEXP"
		else
			suffix = "+" .. change .. " WEXP"
		end
		if change ~= 0 then
			if class == promoClass then
				wlv = wlv .. frame:expandTemplate{ title = weapon .. "GBA" } .. " " .. suffix .. " "
			elseif class == promoClass2 then
				wlv2 = wlv2 .. frame:expandTemplate{ title = weapon .. "GBA" } .. " " .. suffix .. " "
			elseif class == promoClass3 then
				wlv3 = wlv3 .. frame:expandTemplate{ title = weapon .. "GBA" } .. " " .. suffix .. " "
			end
		end
	end
	local physWeapons = { "sword", "lance", "axe", "bow" }
	local magWeapons = { "staff", "anima", "light", "dark" }
	if classData[promoClass].staff == 0 and classData[promoClass].anima == 0 and classData[promoClass].light == 0 and classData[promoClass].dark == 0 then
		for i, weapon in ipairs(physWeapons) do
			generateWlv(promoClass,weapon)
		end
	else
		strLabel = "Mag"
		for i, weapon in ipairs(magWeapons) do
			generateWlv(promoClass,weapon)
		end
	end
	if wlv == "" then
		wlv = frame:expandTemplate{ title = "nwh" }
	end
	local baseSkills = classData[baseClass]["skills"]
	local promoSkills = classData[promoClass]["skills"]
	for i, skill in ipairs(promoSkills) do
		if arrayContains(baseSkills, skill) == false then
			skills = skills .. "+" .. getSkillLink(skill)
			hasSkills = true
		end
	end
	if promoClass2 == nil then
		return frame:expandTemplate{ title = 'PromotionGains', args = { movelabel = "Move", lcklabel = "Luck", strlabel = strLabel, class = promoLink, hp = hp, str = str, skill = skl, spd = spd, def = def, res = res, con = con, move = math.abs(mov), weaponlvl = wlv, movesign = movSign, skills = skills } }
	else
		local promoLink2 = createLink(classData,promoClass2)
		local hp2 = classData[promoClass2].hpPromoGain
		local str2 = classData[promoClass2].strPromoGain
		local skl2 = classData[promoClass2].sklPromoGain
		local spd2 = classData[promoClass2].spdPromoGain
		local def2 = classData[promoClass2].defPromoGain
		local res2 = classData[promoClass2].resPromoGain
		local con2 = generateGain(promoClass2,"con")
		local mov2 = generateGain(promoClass2,"mov")
		local movSign2 = statSign(mov2)
		local skills2 = ""
		local hasSkills2 = false
		local promoSkills2 = classData[promoClass2]["skills"]
		if strLabel == "Str" then
			for i, weapon in ipairs(physWeapons) do
				generateWlv(promoClass2,weapon)
			end
		else
			for i, weapon in ipairs(magWeapons) do
				generateWlv(promoClass2,weapon)
			end
		end
		if wlv2 == "" then
			wlv2 = frame:expandTemplate{ title = "nwh" }
		end
		for i, skill in ipairs(promoSkills2) do
			if arrayContains(baseSkills, skill) == false then
				skills2 = skills2 .. "+" .. getSkillLink(skill)
				hasSkills2 = true
			end
		end
		if promoClass3 == nil then
			if not hasSkills and hasSkills2 then
				skills = frame:expandTemplate{ title = "nwh" }
			end
			if not hasSkills2 and hasSkills then
				skills2 = frame:expandTemplate{ title = "nwh" }
			end
			return frame:expandTemplate{ title = 'PromotionGains', args = { movelabel = "Move", lcklabel = "Luck", strlabel = strLabel, class1 = promoLink, hp1 = hp, str1 = str, skill1 = skl, spd1 = spd, def1 = def, res1 = res, con1 = con, move1 = math.abs(mov), weaponlvl1 = wlv, move1sign = movSign, skills1 = skills, class = promoLink2, hp = hp2, str = str2, skill = skl2, spd = spd2, def = def2, res = res2, con = con2, move = math.abs(mov2), weaponlvl = wlv2, movesign = movSign2, skills = skills2 } }
		else
			local promoLink3 = createLink(classData,promoClass3)
			local hp3 = classData[promoClass3].hpPromoGain
			local str3 = classData[promoClass3].strPromoGain
			local skl3 = classData[promoClass3].sklPromoGain
			local spd3 = classData[promoClass3].spdPromoGain
			local def3 = classData[promoClass3].defPromoGain
			local res3 = classData[promoClass3].resPromoGain
			local con3 = generateGain(promoClass3,"con")
			local mov3 = generateGain(promoClass3,"mov")
			local movSign3 = statSign(mov3)
			local skills3 = ""
			local hasSkills3 = false
			local promoSkills3 = classData[promoClass3]["skills"]
			if strLabel == "Str" then
				for i, weapon in ipairs(physWeapons) do
					generateWlv(promoClass3,weapon)
				end
			else
				for i, weapon in ipairs(magWeapons) do
					generateWlv(promoClass3,weapon)
				end
			end
			if wlv3 == "" then
				wlv3 = frame:expandTemplate{ title = "nwh" }
			end
			for i, skill in ipairs(promoSkills3) do
				if arrayContains(baseSkills, skill) == false then
					skills3 = skills3 .. "+" .. getSkillLink(skill)
					hasSkills3 = true
				end
			end
			if not hasSkills and (hasSkills3 or hasSkills2) then
				skills = frame:expandTemplate{ title = "nwh" }
			end
			if not hasSkills2 and (hasSkills or hasSkills3) then
				skills2 = frame:expandTemplate{ title = "nwh" }
			end
			if not hasSkills3 and (hasSkills or hasSkills2) then
				skills3 = frame:expandTemplate{ title = "nwh" }
			end
			return frame:expandTemplate{ title = 'PromotionGains', args = { movelabel = "Move", lcklabel = "Luck", strlabel = strLabel, class1 = promoLink, hp1 = hp, str1 = str, skill1 = skl, spd1 = spd, def1 = def, res1 = res, con1 = con, move1 = math.abs(mov), weaponlvl1 = wlv, move1sign = movSign, skills1 = skills, class2 = promoLink2, hp2 = hp2, str2 = str2, skill2 = skl2, spd2 = spd2, def2 = def2, res2 = res2, con2 = con2, move2 = math.abs(mov2), weaponlvl2 = wlv2, move2sign = movSign2, skills2 = skills2, class = promoLink3, hp = hp3, str = str3, skill = skl3, spd = spd3, def = def3, res = res3, con = con3, move = math.abs(mov3), weaponlvl = wlv3, movesign = movSign3, skills = skills3 } }
		end
	end
end

local function FE9(frame,classData,baseClass,promoClass)
	local promoLink = createLink(classData,promoClass)
	local function generateGain(stat)
		return classData[promoClass][stat] - classData[baseClass][stat]
	end
	local hp = generateGain("hp")
	local str = generateGain("str")
	local mag = generateGain("mag")
	local skl = generateGain("skl")
	local spd = generateGain("spd")
	local def = generateGain("def")
	local res = generateGain("res")
	local bld = generateGain("bld")
	local mov = generateGain("mov")
	local wlv = ""
	local choiceSymbol = "†"
	local choiceText = "Player must choose one of any of the options with " .. choiceSymbol
	local choiceNote = frame:expandTemplate{ title = "H", args = { choiceSymbol, choiceText } }
	local knifeStaffText = "Player must choose between either Knife skill or E level in staves"
	local knifeStaffNote = frame:expandTemplate{ title = "H", args = { choiceSymbol, knifeStaffText } }
	local skills = ""
	local wlvTable = {
		[1] = "E",
		[31] = "D",
		[71] = "C",
		[121] = "B",
		[181] = "A",
		[251] = "S"
	}
	local skillLinkTable = {
		["Move Again"] = "+[[Move Again]], ", --assumes Shove is going to be after it
		["Critical rate +15"] = "[[Critical rate]] +15" .. frame:expandTemplate{ title = "H", args = { "*", "Not present in the Japanese version" } },
		["Knife"] = frame:expandTemplate{ title = "Item", args = { "9", "Knife", link = "Knife (skill)", image = "knife skill" } },
		["Knife*"] = frame:expandTemplate{ title = "Item", args = { "9", "Knife", link = "Knife (skill)", image = "knife skill" } } .. knifeStaffNote
	}
	local function generateWlv(weapon)
		local suffix = ""
		if classData[promoClass][weapon] ~= "*" then
			local change = generateGain(weapon)
			if change > 0 then
				if classData[baseClass][weapon] ~= 0 then
					suffix = "+" .. prefix .. wlvTable[classData[promoClass][weapon]]
				else
					suffix = wlvTable[classData[promoClass][weapon]]
				end
			end
		else
			local change = "*"
			if weapon ~= "staff" then
				suffix = "E" .. choiceNote
			else
				suffix = "E" .. knifeStaffNote
			end
		end
		if suffix ~= "" then
			wlv = wlv .. frame:expandTemplate{ title = weapon .. "GCN" } .. " " .. suffix .. " "
		end
	end
	local weapons = { "sword", "lance", "axe", "bow", "fire", "thunder", "wind", "staff" }
	for i, weapon in ipairs(weapons) do
		generateWlv(weapon)
	end
	if wlv == "" then
		wlv = frame:expandTemplate{ title = "nwh" }
	end
	local baseSkills = classData[baseClass]["innateSkills"]
	local promoSkills = classData[promoClass]["innateSkills"]
	local skills = ""
	for i, skill in ipairs(promoSkills) do
		if arrayContains(baseSkills, skill) == false then
			if skillLinkTable[skill] then
				skills = skills .. skillLinkTable[skill]
			else
				skills = frame:expandTemplate{ title = "Item", args = { "9", skill } }
			end
		end
	end
	for i, skill in ipairs(baseSkills) do
		if arrayContains(promoSkills, skill) == false and skill ~= "Steal" then
			skills = skills .. "−[[" .. skill .. "]] "
		end
	end
	return frame:expandTemplate{ title = 'PromotionGains', args = { conlabel = "Cn", spdlabel = "Sp", movelabel = "Mv", class = promoLink, hp = hp, str = str, mag = mag, skill = skl, spd = spd, def = def, res = res, con = bld, move = mov, skills = skills, weaponlvl = wlv } }
end

local function DS(frame,game,classData,baseClass,promoClass,promoClass2)
	local promoLink = createLink(classData,promoClass)
	local function generateGain(class,stat)
		return classData[class][stat] - classData[baseClass][stat]
	end
	
	local hp = generateGain(promoClass,"hp")
	local str = generateGain(promoClass,"str")
	local mag = generateGain(promoClass,"mag")
	local skl = generateGain(promoClass,"skl")
	local spd = generateGain(promoClass,"spd")
	local def = generateGain(promoClass,"def")
	local res = generateGain(promoClass,"res")
	local mov = generateGain(promoClass,"mov")
	local hpSign = statSign(hp)
	local strSign = statSign(str)
	local magSign = statSign(mag)
	local sklSign = statSign(skl)
	local spdSign = statSign(spd)
	local defSign = statSign(def)
	local resSign = statSign(res)
	local movSign = statSign(mov)
	local wlvTable = {
		[1] = "E",
		[31] = "D",
		[76] = "C",
		[136] = "B",
		[196] = "A"
	}
	local wlv = ""
	local wlv2 = ""

	local gameNumber = game:sub(3)
	local function generateWlv(class,weapon)
		local change = generateGain(class,weapon)
		local suffix = ""
		if wlvTable[change] then
			suffix = wlvTable[change]
		elseif change < 0 then
			suffix = "−" .. math.abs(change) .. " WEXP"
		else
			suffix = "+" .. change .. " WEXP"
		end
		if change ~= 0 then
			if class == promoClass then
				wlv = wlv .. frame:expandTemplate{ title = weapon .. "DS", args = { gameNumber } } .. " " .. suffix .. " "
			elseif class == promoClass2 then
				wlv2 = wlv2 .. frame:expandTemplate{ title = weapon .. "DS", args = { gameNumber } } .. " " .. suffix .. " "
			end
		end
	end
	local weapons = { "sword", "lance", "axe", "bow", "tome", "staff" }
	for i, weapon in ipairs(weapons) do
		generateWlv(promoClass,weapon)
	end
	if wlv == "" then
		wlv = frame:expandTemplate{ title = "nwh" }
	end
	if promoClass2 == nil then
		return frame:expandTemplate{ title = 'PromotionGains', args = { class = promoLink, hp = math.abs(hp), str = math.abs(str), mag = math.abs(mag), skill = math.abs(skl), spd = math.abs(spd), def = math.abs(def), res = math.abs(res), move = math.abs(mov), weaponlvl = wlv, hpsign = hpSign, strsign = strSign, magsign = magSign, skillsign = sklSign, spdsign = spdSign, defsign = defSign, ressign = resSign, movesign = movSign } }
	else
		local promoLink2 = createLink(classData,promoClass2)
		local hp2 = generateGain(promoClass2,"hp")
		local str2 = generateGain(promoClass2,"str")
		local mag2 = generateGain(promoClass2,"mag")
		local skl2 = generateGain(promoClass2,"skl")
		local spd2 = generateGain(promoClass2,"spd")
		local def2 = generateGain(promoClass2,"def")
		local res2 = generateGain(promoClass2,"res")
		local mov2 = generateGain(promoClass2,"mov")
		local hpSign2 = statSign(hp2)
		local strSign2 = statSign(str2)
		local magSign2 = statSign(mag2)
		local sklSign2 = statSign(skl2)
		local spdSign2 = statSign(spd2)
		local defSign2 = statSign(def2)
		local resSign2 = statSign(res2)
		local movSign2 = statSign(mov2)
		for i, weapon in ipairs(weapons) do
			generateWlv(promoClass2,weapon)
		end
		if wlv2 == "" then
			wlv2 = frame:expandTemplate{ title = "nwh" }
		end
		return frame:expandTemplate{ title = 'PromotionGains', args = { class1 = promoLink, hp1 = math.abs(hp), str1 = math.abs(str), mag1 = math.abs(mag), skill1 = math.abs(skl), spd1 = math.abs(spd), def1 = math.abs(def), res1 = math.abs(res), move1 = math.abs(mov), skills1 = skills, weaponlvl1 = wlv, hp1sign = hpSign, str1sign = strSign, mag1sign = magSign, skill1sign = sklSign, spd1sign = spdSign, def1sign = defSign, res1sign = resSign, move1sign = movSign, class = promoLink2, hp = math.abs(hp2), str = math.abs(str2), mag = math.abs(mag2), skill = math.abs(skl2), spd = math.abs(spd2), def = math.abs(def2), res = math.abs(res2), move = math.abs(mov2), weaponlvl = wlv2, hpsign = hpSign2, strsign = strSign2, magsign = magSign2, skillsign = sklSign2, spdsign = spdSign2, defsign = defSign2, ressign = resSign2, movesign = movSign2 } }
	end
end

local function FE13(frame,classData,baseClass,promoClass,promoClass2)
	local promoLink = createLink(classData,promoClass)
	local function generateGain(class,stat)
		return classData[class][stat] - classData[baseClass][stat]
	end
	local hp = generateGain(promoClass,"hp")
	local str = generateGain(promoClass,"str")
	local mag = generateGain(promoClass,"mag")
	local skl = generateGain(promoClass,"skl")
	local spd = generateGain(promoClass,"spd")
	local def = generateGain(promoClass,"def")
	local res = generateGain(promoClass,"res")
	local mov = generateGain(promoClass,"mov")
	local hpSign = statSign(hp)
	local strSign = statSign(str)
	local magSign = statSign(mag)
	local sklSign = statSign(skl)
	local spdSign = statSign(spd)
	local defSign = statSign(def)
	local resSign = statSign(res)
	local movSign = statSign(mov)
	
	local wlv = ""
	local wlv2 = ""

	local function generateWlv(class,weapon)
		local change = generateGain(class,weapon)
		local suffix = ""
		if change == 1 then
			suffix = "E"
		end
		if change ~= 0 then
			if class == promoClass then
				wlv = wlv .. frame:expandTemplate{ title = weapon .. "13" } .. " " ..  suffix .. " "
			elseif class == promoClass2 then
				wlv2 = wlv2 .. frame:expandTemplate{ title = weapon .. "13" } .. " " .. suffix .. " "
			end
		end
	end
	local weapons = { "sword", "lance", "axe", "bow", "tome", "staff" }
	for i, weapon in ipairs(weapons) do
		generateWlv(promoClass,weapon)
	end
	if wlv == "" then
		wlv = frame:expandTemplate{ title = "nwh" }
	end
	if promoClass2 == nil then
		return frame:expandTemplate{ title = 'PromotionGains', args = { class = promoLink, hp = math.abs(hp), str = math.abs(str), mag = math.abs(mag), skill = math.abs(skl), spd = math.abs(spd), def = math.abs(def), res = math.abs(res), move = math.abs(mov), weaponlvl = wlv, hpsign = hpSign, strsign = strSign, magsign = magSign, skillsign = sklSign, spdSign = spdSign, defsign = defSign, ressign = resSign, movesign = movSign } }
	else
		local promoLink2 = createLink(classData,promoClass2)
		local hp2 = generateGain(promoClass2,"hp")
		local str2 = generateGain(promoClass2,"str")
		local mag2 = generateGain(promoClass2,"mag")
		local skl2 = generateGain(promoClass2,"skl")
		local spd2 = generateGain(promoClass2,"spd")
		local def2 = generateGain(promoClass2,"def")
		local res2 = generateGain(promoClass2,"res")
		local mov2 = generateGain(promoClass2,"mov")
		local hpSign2 = statSign(hp2)
		local strSign2 = statSign(str2)
		local magSign2 = statSign(mag2)
		local sklSign2 = statSign(skl2)
		local spdSign2 = statSign(spd2)
		local defSign2 = statSign(def2)
		local resSign2 = statSign(res2)
		local movSign2 = statSign(mov2)
		for i, weapon in ipairs(weapons) do
			generateWlv(promoClass2,weapon)
		end
		if wlv2 == "" then
			wlv2 = frame:expandTemplate{ title = "nwh" }
		end
		return frame:expandTemplate{ title = 'PromotionGains', args = { class1 = promoLink, hp1 = math.abs(hp), str1 = math.abs(str), mag1 = math.abs(mag), skill1 = math.abs(skl), spd1 = math.abs(spd), def1 = math.abs(def), res1 = math.abs(res), move1 = math.abs(mov), skills1 = skills, weaponlvl1 = wlv, hp1sign = hpSign, str1sign = strSign, mag1sign = magSign, skill1sign = sklSign, spd1sign = spdSign, def1sign = defSign, res1sign = resSign, move1sign = movSign, class = promoLink2, hp = math.abs(hp2), str = math.abs(str2), mag = math.abs(mag2), skill = math.abs(skl2), spd = math.abs(spd2), def = math.abs(def2), res = math.abs(res2), move = math.abs(mov2), weaponlvl = wlv2, hpsign = hpSign2, strsign = strSign2, magsign = magSign2, skillsign = sklSign2, spdsign = spdSign2, defsign = defSign2, ressign = resSign2, movesign = movSign2 } }
	end
end

local function FE14(frame,classData,baseClass,promoClass,promoClass2)
	local promoLink = createLink(classData,promoClass)
	local function generateGain(class,stat)
		return classData[class][stat] - classData[baseClass][stat]
	end
	local hp = generateGain(promoClass,"hp")
	local str = generateGain(promoClass,"str")
	local mag = generateGain(promoClass,"mag")
	local skl = generateGain(promoClass,"skl")
	local spd = generateGain(promoClass,"spd")
	local lck = generateGain(promoClass,"lck")
	local def = generateGain(promoClass,"def")
	local res = generateGain(promoClass,"res")
	local mov = generateGain(promoClass,"mov")
	local hpSign = statSign(hp)
	local strSign = statSign(str)
	local magSign = statSign(mag)
	local sklSign = statSign(skl)
	local spdSign = statSign(spd)
	local lckSign = statSign(lck)
	local defSign = statSign(def)
	local resSign = statSign(res)
	local movSign = statSign(mov)
	
	local wlv = ""
	local wlv2 = ""

	local function generateWlv(class,weapon)
		local change = generateGain(class,weapon)
		local suffix = ""
		if change == 1 then
			suffix = "E"
		end
		if change ~= 0 then
			if class == promoClass then
				wlv = wlv .. frame:expandTemplate{ title = weapon .. "14" } .. " " .. suffix .. " "
			elseif class == promoClass2 then
				wlv2 = wlv2 .. frame:expandTemplate{ title = weapon .. "14" } .. " " .. suffix .. " "
			end
		end
	end
	local weapons = { "sword", "lance", "axe", "dagger", "bow", "tome", "staff", "stone" }
	for i, weapon in ipairs(weapons) do
		generateWlv(promoClass,weapon)
	end
	if wlv == "" then
		wlv = frame:expandTemplate{ title = "nwh" }
	end
	if promoClass2 == nil then
		return frame:expandTemplate{ title = 'PromotionGains', args = { class = promoLink, hp = math.abs(hp), str = math.abs(str), mag = math.abs(mag), skill = math.abs(skl), spd = math.abs(spd), lck = math.abs(lck), def = math.abs(def), res = math.abs(res), move = math.abs(mov), weaponlvl = wlv, hpsign = hpSign, strsign = strSign, magsign = magSign, skillsign = sklSign, spdsign = spdSign, lcksign = lckSign, defsign = defSign, ressign = resSign, movesign = movSign } }
	else
		local promoLink2 = createLink(classData,promoClass2)
		local hp2 = generateGain(promoClass2,"hp")
		local str2 = generateGain(promoClass2,"str")
		local mag2 = generateGain(promoClass2,"mag")
		local skl2 = generateGain(promoClass2,"skl")
		local spd2 = generateGain(promoClass2,"spd")
		local lck2 = generateGain(promoClass2,"lck")
		local def2 = generateGain(promoClass2,"def")
		local res2 = generateGain(promoClass2,"res")
		local mov2 = generateGain(promoClass2,"mov")
		local hpSign2 = statSign(hp2)
		local strSign2 = statSign(str2)
		local magSign2 = statSign(mag2)
		local sklSign2 = statSign(skl2)
		local spdSign2 = statSign(spd2)
		local lckSign2 = statSign(lck2)
		local defSign2 = statSign(def2)
		local resSign2 = statSign(res2)
		local movSign2 = statSign(mov2)
		for i, weapon in ipairs(weapons) do
			generateWlv(promoClass2,weapon)
		end
		if wlv2 == "" then
			wlv2 = frame:expandTemplate{ title = "nwh" }
		end
		return frame:expandTemplate{ title = 'PromotionGains', args = { class1 = promoLink, hp1 = math.abs(hp), str1 = math.abs(str), mag1 = math.abs(mag), skill1 = math.abs(skl), spd1 = math.abs(spd), lck1 = math.abs(lck), def1 = math.abs(def), res1 = math.abs(res), move1 = math.abs(mov), skills1 = skills, weaponlvl1 = wlv, hp1sign = hpSign, str1sign = strSign, mag1sign = magSign, skill1sign = sklSign, spd1sign = spdSign, lck1sign = lckSign, def1sign = defSign, res1sign = resSign, move1sign = movSign, class = promoLink2, hp = math.abs(hp2), str = math.abs(str2), mag = math.abs(mag2), skill = math.abs(skl2), spd = math.abs(spd2), lck = math.abs(lck2), def = math.abs(def2), res = math.abs(res2), move = math.abs(mov2), weaponlvl = wlv2, hpsign = hpSign2, strsign = strSign2, magsign = magSign2, skillsign = sklSign2, spdsign = spdSign2, lcksign = lckSign2, defsign = defSign2, ressign = resSign2, movesign = movSign2 } }
	end
end

local function FE15(frame,classData,baseClass,promoClass,promoClass2,promoClass3,promoClass4)
	return "Echoes placeholder"
end

local function FE17(frame,classData,baseClass,promoClass,promoClass2,innateProficiency)
	local promoLink = createLink(classData,promoClass)
	local function generateGain(class,stat)
		return classData[class][stat] - classData[baseClass][stat]
	end
	local hp = generateGain(promoClass,"hp")
	local str = generateGain(promoClass,"str")
	local mag = generateGain(promoClass,"mag")
	local dex = generateGain(promoClass,"dex")
	local spd = generateGain(promoClass,"spd")
	local lck = generateGain(promoClass,"lck")
	local def = generateGain(promoClass,"def")
	local res = generateGain(promoClass,"res")
	local bld = generateGain(promoClass,"bld")
	local mov = generateGain(promoClass,"mov")
	local hpSign = statSign(hp)
	local strSign = statSign(str)
	local magSign = statSign(mag)
	local dexSign = statSign(dex)
	local spdSign = statSign(spd)
	local defSign = statSign(def)
	local lckSign = statSign(lck)
	local resSign = statSign(res)
	local bldSign = statSign(bld)
	local movSign = statSign(mov)
	local oneChoiceSymbol = "†"
	local oneChoiceText = "Player must choose one of any of the options with " .. oneChoiceSymbol
	local oneChoiceNote = frame:expandTemplate{ title = "H", args = { oneChoiceSymbol, oneChoiceText } }
	local twoChoiceSymbol = "‡"
	local twoChoiceText = "Player must choose two of any of the options with " .. twoChoiceSymbol
	local twoChoiceNote = frame:expandTemplate{ title = "H", args = { twoChoiceSymbol, twoChoiceText } }
	local wlvSuffix = "17"
	local wlvLetterToNumeric = { --Associates weapon level with a number so it can be used in math
		D = 1,
		C = 2,
		B = 3,
		A = 4,
		S = 5,
	}
	local wlvNumericToLetter = { --Used to convert the number back to letter
		[1] = "D",
		[2] = "C",
		[3] = "B",
		[4] = "A",
		[5] = "S"
	}
	local wlv = ""
	local wlv2 = ""
	local weapons = { "sword", "lance", "axe", "bow", "knife", "tome", "staff", "art" } --Intentionally not bothering to check for special or cannonball as those aren't part of classlines
	local function innateIncrease(class,weaponLevel,weapon) --Checks if the weapon is the unit's innate proficiency, and increases weapon level by 1 if class allows it
		if innateProficiency == weapon and arrayContains(classData[class]["increaseIfInnate"],weapon) then
			local increasedValue = wlvLetterToNumeric[weaponLevel] + 1
			wlvSuffix = "17Blue"
			return wlvNumericToLetter[increasedValue]
		else
			wlvSuffix = "17"
			return weaponLevel
		end
	end
	local function generateWlv(class,weapon)
		local shouldPrint = false
		local weaponLevel = classData[class]["weaponLevels"][weapon]
		if weaponLevel then
			if string.sub(weaponLevel,-1) == "*" then --Classes where one weapon can be chosen
				weaponLevel = string.sub(weaponLevel,1,-2)
				weaponLevel = innateIncrease(class,weaponLevel,weapon)
				suffix = weaponLevel .. oneChoiceNote
			elseif string.sub(weaponLevel,-1) == "$" then --Classes where two weapons can be chosen
				weaponLevel = string.sub(weaponLevel,1,-2)
				weaponLevel = innateIncrease(class,weaponLevel,weapon)
				suffix =weaponLevel .. twoChoiceNote
			else
				weaponLevel = innateIncrease(class,weaponLevel,weapon)
				suffix = weaponLevel
			end
			shouldPrint = true
		end
		if shouldPrint then
			if class == promoClass then
				wlv = wlv .. frame:expandTemplate{ title = weapon .. wlvSuffix } .. " " .. suffix .. " "
			elseif class == promoClass2 then
				wlv2 = wlv2 .. frame:expandTemplate{ title = weapon .. wlvSuffix } .. " " .. suffix .. " "
			end
		end
	end
	
	for i, weapon in ipairs(weapons) do
		generateWlv(promoClass,weapon)
	end
	
	if wlv == "" then
		wlv = frame:expandTemplate{ title = "nwh" }
	end
	
	if promoClass2 == nil then
		return frame:expandTemplate{ title = 'PromotionGains', args = { skilllabel = "Dex", conlabel = "Bld", class = promoLink, hp = math.abs(hp), str = math.abs(str), mag = math.abs(mag), skill = math.abs(dex), spd = math.abs(spd), lck = math.abs(lck), def = math.abs(def), res = math.abs(res), con = math.abs(bld), move = math.abs(mov), weaponlvl = wlv, hpsign = hpSign, strsign = strSign, magsign = magSign, skillsign = dexSign, spdsign = spdSign, lcksign = lckSign, defsign = defSign, ressign = resSign, consign = bldSign, movesign = movSign } }
	else
		local promoLink2 = createLink(classData,promoClass2)
		local hp2 = generateGain(promoClass2,"hp")
		local str2 = generateGain(promoClass2,"str")
		local mag2 = generateGain(promoClass2,"mag")
		local dex2 = generateGain(promoClass2,"dex")
		local spd2 = generateGain(promoClass2,"spd")
		local lck2 = generateGain(promoClass2,"lck")
		local def2 = generateGain(promoClass2,"def")
		local res2 = generateGain(promoClass2,"res")
		local bld2 = generateGain(promoClass2,"bld")
		local mov2 = generateGain(promoClass2,"mov")
		local hpSign2 = statSign(hp2)
		local strSign2 = statSign(str2)
		local magSign2 = statSign(mag2)
		local dexSign2 = statSign(dex2)
		local spdSign2 = statSign(spd2)
		local lckSign2 = statSign(lck2)
		local defSign2 = statSign(def2)
		local resSign2 = statSign(res2)
		local bldSign2 = statSign(bld2)
		local movSign2 = statSign(mov2)
		
		for i, weapon in ipairs(weapons) do
			generateWlv(promoClass2,weapon)
		end

		if wlv2 == "" then
			wlv2 = frame:expandTemplate{ title = "nwh" }
		end
		return frame:expandTemplate{ title = 'PromotionGains', args = { conlabel = "Bld", skilllabel = "Dex", class1 = promoLink, hp1 = math.abs(hp), str1 = math.abs(str), mag1 = math.abs(mag), skill1 = math.abs(dex), spd1 = math.abs(spd), lck1 = math.abs(lck), def1 = math.abs(def), res1 = math.abs(res), con1 = math.abs(bld), move1 = math.abs(mov), skills1 = skills, weaponlvl1 = wlv, hp1sign = hpSign, str1sign = strSign, mag1sign = magSign, skill1sign = dexSign, spd1sign = spdSign, lck1sign = lckSign, def1sign = defSign, res1sign = resSign, con1sign = bldSign, move1sign = movSign, class = promoLink2, hp = math.abs(hp2), str = math.abs(str2), mag = math.abs(mag2), skill = math.abs(dex2), spd = math.abs(spd2), lck = math.abs(lck2), def = math.abs(def2), res = math.abs(res2), con = math.abs(bld2), move = math.abs(mov2), weaponlvl = wlv2, hpsign = hpSign2, strsign = strSign2, magsign = magSign2, skillsign = sklSign2, spdsign = spdSign2, lcksign = lckSign2, defsign = defSign2, ressign = resSign2, consign = bldSign2, movesign = movSign2 } }
	end
end

function p.main(frame)
	local args = getArgs(frame)
	local game = args[1]
	local baseClass = args[2]
	local promoClass = args[3]
	local promoClass2 = args[4]
	local holyBlood = promoClass2
	local promoClass3 = args[5]
	local bloodLevel = nil
	local innateProficiency = nil
	if args[5] then
		innateProficiency = string.lower(args[5])
		bloodLevel = innateProficiency
	end
	local promoClass4 = args[6]
	local holyBlood2 = promoClass4
	local bloodLevel2 = nil
	if args[7] then 
		bloodLevel2 = string.lower(args[7])
	end
	local classData = mw.loadData("Module:ClassStats/" .. game)

	--Table for game functions
	local gameFunctions = {
		FE1 = function() return FE1(frame, classData, baseClass, promoClass) end,
		FE2 = function() return FE2(frame, classData, baseClass, promoClass, promoClass2, promoClass3) end,
		FE3 = function() return FE3(frame, classData, baseClass, promoClass) end,
		FE4 = function() return FE4(frame, classData, baseClass, promoClass, holyBlood, bloodLevel, holyBlood2, bloodLevel2) end,
		FE5 = function() return FE5(frame, classData, baseClass, promoClass, promoClass2) end,
		FE6 = function() return FE6(frame, classData, baseClass, promoClass) end,
		FE7 = function() return FE7(frame, classData, baseClass, promoClass) end,
		FE8 = function() return FE8(frame, classData, baseClass, promoClass, promoClass2, promoClass3) end,
		FE9 = function() return FE9(frame, classData, baseClass, promoClass) end,
		FE11 = function() return DS(frame, game, classData, baseClass, promoClass, promoClass2) end,
		FE12 = function() return DS(frame, game, classData, baseClass, promoClass, promoClass2) end,
		FE13 = function() return FE13(frame, classData, baseClass, promoClass, promoClass2) end,
		FE14 = function() return FE14(frame, classData, baseClass, promoClass, promoClass2) end,
		FE15 = function() return FE15(frame, classData, baseClass, promoClass, promoClass2, promoClass3, promoClass4) end,
		FE17 = function() return FE17(frame, classData, baseClass, promoClass, promoClass2, innateProficiency) end
	}
	--Call the correct function based on game
	if gameFunctions[game] then
		return gameFunctions[game]()
	end
end

return p