Module:MythicEffectTable

local List = require 'Module:ListUtil' local Hash = require 'Module:HashUtil' local cargo = mw.ext.cargo

local ROWS = {'Light', 'Astra', 'Dark', 'Anima'} local COLUMNS = {'Atk', 'Spd', 'Def', 'Res'}

local main = function (args) local query = Hash.map_self(List.group_by(cargo.query(		'MythicHero',		'_pageName=Hero,MythicEffect=Effect,MythicEffect2=Effect2,AllyBoostHP=HP,AllyBoostAtk=Atk,AllyBoostSpd=Spd,AllyBoostDef=Def,AllyBoostRes=Res',		{limit = 100}	), function (v) return v.Effect end), function (v)		return List.group_by(v, function (x) return select(2, List.find_if(COLUMNS, function (col) return x[col] ~= '0' end)) end)	end)

local tbl = mw.html.create('table'):addClass('wikitable default'):css('text-align', 'center') tbl:tag('th'):wikitext('Mythic Effect') tbl:tag('th'):wikitext(' Atk+3') tbl:tag('th'):wikitext(' Spd+4') tbl:tag('th'):wikitext(' Def+5') tbl:tag('th'):wikitext(' Res+5') for _, element in ipairs(ROWS) do		local tr = tbl:tag('tr') tr:tag('td'):wikitext((' %s'):format(element, element))

for _, col in ipairs(COLUMNS) do			local heroes = query[element] and query[element][col] or {} tr:tag('td'):css('padding', '1em'):wikitext(table.concat(List.map(heroes, function (h)				return mw.getCurrentFrame:expandTemplate{title = 'UnitIcon', args = {name = h.Hero, size = '45px'}}			end), ' ')) end end

return tostring(tbl) end

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