Module:MythicHeroesTable

local cargo = mw.ext.cargo local List = require 'Module:ListUtil' local HeroUtil = require 'Module:HeroUtil' local HeroTableBuilder = require 'Module:HeroTableBuilder'

local main = function local units = cargo.query(		'MythicHero=MH,Units=U',		U._pageName=page,IFNULL(CONCAT(U.Name,': ',U.Title),U.Name)=name,Entries,MoveType,WeaponType,		 MythicEffect=elem,MythicEffect2=effect2,AllyBoostHP=hp,AllyBoostAtk=atk,AllyBoostSpd=spd,AllyBoostDef=def,AllyBoostRes=res, {		join = 'MH._pageName=U._pageName',		where = "IFNULL(Properties__full,'') NOT LIKE '%enemy%'",		groupBy = 'U.WikiName',		limit = 1000,	})

local statFmt = function (stat) return stat ~= '0' and ('%+d'):format(tonumber(stat)) or '—' end

local theUnit = nil local builder = HeroTableBuilder.new local releaseTimes = HeroUtil.getReleaseTimes {mask = {focus = true}}

builder:heroIcon builder:heroLink builder:heroEntry builder:moveType builder:weaponType builder:column('Element', function (elem) elem:wikitext((' %s'):format(theUnit.elem, theUnit.elem)) end) builder:column('HP', function (elem) elem:attr('data-sort-value', theUnit.hp):wikitext(statFmt(theUnit.hp)) end):css('width', '6%') builder:column('Atk', function (elem) elem:attr('data-sort-value', theUnit.atk):wikitext(statFmt(theUnit.atk)) end):css('width', '6%') builder:column('Spd', function (elem) elem:attr('data-sort-value', theUnit.spd):wikitext(statFmt(theUnit.spd)) end):css('width', '6%') builder:column('Def', function (elem) elem:attr('data-sort-value', theUnit.def):wikitext(statFmt(theUnit.def)) end):css('width', '6%') builder:column('Res', function (elem) elem:attr('data-sort-value', theUnit.res):wikitext(statFmt(theUnit.res)) end):css('width', '6%') builder:column('Special slot', function (elem) elem:wikitext(theUnit.effect2 ~= '' and 'Yes' or 'No') end) builder:column('Release date', function (elem) elem:wikitext(os.date('%Y-%m-%d', releaseTimes[theUnit.page]:earliest)) end):css('width', '12%')

for _, v in ipairs(List.sort_by(units, function (v) return releaseTimes[v.page]:earliest end)) do		theUnit = v		builder:addHero(v.page, v.name, v.MoveType, v.WeaponType, v.Entries) end

return builder:build:addClass('wikitable'):addClass('sortable'):css('text-align', 'center') end

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