Content added Content deleted
m (deal with rarity later) |
mNo edit summary |
||
Line 62: | Line 62: | ||
if untrained and rarity then |
if untrained and rarity then |
||
local images = string.format( |
local images = string.format( |
||
' |
'Untrained=[[File:%s|%dpx]]', |
||
untrained, |
untrained, |
||
image_size) |
image_size) |
||
Line 68: | Line 68: | ||
if trained then |
if trained then |
||
images = images . string.format( |
images = images . string.format( |
||
'|-| |
'|-|Trained=[[File:%s|%dpx]]', |
||
trained, |
trained, |
||
image_size) |
image_size) |
||
Line 137: | Line 137: | ||
addHeader(args['title']) |
addHeader(args['title']) |
||
addCardArt(args['untrained'], args['trained']) |
addCardArt(args['rarity'], args['untrained'], args['trained']) |
||
addRow('Japanese', args['japanese']) |
addRow('Japanese', args['japanese']) |
||
addRow('Romaji', args['romaji']) |
addRow('Romaji', args['romaji']) |
Revision as of 03:42, 29 May 2021
This module depends on the following other modules: |
To generate {{Infobox card}}, invoke using the main function.
--------------------------
-- Module for [[Template:Infobox Card]]
------------------------
local getArgs = require('Module:Arguments').getArgs
local p = {}
local _frame
local width = '330px'
local root
local colors = {
cute = { bg = '#FF70A8', text = '#FFFFFF' },
cool = { bg = '', text = ''},
pure = { bg = '', text = ''},
happy = { bg = '', text = ''},
mysterious = { bg = '#8651BC', text = '#FFFFFF' }
}
local palette = { bg = '#000000', text = '#FFFFFF' }
local units = {
vs = { image = 'Virtualsingerlogo.png', link = 'VIRTUAL SINGER' },
ln = { image = 'Leoneedlogo.png', link = 'Leo/need' },
mmj = { image = 'MMJ_logo.png', link = 'MORE MORE JUMP!'},
vbs = { image = 'Vivid_logo.png', link = 'Vivid BAD SQUAD'},
wxs = { image = 'Wonderlandsxswowtimelogo.png', link = 'Wonderlands×Showtime' },
['25ji'] = { image = '25ji-logo.png', link = '25-ji, Night Code de.' }
}
local function addHeader(label)
root:tag('tr')
:tag('th')
:attr('colspan', 30)
:css({
['text-align'] = 'center',
['background-color'] = palette.bg,
color = palette.text
})
:wikitext(label)
end
local function addRow(label, data)
if data then
root:tag('tr')
:attr('id', label)
:tag('th')
:attr('colspan', 12)
:css('text-align', 'left')
:wikitext(label)
:done()
:tag('td')
:attr('colspan', 18)
:wikitext(data)
:done()
end
end
local function addCardArt(rarity, untrained , trained)
local image_size = 300
if untrained and rarity then
local images = string.format(
'Untrained=[[File:%s|%dpx]]',
untrained,
image_size)
if trained then
images = images . string.format(
'|-|Trained=[[File:%s|%dpx]]',
trained,
image_size)
end
root:tag('tr')
:tag('td')
:attr('colspan', 30)
:css('text-align', 'center')
:wikitext(_frame:callParserFunction({
name = '#tag',
args = { 'tabber', images }
}))
end
end
local function addUnit(unit, subunit)
if unit and units[unit] then
local unit_info = units[unit]
root:tag('tr')
:tag('td')
:attr('colspan', 30)
:css('text-align', 'center')
:wikitext(
string.format(
"[[File:%s|150px|link=%s]]",
unit_info.image,
unit_info.link
))
end
end
local function addAttribute(attr)
if attr then
root:tag('tr')
:tag('td')
:attr('colspan', 30)
:css('text-align', 'center')
:wikitext(
_frame:expandTemplate({
title = 'Icons',
args = { attr, size='20px' }
})
)
end
end
function p.main(frame)
_frame = frame
args = getArgs(frame)
if args['bg color'] or args['text color'] then
if args['bg color'] then
palette.bg = args['bg color']
end
if args['text color'] then
palette.text = args['text color']
end
elseif args['attribute'] and colors[args['attribute']] then
palette = colors[args['attribute']]
end
root = mw.html.create('table')
root
:addClass('infobox')
:css('width', width)
addHeader(args['title'])
addCardArt(args['rarity'], args['untrained'], args['trained'])
addRow('Japanese', args['japanese'])
addRow('Romaji', args['romaji'])
addHeader('Unit')
addUnit(args['unit'], args['subunit'])
addHeader('Card Information')
addAttribute(args['attribute'])
addRow('Character', args['character'])
addRow('Release Date', args['date'])
addRow('Status', args['status'])
addRow('Card Debut', args['debut'])
addRow('Card ID', args['id'])
addHeader('Side Stories')
local spacer = root:tag('tr')
for i=1,30,1 do
spacer:tag('td')
:attr('colspan', 1)
:css('width', 'calc(100% / 30)')
end
return tostring(root)
end
return p