Module:Pokemon Super Mystery Dungeon Pokémon table

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 18:14, 26 January 2024 by Noirfasui (talk | contribs) (Created page with "-------------------------------------------------------------------------------- -- -- Module:Super Mystery Dungeon Dungeon Pokémon table -- -------------------------------------------------------------------------------- local p = {} local mw = require('mw') function p.main(frame) local args = frame.args local output = {} -- Header row table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">') table.insert(outpu...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

--------------------------------------------------------------------------------
--
--			Module:Super Mystery Dungeon Dungeon Pokémon table
--
--------------------------------------------------------------------------------

local p = {}
local mw = require('mw')

function p.main(frame)
	local args = frame.args
	local output = {}
	-- Header row
	table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">')
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">Model</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "SuperMysteryDungeon", args = {"Pokémon"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">Floors</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2" rowspan="2" style="width: 20%;">' .. frame:expandTemplate{title = "SuperMysteryDungeon", args = {"Type", "Types"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "SuperMysteryDungeon", args = {"Experience"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "SuperMysteryDungeon", args = {"Level"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "SuperMysteryDungeon", args = {"Recruitment rate"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">Spawn rate</th>')
	table.insert(output, '</tr>')
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" style="width: 10%;">English</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 10%;">Japanese</th>')
	table.insert(output, '</tr>')
	-- Data rows
	for i = 1, 100 do
		local pokemonArg = args["pokémon_" .. i]
		local levelArg = args["level_" .. i]
		local expArg = args["exp_" .. i]
		local recruitArg = args["recruit_" .. i]
		local spawnRateArg = args["spawnRate_" .. i]
		local floorArg = args["floor_" .. i]
		if not pokemonArg and not expArg and not recruitArg and not spawnRateArg and not floorArg then
			break -- exit loop when no more rows are found
		end
		local rowData = {}
		table.insert(rowData, '<tr class="monstersTableRow">')
		table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "SuperMysteryDungeonModel", args = {(pokemonArg or "")}} .. '</th>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "SuperMysteryDungeon", args = {(pokemonArg or "")}} .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Super Mystery Dungeon Pokémon Data Cell|superMysteryDungeonPokemonDataCell|name=' .. (pokemonArg or "") .. '|getVar=ja}}') .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (floorArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		if frame:preprocess('{{#invoke:Super Mystery Dungeon Pokémon Data Cell|superMysteryDungeonPokemonDataCell|name=' .. (pokemonArg or "") .. '|getVar=type2}}') ~= "" then
			table.insert(rowData, '<th class="templatePrimary">' .. fragame:preprocess('{{TypePKMN|{{#invoke:Super Mystery Dungeon Pokémon Data Cell|superMysteryDungeonPokemonDataCell|name=' .. (pokemonArg or "") .. '|getVar=type1}}}}') .. '</th>')
			table.insert(rowData, '<th class="templatePrimary">' .. frame:preprocess('{{TypePKMN|{{#invoke:Super Mystery Dungeon Pokémon Data Cell|superMysteryDungeonPokemonDataCell|name=' .. (pokemonArg or "") .. '|getVar=type2}}}}') .. '</th>')
		else
			table.insert(rowData, '<th class="templatePrimary" colspan="2">' .. frame:preprocess('{{TypePKMN|{{#invoke:Super Mystery Dungeon Pokémon Data Cell|superMysteryDungeonPokemonDataCell|name=' .. (pokemonArg or "") .. '|getVar=type1}}}}') .. '</th>')
		end
		table.insert(rowData, '<td class="templateSecondary">' .. (expArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (levelArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (recruitArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. (spawnRateArg or frame:expandTemplate{title = "Research"}) .. '</td>')
		table.insert(rowData, '</tr>')
		table.insert(output, table.concat(rowData))
	end
	table.insert(output, '</table>')
	return table.concat(output)
end

return p