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

Social media: If you would like, please join our Discord server, and/or follow us on X (Twitter), Bluesky, or Tumblr!

Module:ReclassGrowths

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

Syntax

Normal

Does not currently support avatar asset/flaws.

{{#invoke:ReclassGrowths|main|FE<number>|Unit name|Class name|Class name 2 (optional)|Class name 3 (optional)|Class name 4 (optional)}}

Classes 2 through 4 are for if another class has the same exact growth rates.

Children

Does not currently support avatar asset/flaws or "third-generation" Morgan/Kana.

For child growths in Awakening and Fates:

{{#invoke:ReclassGrowths|main|FE<number>c|Unit name|Non-fixed parent name|Class name|Class name 2 (optional)|Class name 3 (optional)|Class name 4 (optional)}}

local getArgs = require('Module:Arguments').getArgs
local p = {}
local function createLink(classData,class)
	return "[[" .. classData[class].article .. "|" .. classData[class].name .. "]]"
end

local function DS(frame,charData,classData,character,class1,class2,class3,class4)
	local classLink = createLink(classData,class1)
	if class2 then
		classLink = classLink .. "/" .. createLink(classData,class2) 
	end
	if class3 then
		classLink = classLink .. "/" .. createLink(classData,class3) 
	end
	if class4 then
		classLink = classLink .. "/" .. createLink(classData,class4) 
	end
	local function calculateGrowth(stat)
		local output = charData[character][stat] + classData[class1][stat.."Growth"]
		if output < 0 then
			output = 0
		end
		return output .. "%"
	end
	local hp = calculateGrowth("hp")
	local str = calculateGrowth("str")
	local mag = calculateGrowth("mag")
	local skl = calculateGrowth("skl")
	local spd = calculateGrowth("spd")
	local lck = calculateGrowth("lck")
	local def = calculateGrowth("def")
	local res = calculateGrowth("res")
	return frame:expandTemplate{ title = 'GrowthRates', args = { class = classLink, hp = hp, str = str, mag = mag, skill = skl, spd = spd, luck = lck, def = def, res = res } }
end

function childFE13(frame,charData,classData,character,parent,class1,class2,class3,class4)
	local classLink = createLink(classData,class1)
	if class2 then
		classLink = classLink .. "/" .. createLink(classData,class2) 
	end
	if class3 then
		classLink = classLink .. "/" .. createLink(classData,class3) 
	end
	if class4 then
		classLink = classLink .. "/" .. createLink(classData,class4) 
	end
	local nonVariableParent = ""
	local parentage = {
		Lucina = "Chrom",
		Morgan = "Robin",
		Owain = "Lissa",
		Kjelle = "Sully",
		Laurent = "Miriel",
		Cynthia = "Sumia",
		Brady = "Maribelle",
		Yarne = "Panne",
		Severa = "Cordelia",
		Nah = "Nowi",
		Noire = "Tharja",
		Inigo = "Olivia",
		Gerome = "Cherche"
	}
	nonVariableParent = parentage[character] 
	local function calculateGrowth(stat)
		local output = math.floor((charData[character][stat] + charData[parent][stat] + charData[nonVariableParent][stat])/3) + classData[class1][stat.."Growth"]
		if output < 0 then
			output = 0
		end
		return output .. "%"
	end
	
	local hp = calculateGrowth("hp")
	local str = calculateGrowth("str")
	local mag = calculateGrowth("mag")
	local skl = calculateGrowth("skl")
	local spd = calculateGrowth("spd")
	local lck = calculateGrowth("lck")
	local def = calculateGrowth("def")
	local res = calculateGrowth("res")
	
	return frame:expandTemplate{ title = 'GrowthRates', args = { class = classLink, hp = hp, str = str, mag = mag, skill = skl, spd = spd, luck = lck, def = def, res = res } }
end

function childFE14(frame,charData,classData,character,parent,class1,class2,class3,class4)
	local classLink = createLink(classData,class1)
	if class2 then
		classLink = classLink .. "/" .. createLink(classData,class2) 
	end
	if class3 then
		classLink = classLink .. "/" .. createLink(classData,class3) 
	end
	if class4 then
		classLink = classLink .. "/" .. createLink(classData,class4) 
	end
	
	local function calculateGrowth(stat)
		local output = math.floor((charData[character][stat] + charData[parent][stat])/2) + classData[class1][stat.."Growth"]
		if output < 0 then
			output = 0
		end
		return output .. "%"
	end
	
	local hp = calculateGrowth("hp")
	local str = calculateGrowth("str")
	local mag = calculateGrowth("mag")
	local skl = calculateGrowth("skl")
	local spd = calculateGrowth("spd")
	local lck = calculateGrowth("lck")
	local def = calculateGrowth("def")
	local res = calculateGrowth("res")
	
	return frame:expandTemplate{ title = 'GrowthRates', args = { class = classLink, hp = hp, str = str, mag = mag, skill = skl, spd = spd, luck = lck, def = def, res = res } }
end

local function FE15(frame,charData,classData,character,class1,class2,class3,class4)
	local classLink = createLink(classData,class1)
	if class2 then
		classLink = classLink .. "/" .. createLink(classData,class2) 
	end
	if class3 then
		classLink = classLink .. "/" .. createLink(classData,class3) 
	end
	if class4 then
		classLink = classLink .. "/" .. createLink(classData,class4) 
	end
	local function calculateGrowth(stat)
		local output = charData[character][stat] + classData[class1][stat.."Growth"]
		if output < 0 then
			output = 0
		end
		return output .. "%"
	end
	local hp = calculateGrowth("hp")
	local atk = calculateGrowth("atk")
	local skl = calculateGrowth("skl")
	local spd = calculateGrowth("spd")
	local lck = calculateGrowth("lck")
	local def = calculateGrowth("def")
	local res = calculateGrowth("res")
	return frame:expandTemplate{ title = 'GrowthRates', args = { class = classLink, hp = hp, str = atk, skill = skl, spd = spd, luck = lck, def = def, res = res, strlabel = "Atk" } }
end

local function FE16(frame,charData,classData,character,class1,class2,class3,class4)
	local classLink = createLink(classData,class1)
	if class2 then
		classLink = classLink .. "/" .. createLink(classData,class2) 
	end
	if class3 then
		classLink = classLink .. "/" .. createLink(classData,class3) 
	end
	if class4 then
		classLink = classLink .. "/" .. createLink(classData,class4) 
	end
	local function calculateGrowth(stat)
		local output = charData[character][stat] + classData[class1][stat.."Growth"]
		if output < 0 then
			output = 0
		end
		return output .. "%"
	end
	
	local hp = calculateGrowth("hp")
	local str = calculateGrowth("str")
	local mag = calculateGrowth("mag")
	local dex = calculateGrowth("dex")
	local spd = calculateGrowth("spd")
	local lck = calculateGrowth("lck")
	local def = calculateGrowth("def")
	local res = calculateGrowth("res")
	local cha = calculateGrowth("cha")
	
	return frame:expandTemplate{ title = 'GrowthRates', args = { class = classLink, hp = hp, str = str, mag = mag, skill = dex, spd = spd, luck = lck, def = def, res = res, cha = cha, skilllabel = "Dex" } }
end

local function FE17(frame,charData,classData,character,class1,class2,class3,class4)
	local classLink = createLink(classData,class1)
	if class2 then
		classLink = classLink .. "/" .. createLink(classData,class2) 
	end
	if class3 then
		classLink = classLink .. "/" .. createLink(classData,class3) 
	end
	if class4 then
		classLink = classLink .. "/" .. createLink(classData,class4) 
	end
	local function calculateGrowth(stat)
		local output = 0
		if character ~= "Jean" then
			output = charData[character][stat] + classData[class1][stat.."Growth"]
		else --Expertise
			output = charData[character][stat] + classData[class1][stat.."Growth"] * 2
		end
		if output < 0 then
			output = 0
		end
		return output .. "%"
	end
	
	local hp = calculateGrowth("hp")
	local str = calculateGrowth("str")
	local mag = calculateGrowth("mag")
	local dex = calculateGrowth("dex")
	local spd = calculateGrowth("spd")
	local lck = calculateGrowth("lck")
	local def = calculateGrowth("def")
	local res = calculateGrowth("res")
	local bld = calculateGrowth("bld")
	return frame:expandTemplate{ title = 'GrowthRates', args = { class = classLink, hp = hp, str = str, mag = mag, skill = dex, spd = spd, luck = lck, def = def, res = res, bld = bld, skilllabel = "Dex" } }
end

function p.main(frame)
	local args = getArgs(frame)
	local game = args[1]
	if game == "FE13c" or game == "FE14c" then
		local character = args[2]
		game = game:sub(1,-2) --Remove c
		local charData = require("Module:CharGrowths/" .. game)
		local classData = require("Module:ClassStats/" .. game)
		local parent = args[3]
		local class1 = args[4]
		local class2 = args[5]
		local class3 = args[6]
		local class4 = args[7]
		local gameFunctions = {
		    FE13 = childFE13,
		    FE14 = childFE14
		}
		return gameFunctions[game](frame,charData,classData,character,parent,class1,class2,class3,class4)
	else
		local character = args[2]
		local class1 = args[3]
		local class2 = args[4]
		local class3 = args[5]
		local charData = require("Module:CharGrowths/" .. game)
		local classData = require("Module:ClassStats/" .. game)
		
		--Table for game functions
		local gameFunctions = {
		    FE11 = DS,
		    FE12 = DS,
		    FE13 = DS,
		    FE14 = DS,
		    FE15 = FE15,
		    FE16 = FE16,
		    FE17 = FE17
		}
		--Call the correct function based on game
		if gameFunctions[game] then
		    return gameFunctions[game](frame, charData, classData, character, class1, class2, class3, class4)
		end
	end
end

return p