Fandom

Fire Emblem Wiki

Module:Sandbox

5,334pages on
this wiki
Add New Page
Talk0
--This module is invoked by Template:WeaponStat
 
local wps = {}
local getArgs = require('Module:Arguments').getArgs
local getColor = require('Module:Color').colorByGame
local common = require('Module:Common')
local cols = {
    --Weapon stats
    wlv =   '\n![[Weapon Level|WLv]]',
    rank =  '\n![[Weapon Rank|Rank]]',
    uses =  '\n![[Usage|Uses]]',
    whp =   '\n![[Usage|WHp]]',
    mt =    '\n![[Might|Mt]]',
    power = '\n![[Might|Power]]',
    hit =   '\n![[Hit%|Hit]]',
    crt =   '\n![[Critical Rate|Crt]]',
    rng =   '\n![[Range|Rng]]',
    wt =    '\n![[Weight (weapon stat)|Wt]]',
    wex =   '\n![[Weapon Experience|WEx]]',
    worth = '\n![[Cost|Worth]]',
    avoid = '\n![[Evade|Avoid]]',
}
local res = {
    'sword', 'lance', 'axe', 'bow',
    'fire', 'ice', 'thunder', 'wind', 'light', 'dark'
}
 
function wps.main(frame)
	local args = getArgs(frame)
	if(pcall(wps._main, args)) then
        return wps._main(args)
    else
        return '<span style="color:red">Missing \'game\' parameter. See [[Template:WeaponStat]] for more info.</span>'
    end
end
 
function wps._main(args)
    local game = string.lower(args.game)
    local class = common.colorLinks(game)
    local color = getColor[game]
    local out, columns, n_cols,
          top_colspan, bot_colspan,
          maxiter, maxcnt
 
    -- HEADERS
    if(string.match(game, 'fe')) then
        --------------------- Fire Emblem games --------------------------
        i = tonumber(string.sub(game, 3))   -- FE installment
        if (i==1 or i==3) then
            n_cols = 8
            columns =
                cols.wlv..
                cols.uses..
                cols.mt..
                cols.hit..
                cols.crt..
                cols.rng..
                cols.wt..
                cols.worth
        elseif (i == 2) then
            n_cols = 5
            columns =
                cols.mt..
                cols.hit..
                cols.crt..
                cols.rng..
                cols.wt
        elseif (i == 4) then
            n_cols = 7
            columns =
                cols.rank..
                cols.uses..
                cols.mt..
                cols.hit..
                cols.rng..
                cols.wt..
                cols.worth
        elseif (i >= 5 and i <= 11) then
            n_cols = 9
            columns =
                cols.rank..
                cols.uses..
                cols.mt..
                cols.hit..
                cols.crt..
                cols.rng..
                cols.wt..
                cols.wex..
                cols.worth
        elseif (i == 12 or i == 13) then
            n_cols = 8
            columns =
                cols.rank..
                cols.uses..
                cols.mt..
                cols.hit..
                cols.crt..
                cols.rng..
                cols.wex..
                cols.worth
        else
            n_cols = 9
            columns =
                cols.rank..
                cols.uses..
                cols.mt..
                cols.hit..
                cols.crt..
                cols.avoid..
                cols.rng..
                cols.wex..
                cols.worth
        end
    elseif( game == 'ts') then
        ------------------------- TearRing Saga  ---------------------------
        n_cols = 8
        columns =
            cols.wlv..
            cols.whp..
            cols.power..
            cols.hit..
            cols.crt..
            cols.rng..
            cols.wt..
            cols.worth
    elseif( game == 'tms') then
        ---------------------- Tokyo Mirage Sessions -----------------------
        n_cols = 1 + #res
        columns = cols.power
        for i = 1, #res do
            columns = columns..'\n!'..
            mw.getCurrentFrame():expandTemplate{
                title = 'Weapon',
                args = { 'tms', res[i] }
            }
        end
 
    end
 
    -- DATA
    maxiter = n_cols + 2
    top_colspan = math.floor(n_cols / 2)
    bot_colspan = n_cols
    columns = columns..'\n|-class="s-cells"'
    for cnt = 3, maxiter do
        columns = columns..'\n| '..common.setDefault(args[tonumber(cnt)])
        maxcnt = cnt + 1
    end
 
 
    -- OUTPUT
    out =
        '{| class="statbox" style="min-width:30%; margin-bottom: 15px; max-width:75%; text-align:center"'..
        '\n|-bgcolor='..color..' class='..class..
        '\n!colspan='.. top_colspan + 1 ..'|Name'..
        '\n!colspan='.. top_colspan     ..'|[[Weapon Type|Type]]'..
        '\n|-'..
        '\n|colspan='.. top_colspan + 1 ..'|'..common.setDefault(args[1])..
        '\n|colspan='.. top_colspan     ..'|'..common.setDefault(args[2])..
        '\n|-bgcolor='..color..' class='..class..
 
        columns..
 
        '\n|-'
 
 
    if( game == 'tms') then
        bot_colspan = math.floor(n_cols / 3)
        bot_colspan1 = bot_colspan + 2
        out = out..
            '\n!bgcolor='..color..' class='..class..' colspan='..bot_colspan..'|Effect'..
            '\n!bgcolor='..color..' class='..class..' colspan='..bot_colspan..'|Skills'..
            '\n!bgcolor='..color..' class='..class..' colspan='..bot_colspan1..'|Performa'..
            '\n|-'..
            '\n|style="text-align: initial" colspan='..bot_colspan..'|'..common.setDefault(args[maxcnt])..
            '\n|style="text-align: initial" colspan='..bot_colspan..'|'..common.setDefault(args[maxcnt + 1])..
            '\n|style="text-align: initial" colspan='..bot_colspan1..'|'..common.setDefault(args[maxcnt + 2])
    else
        out = out..
        '\n!bgcolor='..color..' class='..class..' colspan='..bot_colspan..'|Effect'..
        '\n|-'..
        '\n|colspan='..bot_colspan..'|'..common.setDefault(args[maxcnt])
    end
 
    return out..'\n|}'
end
 
return wps
--[[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