Module:Explorers of Sky Dungeon Pokémon table

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 20:15, 18 January 2024 by Adkuate (talk | contribs) (Created page with "-------------------------------------------------------------------------------- -- -- Module:Explorers of Sky 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: 66%;">') table.insert(output, '...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Explorers of Sky Dungeon Pokémon table/doc

--------------------------------------------------------------------------------
--
--				Module:Explorers of Sky 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: 66%;">')
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 5%;">Sprite</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {"Pokémon"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {"Types"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {"Level"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {"Experience"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">Floors</th>')
	table.insert(output, '<th class="templatePrimary" colspan="4">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {"Recruiting", "Recruitment"}} .. '</th>')
	table.insert(output, '</tr>')
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" style="width: 15%;">English</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 15%;">Japanese</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 5%;">Base Chance</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 10%;">Friend Area</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 5%;">Story</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 5%;">' .. frame:expandTemplate{title = "Tt", args = {'Available in', 'Which version they are available.'}} .. '</th>')
	table.insert(output, '</tr>')
	-- Data rows
	for i = 1, 150 do
		local monsterArg = args["pokémon_" .. i]
		local floorsArg = args["floors_" .. i]
		local levelArg = args["level_" .. i]
		local expArg = args["exp_" .. i]
		local recruitableArg = args["recruitable_" .. i]
		if not monsterArg and not floorsArg and not recruitableArg and not expArg and not levelArg then
			break -- exit loop when no more rows are found
		end
		local typeOne = frame:preprocess('{{#invoke:Explorers of Sky Pokémon Data Cell|explorersOfSkyPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=type1}}')
		local typeTwo = frame:preprocess('{{#invoke:Explorers of Sky Pokémon Data Cell|explorersOfSkyPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=type2}}')
		local version = frame:preprocess('{{#invoke:Explorers of Sky Pokémon Data Cell|explorersOfSkyPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=version}}')
		local verColor = ""
		if version == "Red" then
			verColor = 'style="background-color: orangered;"'
		elseif version == "Blue" then
			verColor = 'style="background-color: cornflowerblue;"'
		end
		local rowData = {}
		table.insert(rowData, '<tr class="monstersTableRow">')
		table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "ExplorersOfSkySprite", args = {(monsterArg or "")}} .. '</th>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {(monsterArg or "")}} .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Explorers of Sky Pokémon Data Cell|explorersOfSkyPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=ja}}') .. '</td>')
		if typeTwo == nil or typeTwo == '' then
			table.insert(rowData, '<td class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}} .. '</td>')
		else
			table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}} .. '</td>')
			table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeTwo}} .. '</td>')
		end
		table.insert(rowData, '<td class="templateSecondary">' .. (levelArg or "Unrecruitable") .. '</td>')
		if expArg == "" or expArg == " " then
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
		else
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Tt", args = {expArg, frame:preprocess('{{#expr:' .. expArg .. '/2 round 0}}') .. ' if K.O.\'d without using a move.'}} .. '</td>')
		end
		table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or "") .. '</td>')
		if recruitableArg == "false" or recruitableArg == "False" or recruitableArg == "no" then
			table.insert(rowData, '<td class="templateSecondary" colspan="4">Unrecruitable</td>')
		else
			table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Explorers of Sky Pokémon Data Cell|explorersOfSkyPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=recruit}}') .. '</td>')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {frame:preprocess('{{#invoke:Explorers of Sky Pokémon Data Cell|explorersOfSkyPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=friendArea}}')}} .. '</td>')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Explorers of Sky Pokémon Data Cell|explorersOfSkyPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=story}}') .. '</td>')
			table.insert(rowData, '<td class="templateSecondary" ' .. (verColor or "") .. '>' .. version .. '</td>')
		end
		table.insert(rowData, '</tr>')
		table.insert(output, table.concat(rowData))
	end
	table.insert(output, '</table>')
	return table.concat(output)
end

return p