Documentation for this module may be created at Module:Page/Gear/doc
local render_item_icon = require('Module:Render/Item')._icon
local render_gear_icon = require('Module:Render/Gear')._icon
local render_job_icon = require('Module:Render/Job')._icon
local model = require('Module:Data').model
local skillLink = require("Module:LinkUtils").acdbLink
local p = {}
-- Weapon Enlightenment Output
function p.inspirationList(insp_skill)
if (insp_skill == nil or insp_skill == '') then return end
local inspList = mw.loadData("Module:Data/MasterParam/InspirationSkill")
local function abilPageName(iname)
return 'Data:Game/MasterParam/Ability/' .. string.gsub(iname, '_', ' ')
end
local function abilityName(iname)
return model.getLoc(abilPageName(iname), 'name')
end
local function abilityExpr(iname)
return model.getLoc(abilPageName(iname), 'expr')
end
local function inspSkillData(iname)
return inspList[iname] or nil
end
local printInspSkill
printInspSkill = function(root, iname, level)
local skillData = inspSkillData(iname)
if skillData == nil then return end
if (skillData.ability and skillData.ability ~= '') then
local abilityData = model.query("Ability", "_pageName,skl1", {where = 'iname="'..skillData.ability..'" and server = "gl"'})[1] or {}
local name = abilityName(skillData.ability) or skillData.ability
local expr = abilityExpr(skillData.ability) or '???'
local linkName = name
if abilityData.skl1 then
linkName = '['..skillLink(abilityData.skl1)..' '..name..']'
end
-- table.insert(root, (string.rep('*', level) .. " '''" .. name .. ":''' " .. expr))
root = root:tag('li')
:tag('b'):wikitext(linkName..':'):done()
:wikitext(' ' .. expr )
end
if skillData.derivation then
local ul
for _, subData in ipairs(skillData.derivation) do
ul = ul or root:tag('ul')
printInspSkill(ul, subData['iname'], level + 1)
end
end
end
local output = mw.html.create()
printInspSkill(output, insp_skill, 0)
if mw.text.trim(tostring(output)) == '' then return end
local root = mw.html.create()
root:newline():tag('div'):addClass('clear')
root:newline():tag('h2'):wikitext('Weapon Enlightenment Skills')
root:newline():node(output)
return root
end
local renderPage = function(iname)
local rows = model.query('Artifact','_pageName,server,rini,rmax,icon,maxnum,type,kakera,jobs,tag,equip1,equip2,equip3,equip4,equip5,pvp_equip1,pvp_equip2,pvp_equip3,pvp_equip4,pvp_equip5,abils,abrares,attack1,attack2,attack3,attack4,attack5,insp_skill',{where='iname="'..iname..'"'})
if #rows == 0 then
return ('`'..iname..'` not found in Artifact table. Check [https://www.alchemistcodedb.com/gear/'..string.lower(string.gsub(iname, '_', '-'))..' AlchemistCodeDB]')
end
local data = rows[1]
local getLoc = function(param) return model.getLoc(data._pageName, param) end
local name = getLoc('name')
-- local infoboxIcon = render_gear_icon({iname, data=data, size='large', name='none', link='none'})
local root = mw.html.create()
-- Info Box
local infobox = root:tag('div'):addClass('infobox gear')
:cssText('float: right; margin-left: 15px; width: 300px; border: 1px solid #aaa; background: #eee; font-size: 12px;')
local heading = infobox:tag('div'):addClass('heading')
:cssText('background: goldenrod; font-weight: 700; font-size: 140%; line-height: 1.25em; display: flex; flex-direction: row; justify-items: flex-start; text-align: center; min-height: 64px;')
if data.icon then
local infoboxIcon = heading:tag('div'):addClass('infobox-icon')
:cssText('flex: 0 0 64px; padding: 0.25rem;')
infoboxIcon:tag('div'):addClass('item-icon')
:tag('div'):addClass('img x-'..data.rini..' y-2')
:cssText('width:57px; height: 57px; padding:3.5px')
:wikitext('[[File:Game,ArtiIcon,'..data.icon..'.png|57px]]')
end
heading:tag('div'):addClass('name')
:cssText('flex: 1 1 100%; display: flex; text-align: center; align-items: center; justify-content: center; margin: 0; padding: 0.25rem;')
:wikitext(name)
local wrapper = infobox:tag('div'):addClass('wrapper')
:cssText('flex: 1 1 100%; overflow: hidden;')
local dl = wrapper:tag('dl')
:cssText('display: grid; grid-template-columns: 100px 1fr;')
local function printRow(t, label, content)
if content == nil then return end
t:tag('dt')
:cssText('grid-column-start: 1; padding: 2px 8px 2px 3px; text-align: right; border-right: 2px solid #aaa; margin: 0 -2px 0 0;')
:wikitext(label)
t:tag('dd')
:cssText('grid-column-start: 2; margin: 0; padding: 2px 7px; border-left: 2px solid #aaa;')
:wikitext(content)
end
local rank
if tonumber(data.rini) then rank = (data.rini + 1)..'★' end
if tonumber(data.rmax) > tonumber(data.rini) then
rank = rank .. ' – '..(data.rmax + 1)..'★'
end
printRow(dl, 'Rank', rank)
-- Job list
if data.jobs then
local jobList = {}
for i, jkey in ipairs(data.jobs) do
local jobData = model.query('Job','iname',{where='iname="'..jkey..'"'})
if jobData[1] then
table.insert(jobList, render_job_icon({jkey, size='small', name='none'}))
end
end
if #jobList > 0 then
printRow(dl, 'Jobs', table.concat(jobList, ' '))
end
end
printRow(dl, 'Requirement', getLoc('spec'))
-- Gear type data
printRow(dl, 'Type', 'Gear')
local gearTypeMap = mw.loadData("Module:Data/Extra/GearTypeMap")
if data.type and gearTypeMap['gearClass'][data.type] then
printRow(dl, 'Gear type', gearTypeMap['gearClass'][data.type] .. (data.tag and ' ('..(gearTypeMap['gearType'][data.tag] or data.tag)..')' or ''))
end
-- Gear extra data
local gearExtra = mw.loadData("Module:Data/Extra/Gear")[iname]
local source = gearExtra and gearExtra.source or 'Unreleased'
printRow(dl, 'Source', source)
local releaseDates
if gearExtra then
if gearExtra['glDate'] then
releaseDates = releaseDates or mw.html.create('ul')
releaseDates:tag('li'):wikitext('GL: '..gearExtra['glDate'])
end
if gearExtra['jpDate'] then
releaseDates = releaseDates or mw.html.create('ul')
releaseDates:tag('li'):wikitext('JP: '..gearExtra['jpDate'])
end
printRow(dl, 'Release dates', releaseDates and tostring(releaseDates) or nil)
if gearExtra['glOnly'] then
printRow(dl, 'Global only', 'Yes')
end
end
-- Shard source
printRow(dl, 'Item shard', data.kakera and render_item_icon({ data.kakera, name = 'none' }) or nil)
-- Transmute limit
printRow(dl, 'Transmute limit', data.maxnum < 999 and data.maxnum or nil)
-- Ext links
printRow(dl, 'External links', '[http://www.alchemistcodedb.com/gear/' .. string.lower(string.gsub(iname, '_', '-')) .. ' AlchemistCodeDB]')
-- Body
root:tag('p'):wikitext(getLoc('flavor'))
root:tag('p'):wikitext(getLoc('expr'))
-- Stat Output
local gearStats = require('Module:GearStats')
root:newline():wikitext(gearStats.getGearStatOutput(data))
-- Ability Output
root:newline():wikitext(gearStats.gearAbilityOutput(data, frame))
root:newline():node(p.inspirationList(data.insp_skill))
-- Category
local cats = {}
table.insert(cats, 'Gear')
if source:find('Unreleased') then
table.insert(cats, 'Unreleased gear')
end
if source:find('Free') then
table.insert(cats, 'Free gear')
end
if source:find('PvP') then
table.insert(cats, 'PvP gear')
end
if source:find('VCR') then
table.insert(cats, 'Vision Clear Rewards')
end
if source:find('Limited Summon') then
table.insert(cats, 'Limited summon gear')
elseif source:find('Summon') then
table.insert(cats, 'Summon gear')
end
if source:find('Gem') then
table.insert(cats, 'Gem gear')
end
if data.insp_skill and data.insp_skill ~= '' then
table.insert(cats, 'Gear with enlightened skills')
end
for i,cat in ipairs(cats) do
root:wikitext('[[Category:'..cat..']]')
end
return tostring(root)
end
local renderFuncs = {}
renderFuncs.Icon = render_gear_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 args.isPage then
return renderPage(iname)
else
return renderTransclude(iname, args)
end
end
p.renderPage = renderPage
function p.test()
mw.log(p.renderPage('AF_ARMS_KATANA_MASAMUNE_01'))
mw.log(p.inspirationList('INSP_SWORD_CANON'))
end
return p