Fandom

Fire Emblem Wiki

Module:PromotionGains

5,334pages on
this wiki
Add New Page
Talk0
--This module is invoked by Template:PromotionGains
 
local p = {}
local getArgs = require('Module:Arguments').getArgs
local getColor = require('Module:Color').colorByGame
local common = require('Module:Common')
local cols = {
    -- character stats
    {'lv',      '\n![[Level|Lv]]'},
    {'hp',      '\n![[HP]]'},
    {'ep',      '\n![[EP]]'},
    {'str',     '\n![[Strength|Str]]'},
    {'mag',     '\n![[Magic (stat)|Mag]]'},
    {'skl',     '\n![[Skill (stat)|Skl]]'},
    {'spd',     '\n![[Speed (stat)|Spd]]'},
        {'agl', '\n![[Speed (stat)|Agl]]'},
    {'def',     '\n![[Defense|Def]]'},
    {'res',     '\n![[Resistance|Res]]'},
    {'con',     '\n![[Constitution|Con]]'},
        {'bld', '\n![[Constitution|Bld]]'},
    {'wlv',     '\n![[Weapon Level|Wlv]]'},
    {'mov',     '\n![[Movement|Mov]]'},
}
 
function p.main(frame)
    args = getArgs(frame)
    if(pcall(p._main, args)) then
        return p._main(args)
    else
	    return '<span style="color: red">Missing \'game\' parameter. See [[Template:PromotionGains]] for more info.</span>'
    end
end
 
function p._main(args)
    local out, class, colspan, colspan1, colspan2
    local nCols = 0     --number of columns
    local columns = ''
    local game = string.lower(args.game)
    local color = getColor[game]
 
    class = common.colorLinks(game)
 
    -- Header columns iteration
    for i = 1, #cols do
        if(args[cols[i][1]] ~= nil) then
            columns = columns..cols[i][2]
            nCols = nCols + 1
        end
    end
 
    -- Data columns iteration
    columns = columns..'\n|-class="s-cells"'
    for i = 1, #cols do
        if(args[cols[i][1]] ~= nil) then columns = columns..'\n| '..args[cols[i][1]] end
    end
 
    -- Assigning colspan based on number of columns
    if (nCols % 2 == 0) then
        colspan2 = nCols / 2
        colspan1 = colspan2
    else
        colspan2 = math.ceil(nCols / 2)
        colspan1 = colspan2 - 1
    end
 
    -- Skills and weapon ranks
    colspan = colspan1 + colspan2
    if(args.skills ~= nil or args.wrank ~= nil) then columns=columns..'\n|-bgcolor='..color..' class='..class end
    if(args.skills ~= nil and args.wrank ~= nil) then
        columns=columns..
        '\n!colspan='..colspan1..'|[[Skills]]'..
        '\n!colspan='..colspan2..'|[[Weapon Rank]]s'..
        '\n|-'..
        '\n|colspan='..colspan1..'| '..args.skills..
        '\n|colspan='..colspan2..'| '..args.wrank
    elseif(args.skills ~= nil and args.wrank == nil) then
        columns=columns..
        '\n!colspan='..colspan..'|[[Skills]]'..
        '\n|-'..
        '\n|colspan='..colspan..'| '..args.skills
    elseif(args.skills == nil and args.wrank ~= nil) then
        columns=columns..
        '\n!colspan='..colspan..'|[[Weapon Rank]]s'..
        '\n|-'..
        '\n|colspan='..colspan..'| '..args.wrank
    end
 
    --Final output
    out =
    '{| class="statbox" style="text-align: center"'..
    '\n|-bgcolor='..color..' class='..class
    if(args.req == nil or args.req == '-') then
        out = out..
        '\n!colspan='..colspan..'|Promoted Class'..
        '\n|-'..
        '\n|colspan='..colspan..'| '..common.setDefault(args.class)
    else
        out = out..
        '\n!colspan='..colspan1..'|Item Required'..
        '\n!colspan='..colspan2..'|Promoted Class'..
        '\n|-'..
        '\n|colspan='..colspan1..'| '..common.setDefault(args.req)..
        '\n|colspan='..colspan2..'| '..common.setDefault(args.class)
    end
    out = out..'\n|-bgcolor='..color..' class='..class..columns..'\n|}'
 
    return out
end
 
return p
--[[Category:Modules]]

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.

Also on Fandom

Random Wiki