Module:Explorers of Sky Dungeon Pokémon table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
(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, '...")
 
No edit summary
Line 9: Line 9:


function p.main(frame)
function p.main(frame)
local data = require("Module:Explorers of Sky Pokémon Data Cell")
local metatable = {__index = function () return "" end}
setmetatable(data, metatable)
local args = frame.args
local args = frame.args
local output = {}
 
local output = mw.html.create()
local header = mw.html.create()
-- Header row
-- Header row
table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 66%;">')
header
table.insert(output, '<tr>')
:tag('tr')
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 5%;">Sprite</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 5%"):wikitext("Sprite"):done()
table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {"Pokémon"}} .. '</th>')
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Pokémon"}}):done()
table.insert(output, '<th class="templatePrimary" colspan="2" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {"Types"}} .. '</th>')
:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Type"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {"Level"}} .. '</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Level"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {"Experience"}} .. '</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Experience"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">Floors</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Floors"):done()
table.insert(output, '<th class="templatePrimary" colspan="4">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {"Recruiting", "Recruitment"}} .. '</th>')
:tag('th'):attr("colspan", "4"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Recruiting", "Recruit Chance"}}):done()
table.insert(output, '</tr>')
:tag('tr')
table.insert(output, '<tr>')
:tag('th'):cssText("width: 15%"):wikitext("English"):done()
table.insert(output, '<th class="templatePrimary" style="width: 15%;">English</th>')
:tag('th'):cssText("width: 15%"):wikitext("Japanese"):done()
table.insert(output, '<th class="templatePrimary" style="width: 15%;">Japanese</th>')
:tag('th'):cssText("width: 5%"):wikitext("Base Chance"):done()
table.insert(output, '<th class="templatePrimary" style="width: 5%;">Base Chance</th>')
:tag('th'):cssText("width: 10%"):wikitext("Friend Area"):done()
table.insert(output, '<th class="templatePrimary" style="width: 10%;">Friend Area</th>')
:tag('th'):cssText("width: 5%"):wikitext("Story"):done()
table.insert(output, '<th class="templatePrimary" style="width: 5%;">Story</th>')
:tag('th'):cssText("width: 5%"):wikitext(frame:expandTemplate{title = "Tt", args = {'Available in', 'Which version they are available.'}}):done()
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
-- Data rows
for i = 1, 150 do
local rows = mw.html.create()
local i = 1
 
while true do
local row = mw.html.create()
local monsterArg = args["pokémon_" .. i]
local monsterArg = args["pokémon_" .. i]
local floorsArg = args["floors_" .. i]
local floorsArg = args["floors_" .. i]
Line 37: Line 45:
local expArg = args["exp_" .. i]
local expArg = args["exp_" .. i]
local recruitableArg = args["recruitable_" .. i]
local recruitableArg = args["recruitable_" .. i]
if not monsterArg and not floorsArg and not recruitableArg and not expArg and not levelArg then
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
break -- exit loop when no more rows are found
end
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 typeOne = data[monsterArg]["type1"] or ""
local version = frame:preprocess('{{#invoke:Explorers of Sky Pokémon Data Cell|explorersOfSkyPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=version}}')
local typeTwo = data[monsterArg]["type2"] or ""
local version = data[monsterArg]["version"] or ""
local verColor = ""
local verColor = ""
if version == "Red" then
 
verColor = 'style="background-color: orangered;"'
if string.lower(version) == "red" then
elseif version == "Blue" then
verColor = 'background-color: orangered'
verColor = 'style="background-color: cornflowerblue;"'
elseif string.lower(version) == "blue" then
verColor = 'background-color: cornflowerblue'
end
end
local rowData = {}
 
table.insert(rowData, '<tr class="monstersTableRow">')
row
table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "ExplorersOfSkySprite", args = {(monsterArg or "")}} .. '</th>')
:tag('tr'):done()
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "ExplorersOfSky", args = {(monsterArg or "")}} .. '</td>')
:tag('th'):wikitext(frame:expandTemplate{title = "ExplorersOfSkySprite", args = {(monsterArg or ""), size = "50x50px"}}):done()
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Explorers of Sky Pokémon Data Cell|explorersOfSkyPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=ja}}') .. '</td>')
:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {(monsterArg or "")}}):done()
:tag('td'):wikitext(data[monsterArg]["ja"]):done()
if typeTwo == nil or typeTwo == '' then
if typeTwo == nil or typeTwo == '' then
table.insert(rowData, '<td class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}} .. '</td>')
row
:tag('td'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}}):done()
else
else
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}} .. '</td>')
row
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeTwo}} .. '</td>')
:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}}):done()
:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeTwo}}):done()
end
end
table.insert(rowData, '<td class="templateSecondary">' .. (levelArg or "Unrecruitable") .. '</td>')
 
if expArg == "" or expArg == " " then
row
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "Research"} .. '</td>')
:tag('td'):wikitext(levelArg or frame:expandTemplate{title = "Research"}):done()
 
if expArg == nil or expArg == '' then
row
:tag('td'):wikitext(frame:expandTemplate{title = "Research"}):done()
else
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>')
row
:tag('td'):wikitext(frame:expandTemplate{title = "Tt", args = {expArg, frame:preprocess('{{#expr:' .. expArg .. '/2 round 0}}') .. ' if K.O.\'d without using a move.'}}):done()
end
end
table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or "") .. '</td>')
 
