Documentation for this module may be created at Module:Page/Memento/doc
local render_item_icon = require('Module:Render/Item')._icon
local render_gear_icon = require('Module:Render/Gear')._icon
local render_memento_icon = require('Module:Render/Memento')._icon
local model = require('Module:Data').model
local p = {}
local typeMap = {
['1'] = 'Equipment',
['2'] = 'Enhance EXP',
['3'] = 'Enhance Trust',
}
local maxLevels = {1, 25, 30, 35, 40}
local function getVCR(data)
local t = {}
local f = function(s, render_icon)
local counts = data['trust_'..s..'_counts']
for i, v in ipairs(data['trust_'..s..'_names']) do
-- table.insert(sb2, i)
-- table.insert(sb2, (counts[i] > 1) and counts[i] or nil)
table.insert(t, render_icon({v, name = 'none', count = counts[i] > 1 and counts[i] or nil}))
end
end
f('item', render_item_icon)
f('artifact', render_gear_icon)
return #t > 0 and table.concat(t) or nil
end
local function getUnitReward(data)
local iname = data.first_get_unit or ''
if iname == '' then return nil end
return render_unit_icon{iname, size='small'}
end
local renderPage = function(iname)
local rows = model.query('ConceptCard','_pageName,server,rare,icon,en_cost,en_exp,en_trust,first_get_unit,trust_item_names,trust_item_counts,trust_artifact_names,trust_artifact_counts,type',{where='iname="'..iname..'"'})
if #rows == 0 then
return '`'..iname..'` not found in ConceptCard table.'
end
local data = rows[1]
local getLoc = function(param) return model.getLoc(data._pageName, param) end
local sb = {}
local cats = {
'Memento'
}
-- Info Box
table.insert(sb, '{| class="wikitable unit ibox" style="float:right; margin-left: 15px;margin-bottom:0; width: 482px"\n| style="padding:0;width:128px;white-space: nowrap" | ')
local name = getLoc('name')
table.insert(sb, render_memento_icon({iname, data=data, size='large', name='none', link='none'}))
table.insert(sb, '\n! colspan="2" style="padding:12px;font-size:140%;" | ')
table.insert(sb, name)
table.insert(sb, '<span style="font-size:65%"><br/>\n')
table.insert(sb, data.rare + 1)
table.insert(sb, '★ Memento<br/>\n')
table.insert(sb, '[http://www.alchemistcodedb.com/card/' .. string.lower(string.gsub(iname, '_', '-')) .. ' See on Alchemist Code Database]\n')
if data.type then
table.insert(sb, '|-\n!colspan="2"|Type\n|')
local typeMap = {
['1'] = 'Equipment',
['2'] = 'Enhance EXP',
['3'] = 'Enhance Trust',
}
table.insert(sb, typeMap[data.type])
table.insert(sb, '\n')
cats[#cats+1] = typeMap[data.type] .. ' memento'
end
table.insert(sb, '|-\n!colspan="2"|Max Level\n|')
local maxLevels = {1, 25, 30, 35, 40}
table.insert(sb, maxLevels[data.rare + 1])
table.insert(sb, '\n')
-- The amount of zeni required to upgrade another memento with this memento
table.insert(sb, '|-\n!colspan="2"|Enhancer Cost (Zeni)\n|')
table.insert(sb, data.en_cost)
table.insert(sb, '\n')
-- Enhancer EXP is the amount of EXP this memento gives
table.insert(sb, '|-\n!colspan="2"|Enhancer EXP\n|')
table.insert(sb, data.en_exp)
table.insert(sb, '\n')
if data.en_trust then
table.insert(sb, '|-\n!colspan="2"|Enhancer Trust\n|')
table.insert(sb, data.en_trust)
table.insert(sb, '\n')
end
-- Vision Clear Reward
local vcr = getVCR(data)
if vcr then
table.insert(sb, '|-\n!colspan="2"|Vision Clear Reward\n|')
table.insert(sb, vcr)
table.insert(sb, '\n')
end
-- Unit reward
local unit_reward = getUnitReward(data)
if unit_reward then
table.insert(sb, '|-\n!colspan="2"|Gives Unit\n|')
table.insert(sb, unit_reward)
table.insert(sb, '\n')
end
-- Memento extra data
local mementoExtra = mw.loadData("Module:Data/Extra/Memento")
table.insert(sb, '|-\n!colspan="2"|Source\n|')
if mementoExtra[iname] and mementoExtra[iname]['source'] then
table.insert(sb, mementoExtra[iname]['source'])
else
table.insert(sb, 'Unreleased')
end
table.insert(sb, '\n')
if mementoExtra[iname] then
if mementoExtra[iname]['glDate'] then
table.insert(sb, '|-\n!colspan="2"|Release Date\n| '..mementoExtra[iname]['glDate'].."\n")
end
if mementoExtra[iname]['jpDate'] then
table.insert(sb, '|-\n!colspan="2"|JP Release Date\n| '..mementoExtra[iname]['jpDate'].."\n")
end
if mementoExtra[iname]['glOnly'] then
table.insert(sb, '|-\n!colspan="2"|Global Only\n| Yes\n')
end
end
-- Body
-- Card Image + Flavor
table.insert(sb, '|}\n<div class="responsive-img" style="margin:auto;width:fit-content">[[File:Game,ConceptCard,')
table.insert(sb, data.icon)
table.insert(sb, '.png]]<div style="max-width:1024px;padding:8px;">')
table.insert(sb, getLoc('flavor'))
table.insert(sb, '</div></div>')
-- Category
for i, cat in ipairs(cats) do
table.insert(sb, '\n[[Category:'.. cat ..']]')
end
-- TODO Implement http://cdn.alchemistcodedb.com/assets/big-card-frames-b34ac394d6035fb657d491b956e2c4764836b51b9361fccc4b31e722a27df510.png
return table.concat(sb)
end
local function renderPage2(iname)
local rows = model.query('ConceptCard','_pageName,server,rare,icon,en_cost,en_exp,en_trust,first_get_unit,trust_item_names,trust_item_counts,trust_artifact_names,trust_artifact_counts,type',{where='iname="'..iname..'"'})
if #rows == 0 then
return '`'..iname..'` not found in ConceptCard table.'
end
local data = rows[1]
local getLoc = function(param) return model.getLoc(data._pageName, param) end
local cats = {'Memento'}
local name = getLoc('name')
local icon = render_memento_icon{iname, data=data, size='large', name='none', link='none'}
local typeName = typeMap[data.type]
cats[#cats+1] = typeName .. ' mementos'
local rank = data.rare + 1
local maxLevel = maxLevels[rank]
local enhancer_cost = data.en_cost
local enhancer_exp = data.en_exp
local enhancer_trust = data.en_trust
local vcr = getVCR(data)
local unit_reward = getUnitReward(data)
local extra = mw.loadData("Module:Data/Extra/Memento")[iname] or {}
local source = extra.source or 'Unreleased'
local glDate = extra.glDate
local jpDate = extra.jpDate
local glOnly = extra.glOnly
local artwork = '[[File:Game,ConceptCard,'..data.icon..'.png]]'
local flavor = getLoc('flavor')
-- Render
local function printRow(t, label, content)
if content == nil then return end
t:tag('dt'):cssText('grid-column-start:1;border-right:2px solid #999;margin:0 -2px 0 0;padding:2px 8px 2px 3px;text-align:right'):wikitext(label)
t:tag('dd'):cssText('grid-column-start:2;border-left:2px solid #999;margin:0;padding:2px 7px;text-align:left'):wikitext(content)
end
local root = mw.html.create()
local infobox = root:tag('div'):addClass('infobox'):cssText('text-align:center')
infobox:tag('div'):addClass('name'):cssText('font-size:140%;font-weight:700'):wikitext(name)
infobox:tag('div'):node(icon)
local wrapper = infobox:tag('div'):addClass('wrapper')
local dl = wrapper:tag('dl'):cssText('display:grid')
printRow(dl, 'Type', typeName)
printRow(dl, 'Rank', rank .. '★')
printRow(dl, 'Max Level', maxLevel)
printRow(dl, 'Enhancer Cost', enhancer_cost)
printRow(dl, 'Enhancer EXP', enhancer_exp)
printRow(dl, 'Enhancer Trust', enhancer_trust)
printRow(dl, 'Vision Clear Reward', vcr)
printRow(dl, 'Gives Unit', unit_reward)
printRow(dl, 'Source', source)
printRow(dl, 'Release Date', glDate)
printRow(dl, 'JP Release Date', jpDate)
printRow(dl, 'Global Only', glOnly and 'Yes' or nil)
root:tag('div'):addClass('responsive-img'):cssText('margin:auto;width:fit-content')
:wikitext(artwork)
:tag('div'):addClass('flavor'):wikitext(flavor)
for i, cat in ipairs(cats) do
root:wikitext('[[Category:'..cat..']]')
end
return tostring(root)
end
local renderFuncs = {}
renderFuncs.Icon = render_memento_icon
local renderTransclude = function(iname, args)
local type = mw.text.trim(args[1])
args[1] = iname
return (renderFuncs[type] or renderFuncs.Name)(args)
end
function p._main(iname, args)
if not args or args.isPage then
return renderPage(iname)
else
return renderTransclude(iname, args)
end
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {parentFirst = true})
return renderPage(args[1])
end
function p.test(frame)
local args = require('Module:Arguments').getArgs(frame, {parentFirst = true})
return renderPage2(args[1])
end
return p