Module:SacredSealList

local cargo = mw.ext.cargo local Util = require 'Module:Util' local List = require 'Module:ListUtil' local stripWikitext = require 'Module:StripWikitext'.main1

local SEAL_CATEGORIES = { passivea = 'A Skill', passiveb = 'B Skill', passivec = 'C Skill', sacredseal = 'Exclusive', }

local isSealCreatable = function (query) return query.badges ~=  and query.gbadges ~=  and query.coins ~= '' end

local Template_SkillText_nocargo = function (frame, icon, page, name, desc) if Util.isNilOrEmpty(name) then return Util.isNilOrEmpty(page) and '' or ('%s'):format(page) end if Util.isNilOrEmpty(page) then return name or '' end return (' %s'):format(		icon, page, page, Util.isNilOrEmpty(desc) and name or frame:expandTemplate {title = 'Hover', args = {name, stripWikitext(desc)}}) end

local main = function (args, frame) local sealPages = List.map_self(cargo.query('SacredSealCosts', '_pageName', { groupBy = '_pageName', limit = 500, }), function (v) return v._pageName end) local sealGroups = List.group_by(cargo.query( 'SacredSealCosts,Skills', 'SacredSealCosts._pageName=page,Skill=name,Scategory=cat,BadgeColor=bcolor,BadgeCost=badges,GreatBadgeCost=gbadges,SacredCoinCost=coins,Icon,Description', { join = 'SacredSealCosts.Skill=Skills.Name', groupBy = 'Skill', orderBy = 'Skill', limit = 1000, }), function (v) return v.page end)

local tbl = mw.html.create('table'):addClass('wikitable'):addClass('sortable'):css('text-align', 'center'):css('width', '900px') local row = tbl:tag('tr') row:tag('th'):css('width', '20%'):wikitext('Seal') row:tag('th'):css('width', '5%'):wikitext('Type') row:tag('th'):css('width', '20%'):wikitext('Creation cost') row:tag('th'):css('width', '20%'):wikitext('Enhancement cost 1 → 2') row:tag('th'):css('width', '20%'):wikitext('Enhancement cost 2 → 3') row:tag('th'):css('width', '15%'):wikitext('Badge color')

for _, page in ipairs(sealPages) do		local seals = sealGroups[page] if List.any(seals, isSealCreatable) then row = tbl:tag('tr') row:tag('td'):css('text-align', 'left'):wikitext(Template_SkillText_nocargo(frame, seals[1].Icon, seals[1].page, seals[1].name, seals[1].Description)) --		row:tag('td'):css('text-align', 'left'):wikitext(frame:expandTemplate {title = 'SkillText', args = {seals[1].name}}) row:tag('td'):tag('b'):wikitext(SEAL_CATEGORIES[seals[1].cat] or 'Unknown') for rank = 1, 3 do				local s = seals[rank] if not s or not isSealCreatable(s) then row:tag('td'):wikitext(rank > 1 and 'Cannot be enhanced.' or 'Cannot be created.') else row:tag('td'):wikitext(('%s, %s , %s '):format( s.coins, s.gbadges, s.bcolor, s.badges, s.bcolor)) end end row:tag('td'):wikitext(seals[1].bcolor == '' and '—' or				('%s '):format(seals[1].bcolor, seals[1].bcolor, seals[1].bcolor)) end end

return tostring(tbl) end

return require 'Module:MakeMWModule'.makeMWModule {main = main}