Fire Emblem Heroes Wiki
Fire Emblem Heroes Wiki
Template-info.svg Documentation

Lua module to display summoning events.

  • cacheAllHeroes {}
For internal use only.
  • table {...}
Displays a summoning event in a table. This function does not query any summoning events, use Module:SummoningEventList instead.
  • page: Page name of the summoning event.
  • name: Name of the summoning event as shown in-game.
  • startDate, endDate: Start and end dates of the summoning event in YYYY-MM-DD format.
  • heroes: A Lua sequence of Focus Hero names or wikinames, or a semicolon-separated list of them.
  • extratitle, extratext: If present, displays an extra row with the given title and text. Used for example to attach event descriptions or story chapters.
  • page {...}
Defines a summoning event and displays it on a summoning event page.
local cargo = mw.ext.cargo
local Util = require 'Module:Util'
local List = require 'Module:ListUtil'
local Hash = require 'Module:HashUtil'
local escq = require 'Module:EscQ'.main1
local superimposeDiv = require 'Module:Superimpose'.div
local memoizer = require 'Module:Memoizer'.memoizer

local memoizeHero = memoizer(function (hero)
	return cargo.query('Units', "IFNULL(CONCAT(Name,': ',Title),Name)=name,WeaponType,MoveType", {
		where = ("'%s' IN (WikiName,_pageName)"):format(escq(hero)),
		groupBy = 'WikiName',

local cacheAllHeroes = function ()
	local cache = Hash.from_ipairs(cargo.query('Units', "WikiName,IFNULL(CONCAT(Name,': ',Title),Name)=name,WeaponType,MoveType", {
		groupBy = 'WikiName',
		limit = 1000,
	}), function (v) return v.WikiName, v end)
	memoizeHero = function (hero)
		return cache[hero]

-- TODO: use UnitType instead (still needs to be lua-only)
local makeHeroIconDiv = function (hero)
	-- We need to query to get the hero's weapon and move type
	local heroQuery = memoizeHero(hero)
	if not heroQuery then
		return mw.html.create('div'):css('width', '120px'):wikitext('[[' .. hero .. ']]')

	local heroIconDiv = mw.html.create('div'):css('display', 'inline-block'):css('padding', '5px 0')
	heroIconDiv:node(superimposeDiv(Util.getHeroIcon(, '90px'),
		{'[[File:Icon Class ' .. heroQuery.WeaponType .. '.png|22px|link=]]', 2, 2},
		{'[[File:Icon Move ' .. heroQuery.MoveType .. '.png|20px|link=]]', 68, 68}))
	heroIconDiv:tag('div'):css('width', '140px'):css('margin', 'auto')
		:wikitext('[[' .. .. ']]')

	return heroIconDiv

local makeEventTable = function (event, extratitle, extratext)
	local heroes =, '%s*;%s*'), function (v) return v ~= '' end)

	-- Initialize the table
	local tbl = mw.html.create('table'):addClass('wikitable'):addClass('default'):css('text-align', 'center'):css('width', '100%')

	-- Header - Name of Summoning Event
	tbl:tag('tr'):tag('th'):attr('colspan', '3'):tag('b'):wikitext(event.Name)

	-- Image of Summoning Event Banner and text link to event page
	local heroTR = tbl:tag('tr')
	heroTR:tag('td'):css('text-align', 'center'):css('width', '25%'):attr('rowspan', tostring(extratext and 4 or 3))
		:wikitext(('[[File:Banner Focus %s.png|275px]]<br/>[[%s|%s]]'):format(, ' %(Focus%)', '')), event.Page, event.Name))

	-- Table Cell w/ Summoning Event Featured Units Label
	heroTR:tag('th'):css('width', '10%'):wikitext('Featured units')

	-- Table Cell w/ Hero Icons of the Featured Units
	local heroIconTD = heroTR:tag('td'):css('width', '55%')
		:tag('div'):css('width', '100%'):css('display', 'flex'):css('justify-content', 'space-around'):css('flex-flow', 'wrap')
	for _, hero in ipairs(heroes) do
		heroIconTD:node(makeHeroIconDiv(hero):css('flex-basis', '16.666666%'))

	-- Start Date of Summoning Event
	tbl:tag('tr'):tag('th'):wikitext('Start date'):done()

	-- End Date of Summoning Event
	tbl:tag('tr'):tag('th'):wikitext('End date'):done()

	if extratext then

	return tbl

-- for Module:SummoningEventList
local table_ = function (args)
	return tostring(makeEventTable({
		Page =,
		Name =,
		DateStart = args.startDate,
		DateEnd = args.endDate,
		Units = type(args.heroes) == 'table' and table.concat(args.heroes, ';') or args.heroes,
	}, args.extratitle, args.extratext))

return require 'Module:MakeMWModule'.makeMWModule {
	cacheAllHeroes = cacheAllHeroes,
	table = table_,
	main = main, -- TODO: merge Module:SummoningFocus into here