Module:Minion/MinionPageRow

local getArgs = require('Module:Arguments').getArgs local loader = require('Module:Loader')

local string, table, yesno, stringT, minionMdl = loader.require('String', 'Table', 'Yesno', 'String/Templates', 'Minion') local minionData, minionAliases = loader.loadData('Minion/Data', 'Minion/Aliases')

local minionPageRowParams = minionAliases.minionPageRowParams local arrowSymbol = '➜'

local p = {}

function p.minionPageRow(frame) local args = getArgs(frame) return mw.getCurrentFrame:preprocess(p._minionPageRow(args.name or args[1])) end

function p._minionPageRow(name) local minionName = name local minionDt = minionData[minionName] local dropsData = minionDt.drops local rightSideTable = mw.html.create('table'):addClass('wikitable') rightSideTable:tag('th'):wikitext('Condition') rightSideTable:tag('th'):wikitext('Resource') rightSideTable:tag('th'):wikitext('XP') for _, cond in ipairs(minionPageRowParams) do		if dropsData[cond.param] then local dd = dropsData[cond.param] for i, drop in ipairs(dd) do				local row = rightSideTable:tag('tr'):addClass('smalltxt') if i == 1 then row:tag('td'):attr('rowspan', table.length(dd)):wikitext(cond.condition) -- Condition end row:tag('td'):wikitext((''):format(drop.item)) -- Resource -- local experience = drop.exp and drop.exp:match('[%d,%.]+') or 0 -- row:tag('td'):wikitext(():format(experience)) -- XP				row:tag('td'):wikitext(drop.exp and ():format(drop.exp, { iconOnly = true }) or stringT.blankCell) -- XP			end end end local leftSideTable = mw.html.create('table'):addClass('wikitable') local row1 = leftSideTable:tag('tr'):attr('id', minionName) row1:tag('th'):wikitext((''):format(minionName)) row1:tag('th'):wikitext((' %s Max Tier:  '):format(minionName, minionName, string._toRoman(minionMdl._getMinionData(minionName, 'tiers')))) local row2 = leftSideTable:tag('tr'):css('height', '100%') row2:tag('td'):attr('colspan', 2):wikitext(table.concat({ minionDt.collection and (' Collection: '):format(minionDt.collection) or '', minionDt.obtaining and (' Obtaining: %s '):format(minionDt.obtaining) or '', (' Cooldown: %s%s%ss '):format(			minionMdl._getMinionData(minionName, 'time between actions', 'max'),			arrowSymbol,			minionMdl._getMinionData(minionName, 'time between actions', 1)		), (' Storage: %s%s%ss'):format(			minionMdl._getMinionData(minionName, 'storage', 'max'),			arrowSymbol,			minionMdl._getMinionData(minionName, 'storage', 1)		), }))	return table.concat({ tostring(leftSideTable), tostring(rightSideTable) }, '\n') end

function p.minionPageRowAll return mw.getCurrentFrame:preprocess(p._minionPageRowAll) end

function p._minionPageRowAll local t = {} for minionName, minionDt in pairs(minionData) do		t[minionDt.type] = t[minionDt.type] or {} table.push(t[minionDt.type], minionName) end local ret = {} for minionType, minionList in pairs(t) do		table.sort(minionList) table.push(ret, ('|-|%s=\n \n%s\n '):format(minionType, table.concat(table.map(minionList, function(v) return (''):format(v) end), '\n'))) end return table.concat(ret, '\n') end

return p