Module:Galleries

local p = {} local cargo = mw.ext.cargo local mf = require 'Module:MF'.main1

-- Grand Hero Battle promotional arts function p.grandHeroBattle(frame) local maps = cargo.query(		'Maps', 'Map,MapName',		{			where = "MapGroup='Grand Hero Battle'",			groupBy = '_pageName',			orderBy = 'Map'		}	) local imagelist = {} for _, m in ipairs(maps) do		local ext if m.Map < 'T0042' then ext = '.png' else ext = '.jpg' end imagelist[#imagelist + 1] = string.format(			'File:GHB %s%s|%s\n', mf(m.MapName:match('^[^:]+')), ext,			frame:expandTemplate{ title = 'UnitPage', args = { m.MapName }}) end return frame:extensionTag('gallery', table.concat(imagelist)) end

-- Bound Hero Battle promotional arts function p.boundHeroBattle(frame) local maps = cargo.query(		'Maps,MapUnits,Units',		"Maps._pageName=Page,Maps.Map=Map,GROUP_CONCAT(DISTINCT Units._pageName)=BHeroes",		{			join = 'Maps._pageName=MapUnits._pageName,MapUnits.Unit=Units.WikiName',			where = "Maps.MapGroup='Bound Hero Battle' AND Units.WikiName IS NOT NULL AND IFNULL(Units.Properties__full,'') NOT LIKE '%generic%'",			groupBy = 'Maps._pageName',			orderBy = 'Maps.Map'		}	) local imagelist = {} for _, m in ipairs(maps) do		local heroes = mw.text.split(m.BHeroes, '%s*,%s*') local heroname1 = heroes[1]:match('^[^:]+') local heroname2 = heroes[2]:match('^[^:]+') local herotext = '' if m.Page:match('^' .. heroname1) then herotext = string.format(				'%s & %s',				heroes[1], mf(heroname1), heroes[2], mf(heroname2)) else herotext = string.format(				'%s & %s',				heroes[2], mf(heroname2), heroes[1], mf(heroname1)) end local ext = '' if m.Map < 'T0041' then ext = '.png' else ext = '.jpg' end imagelist[#imagelist + 1] = string.format(			'File:BHB %s%s|%s\n', m.Page:match('^[^:]+'), ext, herotext) end return frame:extensionTag('gallery', table.concat(imagelist)) end

-- Legendary Hero Battle promotional arts function p.legendaryHeroBattle(frame) local maps = cargo.query(		'Maps', 'Map,MapName',		{			where = "MapGroup='Legendary Hero Battle' AND Map>='L0006'",			groupBy = '_pageName',			orderBy = 'Map'		}	) local imagelist = {} for _, m in ipairs(maps) do		local ext if m.Map < 'L0008' then ext = '.png' else ext = '.jpg' end imagelist[#imagelist + 1] = string.format(			'File:LHB %s%s|%s\n', mf(m.MapName:match('^[^:]+')), ext,			frame:expandTemplate{ title = 'UnitPage', args = { m.MapName }}) end return frame:extensionTag('gallery', table.concat(imagelist)) end

-- Mythic Hero Battle promotional arts function p.mythicHeroBattle(frame) local maps = cargo.query(		'Maps', 'Map,MapName',		{			where = "MapGroup='Mythic Hero Battle'",			groupBy = '_pageName',			orderBy = 'Map'		}	) local imagelist = {} for _, m in ipairs(maps) do		imagelist[#imagelist + 1] = string.format(			'File:MHB %s.jpg|%s\n', mf(m.MapName:match('^[^:]+')),			frame:expandTemplate{ title = 'UnitPage', args = { m.MapName }}) end return frame:extensionTag('gallery', table.concat(imagelist)) end

function p.tempestTrials(frame) local tempesttrials = cargo.query(		'News', '_pageName=Page,NewsDate',		{			where = "_pageName REGEXP '^Tempest Trials( Mini|\\\\+)?:' AND _pageName NOT LIKE '%Coming Soon%'",			orderBy = 'NewsDate'		}	) local imagelist = {} for _, tt in ipairs(tempesttrials) do		ttname = tt.Page:match(': ([^(]+) %(Notification%)$')		if tt.NewsDate < '2018-10-14' then			ext = '.png'		else			ext = '.jpg'		end		imagelist[#imagelist + 1] = string.format( 'File:Tempest Trials %s%s|%s\n', mf(ttname), ext, ttname)		if tt.NewsDate >= '2018-11-12' then			imagelist[#imagelist + 1] = string.format( 'File:Tempest Trials %s 2%s|%s\n', mf(ttname), ext, ttname)		end	end	return frame:extensionTag('gallery', table.concat(imagelist)) end

function p.forgingBonds(frame) local forgingbonds = cargo.query(		'ForgingBonds', '_pageName=Page,Name',		{			orderBy = 'StartTime'		}	) local imagelist = {} for _, fb in ipairs(forgingbonds) do		imagelist[#imagelist + 1] = string.format(			'File:Forging Bonds %s.png|%s\n', mf(fb.Name), fb.Page) end return frame:extensionTag('gallery', table.concat(imagelist)) end

return p