if recruitableArg == "false" or recruitableArg == "False" or recruitableArg == "no" then
row
table.insert(rowData, '<td class="templateSecondary" colspan="4">Unrecruitable</td>')
:tag('td'):wikitext(floorsArg or frame:expandTemplate{title = "Research"}):done()
 
if recruitableArg == nil or recruitableArg == '' or string.lower(recruitableArg) == "false" or string.lower(recruitableArg) == "no" then
row
:tag('td'):attr("colspan", "4"):wikitext("Unrecruitable"):done()
else
else
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Explorers of Sky Pokémon Data Cell|explorersOfSkyPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=recruit}}') .. '</td>')
row
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>')
:tag('td'):wikitext(data[monsterArg]["recruit"]):done()
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Explorers of Sky Pokémon Data Cell|explorersOfSkyPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=story}}') .. '</td>')
:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {data[monsterArg]["friendArea"]}}):done()
table.insert(rowData, '<td class="templateSecondary" ' .. (verColor or "") .. '>' .. version .. '</td>')
:tag('td'):wikitext(data[monsterArg]["story"]):done()
:tag('td'):cssText(verColor):wikitext(version):done()
end
end
table.insert(rowData, '</tr>')
 
table.insert(output, table.concat(rowData))
rows
:node(row)
:allDone()
 
i = i + 1
end
end
table.insert(output, '</table>')
 
return table.concat(output)
output
:tag('table'):addClass("MDWiki"):cssText("text-align: center; margin: auto; width: 50%;")
:node(header)
:node(rows)
return tostring(output)
 
end
end


return p
return p

Revision as of 14:29, 4 August 2024

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 data = require("Module:Explorers of Sky Pokémon Data Cell")
	local metatable = {__index = function () return "" end}
	setmetatable(data, metatable)
	local args = frame.args

	local output = mw.html.create()
	local header = mw.html.create()
	-- Header row
	header
		:tag('tr')
			:tag('th'):attr("rowspan", "2"):cssText("width: 5%"):wikitext("Sprite"):done()
			:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Pokémon"}}):done()
			:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Type"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Level"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Experience"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Floors"):done()
			:tag('th'):attr("colspan", "4"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Recruiting", "Recruit Chance"}}):done()
		:tag('tr')
			:tag('th'):cssText("width: 15%"):wikitext("English"):done()
			:tag('th'):cssText("width: 15%"):wikitext("Japanese"):done()
			:tag('th'):cssText("width: 5%"):wikitext("Base Chance"):done()
			:tag('th'):cssText("width: 10%"):wikitext("Friend Area"):done()
			:tag('th'):cssText("width: 5%"):wikitext("Story"):done()
			:tag('th'):cssText("width: 5%"):wikitext(frame:expandTemplate{title = "Tt", args = {'Available in', 'Which version they are available.'}}):done()

	-- Data rows
	local rows = mw.html.create()
	local i = 1

	while true do
		local row = mw.html.create()
		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 = data[monsterArg]["type1"] or ""
		local typeTwo = data[monsterArg]["type2"] or ""
		local version = data[monsterArg]["version"] or ""
		local verColor = ""

		if string.lower(version) == "red" then
			verColor = 'background-color: orangered'
		elseif string.lower(version) == "blue" then
			verColor = 'background-color: cornflowerblue'
		end

		row
			:tag('tr'):done()
				:tag('th'):wikitext(frame:expandTemplate{title = "ExplorersOfSkySprite", args = {(monsterArg or ""), size = "50x50px"}}):done()
				:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {(monsterArg or "")}}):done()
				:tag('td'):wikitext(data[monsterArg]["ja"]):done()
	
		if typeTwo == nil or typeTwo == '' then
			row
				:tag('td'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}}):done()
		else
			row
				:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}}):done()
				:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeTwo}}):done()
		end

		row
			:tag('td'):wikitext(levelArg or frame:expandTemplate{title = "Research"}):done()

		if expArg == nil or expArg == '' then
			row
				:tag('td'):wikitext(frame:expandTemplate{title = "Research"}):done()
		else
			row
				:tag('td'):wikitext(frame:expandTemplate{title = "Tt", args = {expArg, frame:preprocess('{{#expr:' .. expArg .. '/2 round 0}}') .. ' if K.O.\'d without using a move.'}}):done()
		end

		row
			:tag('td'):wikitext(floorsArg or frame:expandTemplate{title = "Research"}):done()

		if recruitableArg == nil or recruitableArg == '' or string.lower(recruitableArg) == "false" or string.lower(recruitableArg) == "no" then
			row
				:tag('td'):attr("colspan", "4"):wikitext("Unrecruitable"):done()
		else
			row
				:tag('td'):wikitext(data[monsterArg]["recruit"]):done()
				:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {data[monsterArg]["friendArea"]}}):done()
				:tag('td'):wikitext(data[monsterArg]["story"]):done()
				:tag('td'):cssText(verColor):wikitext(version):done()
		end

		rows
			:node(row)
			:allDone()

		i = i + 1
	end

	output
		:tag('table'):addClass("MDWiki"):cssText("text-align: center; margin: auto; width: 50%;")
			:node(header)
			:node(rows)
	return tostring(output)

end

return p