Module:ListSkills

local p = {}

function p.main(frame) if frame == mw.getCurrentFrame then args = require('Module:ProcessArgs').merge(true) else frame = mw.getCurrentFrame end

local fields = Skills._pageName=_pageName,   Skills.name=name,    Skills.image=image,    Descriptions.description=description,    Skills.requires=requires,    Skills.consumes=consumes,    Skills.cooldown=cooldown,    Skills.skilltype=skilltype,    Skills.subtype=subtype,    Skills.skilltier=skilltier,    Skills.trainer=trainer,    Skills.location=location,    Skills.cost=cost,    Skills.prereq=prereq

local wheres = '' if (args.skilltype ~= nil) then wheres = wheres .. 'skilltype="' .. args.skilltype .. '"' end if (args.subtype ~= nil) then if wheres ~= '' then wheres = wheres .. ' AND ' end wheres = wheres .. 'subtype="' .. args.subtype .. '"' end if (args.skilltier ~= nil) then if wheres ~= '' then wheres = wheres .. ' AND ' end wheres = wheres .. 'skilltier="' .. args.skilltier .. '"' end

local cargoArgs = { where = wheres, orderBy = 'Skills.name', join = 'Skills.name = Descriptions.name', }

local result = p.doQuery(fields, cargoArgs) if not result then return '' end

local html = mw.html.create local tbl = html:tag('table'):addClass('wikitable sortable')

-- header row local trHeader = tbl:tag('tr') trHeader:tag('th'):wikitext('Image') trHeader:tag('th'):wikitext('Name') trHeader:tag('th'):cssText('min-width:350px;'):wikitext('Description') if (args.skilltype == 'Passive') then trHeader:tag('th'):wikitext('Tier') trHeader:tag('th'):wikitext('Cost') trHeader:tag('th'):wikitext('Acquisition') else trHeader:tag('th'):wikitext('Required') trHeader:tag('th'):wikitext('Consumes') trHeader:tag('th'):wikitext('Cooldown') trHeader:tag('th'):wikitext('Tier') trHeader:tag('th'):wikitext('Cost') trHeader:tag('th'):wikitext('Acquisition') end

for _, row in ipairs(result) do       local tr = tbl:tag('tr') -- image tr:tag('td'):cssText('text-align: center;'):wikitext(frame:preprocess('')) -- name tr:tag('td'):wikitext(frame:preprocess( .. row.name .. )) -- description tr:tag('td'):wikitext(frame:preprocess(row.description))

if (args.skilltype == 'Passive') then tr:tag('td'):wikitext(row.skilltier) if (row.skilltier == 'Quest') then tr:tag('td'):wikitext(frame:preprocess(n/a)) tr:tag('td'):wikitext(frame:preprocess(row.prereq)) else tr:tag('td'):wikitext(frame:preprocess(row.cost)) tr:tag('td'):wikitext(frame:preprocess(row.trainer)) end else tr:tag('td'):wikitext(frame:preprocess(row.requires)) tr:tag('td'):wikitext(frame:preprocess(row.consumes)) tr:tag('td'):wikitext(row.cooldown) tr:tag('td'):wikitext(row.skilltier) tr:tag('td'):wikitext(row.cost or None) tr:tag('td'):wikitext(frame:preprocess(row.trainer)) end end

return html end

function p.doQuery(fields, cargoArgs) local result = mw.ext.cargo.query('Skills,Descriptions', fields, cargoArgs) if not next(result) then return nil else return result end end

function split(inputstr, sep) if sep == nil then sep = "%s" end local t={} for str in string.gmatch(inputstr, "([^"..sep.."]+)") do       table.insert(t, str) end return t end

return p