Module:Collectible
Jump to navigation
Jump to search
The Lua source code for the display of Collectibles in Integrated Strategies through {{Collectible}}.
Collectible data is retrieved from the following data modules:
- Module:Collectible/cf – Ceobe's Fungimist
- Module:Collectible/pcs – Phantom & Crimson Solitaire
- Module:Collectible/mca – Mizuki & Caerula Arbor
- Module:Collectible/ej – Expeditioner's Joklumarkar
local p = {}
local themeNameLookup = {
cf = "Ceobe's Fungimist",
ej = "Expeditioner's Joklumarkar",
mca = "Mizuki & Caerula Arbor",
pcs = "Phantom & Crimson Solitaire",
sff = "Sarkaz's Furnaceside Fables",
}
local qualityLookup = {
normal = 1,
rare = 2,
superrare = 3,
}
local data = {
cf = mw.loadData('Module:Collectible/cf'),
ej = mw.loadData('Module:Collectible/ej'),
mca = mw.loadData('Module:Collectible/mca'),
pcs = mw.loadData('Module:Collectible/pcs'),
sff = mw.loadData('Module:Collectible/sff'),
}
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
function p.main(frame)
local args = getArgs(frame, {
wrappers = 'Template:Collectible'
})
return p._main(args)
end
function p._main(args)
local key = args[1]
local themeName
local col
for k, v in pairs(data) do
col = v[key]
if col then
themeName = themeNameLookup[k]
break
end
end
if not col then return ' <i>Collectible not found</i> ' end
local name = col.name or key
local image = col.image or col.name
local text = col.title or col.name
local link = col.link or col.name
local attrs = {
['data-name'] = name,
['data-title'] = col.title,
['data-num'] = col.num,
['data-qlt'] = qualityLookup[col.qlt],
['data-use'] = col.use,
['data-desc'] = col.desc,
['data-theme'] = themeName,
['data-cond'] = col.cond,
}
local root = mw.html.create('')
if yesno(args.gridview) then
local div = root:tag('div')
:attr('style', 'display:inline-block; position:relative; margin:5px;')
local a = div:tag('div')
:addClass('a')
local tt = a:tag('div')
:addClass('collectible-tooltip')
:attr(attrs)
:wikitext('[[File:'..image..'.png|60x60px|link='..link..']]')
:tag('div')
:attr('style', "margin-top:2px;")
:wikitext('[['..link..'|'..text..']]')
else
local span = root:tag('span')
:attr('style', 'display:inline-block;')
local tt = span:tag('span')
:addClass('collectible-tooltip')
:attr(attrs)
:wikitext('[[File:'..image..'.png|20x20px|link='..link..']] ')
:wikitext('[['..link..'|'..text..']]')
end
return root
end
return p