Module:MythicHeroBattleTable

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

local main = function (_, frame) local maps = cargo.query('Maps=M,MapDescriptions=D', 'M._pageName=page,M.HasReward=reward,D.Description=desc', {		join = 'M._pageName=D.Map',		where = "M.MapGroup='Mythic Hero Battle'",		orderBy = 'M.Map',		limit = 100,	}) local mapDates = List.group_by(cargo.query( 'Maps=M,MapDates=D', "M._pageName=page,StartTime=t0,EndTime=t1", { join = 'M._pageName=D._pageName', where = "M.MapGroup='Mythic Hero Battle'", orderBy = 't0', limit = 100, }), function (v) return v.page end) local summoningFocuses = Hash.from_ipairs(cargo.query( 'SummoningEvents=SE,SummoningEventFocuses=SEF,Units=U', "SE._pageName=page,SE.Name=name,IFNULL(CONCAT(U.Name,': ',U.Title),U.Name)=hero", { join = 'SE.WikiName=SEF.WikiName,SEF.Unit=U.WikiName', where = "SE.EventType='Mythic' AND DATE(SE.StartTime)=DATE(U.ReleaseDate)", limit = 100, }), function (v) return v.hero .. ' (map)', v end)

local tbl = mw.html.create('table'):addClass('wikitable'):addClass('default'):css('text-align', 'center') local row = tbl:tag('tr') row:tag('th'):css('width', '23%'):wikitext('Map') row:tag('th'):css('width', '10%'):wikitext('Rewards') row:tag('th'):css('width', '30%'):wikitext('Description') row:tag('th'):css('width', '20%'):wikitext('Availability') row:tag('th'):css('width', '14%'):wikitext('Summoning event')

for _, v in ipairs(maps) do		row = tbl:tag('tr') row:tag('td'):wikitext(frame:expandTemplate {title = 'Banner HB', args = {link = v.page}}) row:tag('td'):wikitext(v.reward) row:tag('td'):wikitext(v.desc) row:tag('td'):wikitext(table.concat(List.map(mapDates[v.page] or {}, function (v)			return Datetime.ht_range(v.t0, v.t1)		end), ' '))

local cell = row:tag('td') local focus = summoningFocuses[v.page] if focus then cell:wikitext(frame:expandTemplate {title = 'UnitIcon', args = {name = focus.hero, size = '63px'}},				' ', focus.name, '') end end

return tbl end

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