This module implements Template:RewardText.
Parameters[]
- 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 x26px.
- 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.
The above documentation is transcluded from Module:RewardText/doc. (edit | history)
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)
end
local lang = mw.language.getContentLanguage()
local size = args.size or 'x26px'
local iconfirst = toboolean(args.iconfirst)
local ul = mw.html.create('span'):addClass('reward')
if toboolean(args['or']) then
ul:addClass('or')
end
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(
'ForgingBondsHeroes=FBH,Units=U',
"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,
})[1]
if heroQuery then
li:wikitext(("%s [[%s|%s]]'s [[%s#%s - %s|%s Conversation]]"):format(
Util.getHeroIcon(reward.hero, size), heroQuery.page, heroQuery.name, heroQuery.fbpage, heroQuery.fullname, reward.fbrank, reward.fbrank))
else
li:wikitext(("[[%s]]'s %s Conversation"):format(reward.hero, reward.fbrank))
end
else
li:wikitext(iconfirst and
('[[File:%s.png|%s|class=inline-icon|alt=|link=%s]] %s'):format(mf(reward.kind), size, reward.kind, lang:formatNum(reward.count)) or
('%s [[File:%s.png|%s|class=inline-icon|alt=|link=%s]]'):format(lang:formatNum(reward.count), mf(reward.kind), size, reward.kind))
end
end
return tostring(ul)
end
return require 'Module:MakeMWModule'.makeMWModule {main = main}