Documentation for this module may be created at Module:WeaponStat/doc
--This module is invoked by Template:WeaponStat
--<nowiki>
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!class="data wlv" |[[Weapon Level|WLv]]',
rank ='\n!class="data rank"|[[Weapon Level|Rank]]',
uses ='\n!class="data uses"|[[Usage|Uses]]',
whp ='\n!class="data whp"|[[Usage|WHp]]',
mt ='\n!class="data mt" |[[Might|Mt]]',
power ='\n!class="data power"|[[Might|Power]]',
hit ='\n!class="data hit"|[[Hit%|Hit]]',
crt ='\n!class="data crt"|[[Critical Rate|Crt]]',
rng ='\n!class="data rng"|[[Range|Rng]]',
wt ='\n!class="data wt" |[[Weight (weapon stat)|Wt]]',
wex ='\n!class="data wex"|[[Weapon Experience|WEx]]',
xp ='\n!class="data xp" |[[Experience|EXP]]',
worth ='\n!class="data worth"|[[Cost|Worth]]',
avo ='\n!class="data avo"|[[Evade|Avo]]',
sp ='\n!class="data sp" |[[SP]]',
rarity ='\n!class="data rarity"|[[Rarity]]',
slots ='\n!class="data slots" |Slots',
seventh='\n!class="data seventh"|Seventh Slot'
}
local res = {
'sword', 'lance', 'axe', 'bow',
'fire', 'ice', 'thunder', 'wind', 'light', 'dark'
}
function returnErr(errType)
msg = '[[Category:Pages with script errors]]<span style="color:red">'..errType..
' \'game\' parameter. See [[Template:WeaponStat]] for more info.</span>'
if (errType == 'Missing') then
return msg
else
do return msg end
end
end
function wps.main(frame)
local args = getArgs(frame)
if(pcall(wps._main, args)) then
return wps._main(args)
else
return returnErr('Missing')
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 --------------------------
s = string.sub(game, 3) -- FE spin-offs
i = tonumber(s) -- FE installment
if (i == nil) then
if (s == 'h') then -- FEH
n_cols = 4
columns =
cols.mt..
cols.rng..
cols.sp..
cols.rarity
elseif (s == 'w') then -- FEW
n_cols = 5
columns =
cols.rank..
cols.mt..
cols.worth..
cols.slots..
cols.seventh
else
return returnErr('Unrecognized')
end
else
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 or i == 15) 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
elseif (i == 14) then
n_cols = 9
columns =
cols.rank..
cols.uses..
cols.mt..
cols.hit..
cols.crt..
cols.avo..
cols.rng..
cols.wex..
cols.worth
elseif (i == 16) then
n_cols = 9
columns =
cols.rank..
cols.uses..
cols.mt..
cols.hit..
cols.crt..
cols.rng..
cols.wex..
cols.wt..
cols.worth
else
n_cols = 11
columns =
cols.rank..
cols.rng..
cols.uses..
cols.wt..
cols.mt..
cols.hit..
cols.avo..
cols.crt..
cols.wex..
cols.xp..
cols.worth
end
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 #FE
n_cols = 1 + #res
columns = cols.power
for i = 1, #res do
columns = columns..'\n!class="data '..res[i]..'"|'..
mw.getCurrentFrame():expandTemplate{
title = 'Weapon',
args = { 'tms', res[i] }
}
end
else
return returnErr('Unrecognized')
end
-- DATA
maxiter = n_cols + 2
top_colspan = math.floor(n_cols / 2)
top_colspan1 = n_cols % 2 ~= 0 and top_colspan + 1 or top_colspan
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"'..
'\n|-bgcolor='..color..' class='..class..
'\n!class="data name" colspan='.. top_colspan1 ..'|Name'..
'\n!class="data type" colspan='.. top_colspan ..'|[[Weapon Type|Type]]'..
'\n|-'..
'\n|colspan='.. top_colspan1 ..'|\n'..common.setDefault(args[1])..
'\n|colspan='.. top_colspan ..'|\n'..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="data effect '..class..'" colspan='..bot_colspan..'|Effect'..
'\n!bgcolor='..color..' class="data skills '..class..'" colspan='..bot_colspan..'|Skills'..
'\n!bgcolor='..color..' class="data perfoma '..class..'" colspan='..bot_colspan1..'|Performa Required'..
'\n|-'..
'\n|colspan='..bot_colspan..'|\n'..common.setDefault(args[maxcnt])..
'\n|colspan='..bot_colspan..'|\n'..common.setDefault(args[maxcnt + 1])..
'\n|colspan='..bot_colspan1..'|\n'..common.setDefault(args[maxcnt + 2])
else
out = out..
'\n!bgcolor='..color..' class="data effect '..class..'" colspan='..bot_colspan..'|Effect'..
'\n|-'..
'\n|colspan='..bot_colspan..'|\n'..common.setDefault(args[maxcnt], '-')
end
-- Weapon Evolution
if common.isnotNil(args.evolve) then
out = out..
'\n|-'..
'\n!bgcolor='..color..' class='..class..' colspan='..bot_colspan..'|Evolution'..
'\n|-'..
'\n!class="data weapon" colspan='..top_colspan..'|Weapon'..
'\n!class="data cost" colspan='..top_colspan..'|Cost'..
'\n|-'..
'\n|colspan='..top_colspan..'|\n'..args.evolve
cost = mw.text.split(common.setDefault(args.cost), ',')
out = out..
'\n|colspan='..top_colspan..'|\n'..
cost[1]..' [[SP]],'..
cost[2]..' [[File:Arena Medal.png|20px|link=Arena Medal]],'..
cost[3]..(tonumber(cost[3]) >= 150
and ' [[File:Divine Dew.png|20px|link=Divine Dew]]'
or '[[File:Refining Stone.png|20px|link=Refining Stone]]')
end
return out..'\n|}'
end
return wps
--</nowiki>
--[[Category:Modules]]
Community content is available under CC-BY-SA unless otherwise noted.