Module:Motion value table
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Motion value table/doc
local m_args = require('Module:ArgsLib')
local cfg = mw.loadData('Module:Motion_value_table/config')
--------------------------------------------
-- Builder functions
--------------------------------------------
local b = {}
function b.build_sequence_row(container, tbl, label)
local colspan = (#tbl > 1) and 1 or 2
local tr = container:tag('tr'):tag('th'):attr('colspan', colspan):attr('rowspan', #tbl):wikitext(label):done()
if (#tbl > 1) then
tr
:tag('th'):wikitext('1'):done()
:tag('td'):wikitext(tbl[1]):done()
:done()
for i = 2, #tbl do
container
:tag('tr')
:tag('th'):wikitext(i):done()
:tag('td'):wikitext(tbl[i]):done()
:done()
end
else
tr:tag('td'):wikitext(tbl[1]):done()
end
end
--------------------------------------------
-- Public
--------------------------------------------
local p = {}
function p.main(frame)
local t_args = frame:getParent().args
return p._main(t_args)
end
function p._main(t_args)
local standard_attacks = m_args.merge_numbered_args(t_args, 'standard')
local charged_attacks = m_args.merge_numbered_args(t_args, 'charged')
local sprint_attacks = m_args.merge_numbered_args(t_args, 'sprint')
-- Create the table
local attack_string_colspan = (#standard_attacks > 1 or #charged_attacks > 1) and 2 or 1
local tb = mw.html.create('table'):addClass('wikitable'):attr('style', 'text-align:center')
tb
:tag('tr')
:tag('th'):attr('colspan', attack_string_colspan):wikitext(cfg.i18n.terms.attack_string):done()
:tag('th'):wikitext(cfg.i18n.terms.value):done()
:done()
if (standard_attacks) then b.build_sequence_row(tb, standard_attacks, cfg.i18n.terms.standard_attack) end
if (charged_attacks) then b.build_sequence_row(tb, charged_attacks, cfg.i18n.terms.charged_attack) end
if (sprint_attacks) then b.build_sequence_row(tb, sprint_attacks, cfg.i18n.terms.sprint) end
-- Standard neutral evade
if (t_args.standard_neutral) then
tb
:tag('tr')
:tag('th'):attr('colspan', '2'):wikitext(cfg.i18n.terms.standard_attack)
:tag('br'):done()
:tag('sup'):wikitext(string.format('(%s)', cfg.i18n.terms.neutral_evade)):done()
:done()
:tag('td'):wikitext(t_args.standard_neutral):done()
:done()
end
-- Charged neutral evade
if (t_args.charged_neutral) then
tb
:tag('tr')
:tag('th'):attr('colspan', '2'):wikitext(cfg.i18n.terms.charged_attack)
:tag('br'):done()
:tag('sup'):wikitext(string.format('(%s)', cfg.i18n.terms.neutral_evade)):done()
:done()
:tag('td'):wikitext(t_args.charged_neutral):done()
:done()
end
-- Projectile
if (t_args.projectile) then
tb
:tag('tr')
:tag('th'):attr('colspan', '2'):wikitext(cfg.i18n.terms.projectile):done()
:tag('td'):wikitext(t_args.projectile)
end
return tb
end
return p