Documentation for this module may be created at Module:ClassInfo/doc

-- This module is invoked by:
-- Template:Classstat
-- Template:ClassPromotions
-- Template:ClassSkills

local getArgs  = require('Module:Arguments').getArgs
local getColor = require('Module:Color').colorByGame
local common   = require('Module:Common')
local stats    = require('Module:CharStat/data').stats
local p = {}
local games = {
    { 'fe1', '[[Fire Emblem: Shadow Dragon and the Blade of Light|FE1]]' },
    { 'fe2', '[[Fire Emblem Gaiden|FE2]]' },
    { 'fe3', '[[Fire Emblem: Mystery of the Emblem|FE3]]' },
    { 'fe4', '[[Fire Emblem: Genealogy of the Holy War|FE4]]' },
    { 'fe5', '[[Fire Emblem: Thracia 776|FE5]]' },
    { 'ts' , '[[TearRing Saga: Utna Heroes Saga|TS]]' },
    { 'fe6', '[[Fire Emblem: The Binding Blade|FE6]]' },
    { 'fe7', '[[Fire Emblem: The Blazing Blade|FE7]]' },
    { 'fe8', '[[Fire Emblem: The Sacred Stones|FE8]]' },
    { 'fe9', '[[Fire Emblem: Path of Radiance|FE9]]' },
    { 'fe10','[[Fire Emblem: Radiant Dawn|FE10]]' },
    { 'fe11','[[Fire Emblem: Shadow Dragon|FE11]]' },
    { 'fe12','[[Fire Emblem: New Mystery of the Emblem|FE12]]' },
    { 'fe13','[[Fire Emblem Awakening|FE13]]' },
    { 'fe14','[[Fire Emblem Fates|FE14]]' },
    { 'fe15','[[Fire Emblem Echoes: Shadows of Valentia|FE15]]' },
    { 'fe16','[[Fire Emblem: Three Houses|FE16]]' },
    { 'few', '[[Fire Emblem Warriors|FEW]]' } 
}

function p.main(frame)
	local args = getArgs(frame)
	return p._main(args)
end

function p._main(args)
    local ext = 5      -- number of extended parameters
    local tbl = mw.html.create('table')
        :addClass('wikitable')
        :css('text-align', args.type == 'stat' and 'center' or '')
    local head = tbl:tag('tr')
          head:tag('th')

    -- COLUMNS
    if args.type == 'stat' then
        head:tag('th'):wikitext(stats[2][3])  -- hp
        head:tag('th'):wikitext(stats[4][3])  -- str
        head:tag('th'):wikitext(stats[5][3])  -- mag
        head:tag('th'):wikitext(stats[9][3])  -- skl
        head:tag('th'):wikitext(stats[12][3]) -- spd
        head:tag('th'):wikitext(stats[14][3]) -- lck
        head:tag('th'):wikitext(stats[15][3]) -- def
        head:tag('th'):wikitext(stats[16][3]) -- res
        head:tag('th'):wikitext(stats[21][3]) -- mov
        head:tag('th'):wikitext(stats[17][3]) -- con
        head:tag('th'):wikitext(stats[19][3]) -- wt
        head:tag('th'):wikitext(stats[20][3]) -- wlv
    elseif args.type == 'promotion' then
        head:tag('th'):wikitext('Base Class')
        head:tag('th'):wikitext('Promotion Method'):css('width', '50%')
        head:tag('th'):wikitext('Promoted Class')
    else
        head:tag('th'):wikitext('Skill')
        head:tag('th'):wikitext('Requirements')
    end
    
    -- ROWS
    for i = 1, #games do
        local k = games[i][1]
        local v = games[i][2]
        function setRow(j)
            local key = j == nil and k or k..'-'..j
            if args[key] ~= nil then
                cols = mw.text.split(args[key], '*')
                local val = j == nil and v or v..' <small>'..cols[1]..'</small>'
                row = tbl:tag('tr')
                row :tag('th'):css('background', getColor[k]..' !important')
                    :addClass(common.colorLinks(k))
                    :wikitext(val)
                for i = j == nil and 1 or 2, #cols do
                    row:tag('td'):wikitext(cols[i])
                end
            end
        end
        setRow()
        for j = 1, ext do setRow(j) end
    end

    return tbl
end

return p
--[[Category:Modules]]
Community content is available under CC-BY-SA unless otherwise noted.