Module:HeroImagesGallery

local cargo = mw.ext.cargo local escq = require 'Module:EscQ'.main1 local mf = require 'Module:MF'.main1 local toboolean = require 'Module:Bool'.toboolean local List = require 'Module:ListUtil'

local IMAGES = File:%s_Face.webp File:%s_BtlFace.webp File:%s_BtlFace_C.webp File:%s_BtlFace_D.webp

local makeList = function (heroesList, frame) local ul = mw.html.create('ul') for _, v in ipairs(heroesList) do		local li = ul:tag('li'):wikitext(frame:expandTemplate {title = 'UnitPage', args = {v.page}}) if v.resplendent == '1' then li:wikitext(' (Resplendent Attire)') end end return tostring(ul) end

local makeGallery = function (heroesList, frame) return table.concat(List.map(heroesList, function (v) local header = mw.html.create('h3'):wikitext(, v.page, ) local filename = mf(v.page) if v.resplendent == '1' then header:wikitext(' (Resplendent Attire)') filename = filename .. '_Resplendent' end return tostring(header) .. frame:extensionTag('gallery', IMAGES:format(filename, filename, filename, filename)) end), '') end

local byArtist = function (args, frame) local artist = args[1] local heroesQuery = cargo.query('Units', '_pageName=page,CONCAT(0)=resplendent', {		where = ("Artist='%s'"):format(escq(artist)),		groupBy = 'page',		limit = 1000,	}) local heroesQueryR = cargo.query('ResplendentHero=R,Units=U', 'U._pageName=page,CONCAT(1)=resplendent', {		join = 'R.Unit=U.WikiName',		where = ("R.Artist='%s' AND U.WikiName IS NOT NULL"):format(escq(artist)),		groupBy = 'page',		limit = 1000,	}) List.concat_self(heroesQuery, heroesQueryR) table.sort(heroesQuery, function (x, y) return x.page < y.page or (x.page == y.page and x.resplendent < y.resplendent) end) return (toboolean(args.list) and makeList or makeGallery)(heroesQuery, frame) end

local byCompany = function (args, frame) local company = args[1] local heroesQuery = cargo.query('Units=U,Artists=A', 'U._pageName=page,CONCAT(0)=resplendent', {		join = 'U.Artist=A.Name',		where = ("A.Company='%s'"):format(escq(company)),		groupBy = 'page',		limit = 1000,	}) local heroesQueryR = cargo.query('ResplendentHero=R,Units=U,Artists=A', 'U._pageName=page,CONCAT(1)=resplendent', {		join = 'R.Unit=U.WikiName,R.Artist=A.Name',		where = ("A.Company='%s' AND U.WikiName IS NOT NULL"):format(escq(company)),		groupBy = 'page',		limit = 1000,	}) List.concat_self(heroesQuery, heroesQueryR) table.sort(heroesQuery, function (x, y) return x.page < y.page or (x.page == y.page and x.resplendent < y.resplendent) end) return (toboolean(args.list) and makeList or makeGallery)(heroesQuery, frame) end

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