Module:Sandbox/MonkeysHK/4

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

local string, table, yesno, minionMdl = loader.require('String', 'Table', 'Yesno', '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)) end

function p._minionPageRow(args) local minionName = args.name local minionDt = minionData[minionName] local dropsData = minionDt.drops local rightSideTable = mw.html.create('table'):addClass('wikitable table-margin-off') 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			end end end local row1 = mw.html.create('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')))) row1:tag('td'):addClass('table-margin-off'):attr('rowspan', 2):node(rightSideTable) local row2 = mw.html.create('tr') row2:tag('td'):attr('colspan', 2):wikitext(table.concat({ args.collection and (' Collection: '):format(args.collection) or '', args.obtaining and (' Obtaining: %s '):format(args.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 tostring(row1) .. tostring(row2) end

return p