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

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 19: Line 19:
header
header
:tag('tr')
:tag('tr')
:tag('th'):attr("rowspan", "2"):cssText("width: 5%"):wikitext("Sprite"):done()
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Sprite"):done()
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Pokémon"}}):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("colspan", "2"):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Type"}}):done()
Line 25: Line 25:
: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(frame:expandTemplate{title = "ExplorersOfSky", args = {"Experience"}}):done()
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Floors"):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('th'):attr("colspan", "3"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Recruiting", "Recruit Chance"}}):done()
:tag('tr')
:tag('tr')
:tag('th'):cssText("width: 15%"):wikitext("English"):done()
:tag('th'):cssText("width: 15%"):wikitext("English"):done()
:tag('th'):cssText("width: 15%"):wikitext("Japanese"):done()
:tag('th'):cssText("width: 15%"):wikitext("Japanese"):done()
:tag('th'):cssText("width: 5%"):wikitext("Base Chance"):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("Story"):done()
:tag('th'):cssText("width: 5%"):wikitext(frame:expandTemplate{title = "Tt", args = {'Available in', 'Which version they are available.'}}):done()
:tag('th'):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "Tt", args = {'Available in', 'Which version they are available.'}}):done()


-- Data rows
-- Data rows
Line 96: Line 95:
row
row
:tag('td'):wikitext(data[monsterArg]["recruit"]):done()
: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'):wikitext(data[monsterArg]["story"]):done()
:tag('td'):cssText(verColor):wikitext(version):done()
:tag('td'):cssText(verColor):wikitext(version):done()

Revision as of 14:32, 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: 10%"):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", "3"):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: 5%"):wikitext("Story"):done()
			:tag('th'):cssText("width: 10%"):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(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