Module:HeroList

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

local SUFFIXES = { story = 'Story', ghb = 'Grand Hero Battle', tempest = 'Tempest Trials', special = 'Special', legendary = 'Legendary', mythic = 'Mythic', --	demoted_240 = '* ', }

local getRarityWikitext = function (rarities, properties) local wikitexts = {HeroUtil._availabilityText {avail = rarities}}

-- Get suffix for _, p in ipairs(properties) do		if SUFFIXES[p] then wikitexts[#wikitexts + 1] = SUFFIXES[p] end end

return table.concat(wikitexts, ' ') end

local heroList = function local heroQueryResult = cargo.query('Units', "_pageName=Page,IFNULL(CONCAT(Name,': ',Title),Name)=Hero,MoveType,WeaponType,Origin,GameSort,Entries,Properties__full", {		where = "IFNULL(Properties__full,'') NOT LIKE '%enemy%'",		groupBy = '_pageName',		limit = 1000,	}) local avail = HeroUtil.getLowestRarities {current = true} local releaseTimes = HeroUtil.getReleaseTimes {}

local theUnit = nil local builder = HeroTableBuilder.new

builder:heroIcon('75px') builder:heroLink:css('width', '20%') builder:column('Appears in', function (elem)		elem:attr('data-sort-value', theUnit.GameSort):wikitext((%s):format(theUnit.Origin))	end):css('width', '25%') builder:heroEntry('35px'):css('width', '9%') builder:moveType('35px'):css('width', '9%') builder:weaponType('35px'):css('width', '9%') builder:column('Rarities', function (elem)		elem:wikitext(getRarityWikitext(avail[theUnit.Page], mw.text.split(theUnit.Properties__full, '%s*,%s*')))	end):css('width', '10%') builder:column('Release date', function (elem)		local heroReleaseTime = releaseTimes[theUnit.Page] and releaseTimes[theUnit.Page]:earliest or 0x7FFFFFFF		elem:wikitext(heroReleaseTime < 0x7FFFFFFF and os.date('%Y-%m-%d', heroReleaseTime) or 'N/A')	end):css('width', '12%')

for _, v in ipairs(heroQueryResult) do		theUnit = v		builder:addHero(v.Page, v.Hero, v.MoveType, v.WeaponType, v.Entries) end

return builder:build:addClass('wikitable'):addClass('default'):css('text-align', 'center'):css('width', '100%') end

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