Module:RewardText

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 'x20px' 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 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				(' %s'):format(mf(reward.kind), size, reward.kind, lang:formatNum(reward.count)) or				('%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}