Module:CompileCombatManuals

local List = require 'Module:ListUtil' local Datetime = require 'Module:DatetimeUtil' local parseObj = require 'Module:ObjectArg'.parse local toboolean = require 'Module:Bool'.toboolean

local STYLES = {display = 'inline-block', ['vertical-align'] = 'middle', margin = '.5em'}

local targets = function (args, frame) local item = args.item local startTime = args.start local endTime = args['end'] local isPath = toboolean(args.path) local manuals, err = parseObj(args.manuals) if err then return require 'Module:Error'.error(err) end

local tr = mw.html.create('tr')

-- item local td = tr:tag('td') td:wikitext(frame:expandTemplate {title = 'ItemText', args = {item}})

-- availability td = tr:tag('td') td:wikitext(Datetime.ht_range(startTime, endTime))

-- manuals td = tr:tag('td') local lastUnit = nil td:wikitext(table.concat(List.map(manuals, function (manual)		local div = mw.html.create('div'):css(STYLES)		div:wikitext(frame:expandTemplate {title = 'IconFrame', args = {hero = manual.unit, rarity = manual.rarity}})		div:wikitext(' ')		div:wikitext(mw.language.getContentLanguage:formatNum(tonumber(manual.cost)))		div:wikitext(frame:expandTemplate {title = 'CombatManualTarget', args = { unit = manual.unit, rarity = manual.rarity, currency = item, cost = manual.cost, prereq = lastUnit, start = startTime, ['end'] = endTime, }})		if isPath then			lastUnit = manual.unit		end		return tostring(div)	end), isPath and " → " or ' '))

return tostring(tr) end

return require 'Module:MakeMWModule'.makeMWModule { targets = targets, }