From Fire Emblem Heroes Wiki
Jump to: navigation, search
Template-info.svg Documentation

This module implements Template:RewardText.

Parameters[edit source]

  • 1: The reward, or list of rewards. If a single reward is specified, it should be a hash in one of the following forms:
    • {hero=;rarity=}: Provide the full name of the Hero and the rewarded rarity. This does not actually define the Hero in the database as available at that rarity.
    • {hero=;fbrank=}: Provide the rank of the Forging Bonds conversation (C / B / A / S) and the full name of the Hero.
    • {seal=}: Provide the name of the Sacred Seal.
    • {accessory=}: Provide the page name of the accessory.
    • {kind=;count=}: Provide the name of the item and the number of items rewarded (defaults to 1 if not given).
If multiple rewards are specified, this parameter should be a list of hashes representing each individual reward. The rewards are displayed as they are specified, without sorting them or merging hashes with identical items into one.
When called from other Lua modules using require 'Module:RewardText'._main(), this parameter may also be a normalized reward object, in which case ObjectArg parsing is skipped.
  • size: (Optional) Size of the item icons and Sacred Seal icons. Defaults to x20px.
  • iconfirst: (Optional) If true, displays icons before item counts.
  • or: (Optional) If true, displays / instead of + between reward items, to indicate a selection between items instead of a single reward comprising all items.
local Reward = require 'Module:Reward'
local cargo = mw.ext.cargo
local Util = require 'Module:Util'
local escq = require 'Module:EscQ'.main1
local mf = require 'Module:MF'.main1
local toboolean = require 'Module:Bool'.toboolean

local main = function (args, frame)
	local rewards, err = Reward.parse(args[1])
	if not rewards then
		return require 'Module:Error'.error(err)

	local lang = mw.language.getContentLanguage()
	local size = args.size or 'x20px'
	local iconfirst = toboolean(args.iconfirst)

	local ul = mw.html.create('span'):addClass('reward')
	if toboolean(args['or']) then

	for _, reward in ipairs(rewards) do
		local li = ul:tag('span')
		if reward.kind == 'Hero' then
			li:wikitext(frame:expandTemplate {title = 'IconFrame', args = {hero = reward.hero, rarity = reward.rarity}})
		elseif reward.kind == 'Accessory' then
			li:wikitext(frame:expandTemplate {title = 'IconFrame', args = {accessory = reward.accessory}})
		elseif reward.kind == 'Sacred Seal' then
			li:wikitext(frame:expandTemplate {title = 'SkillText', args = {reward.seal, size = size}})
		elseif reward.kind == 'Forging Bonds conversation' then
			local heroQuery = cargo.query(
				"U._pageName=page,U.Name=name,IFNULL(CONCAT(U.Name,': ',U.Title),U.Name)=fullname,FBH._pageName=fbpage", {
					join = 'FBH.Hero=U.WikiName',
					where = ("U._pageName='%s'"):format(escq(reward.hero)),
					limit = 1,
			if heroQuery then
				li:wikitext(("%s [[%s|%s]]'s [[%s#%s - %s|%s Conversation]]"):format(
					Util.getHeroIcon(reward.hero, size),,, heroQuery.fbpage, heroQuery.fullname, reward.fbrank, reward.fbrank))
				li:wikitext(("[[%s]]'s %s Conversation"):format(reward.hero, reward.fbrank))
			li:wikitext(iconfirst and
				('[[File:%s.png|%s|alt=|link=%s]] %s'):format(mf(reward.kind), size, reward.kind, lang:formatNum(reward.count)) or
				('%s [[File:%s.png|%s|alt=|link=%s]]'):format(lang:formatNum(reward.count), mf(reward.kind), size, reward.kind))

	return tostring(ul)

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