Module:Sandbox

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 09:44, 14 March 2024 by Deleca7755 (talk | contribs) (é)
Jump to navigation Jump to search



--------------------------------------------------------------------------------
--
--				Module:Rescue Team DX Dungeon Fainted Pokémon table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local data = require("Module:Sandbox/test")
	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'):addClass("templatePrimary"):attr("rowspan", "2" ):cssText("width: 10%"):wikitext("Sprite"):done()
			:tag('th'):addClass("templatePrimary"):attr("colspan", "2" ):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Pokémon"}}):done()
			:tag('th'):addClass("templatePrimary"):attr("colspan", "2" ):attr("rowspan", "2" ):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Types"}}):done()
			:tag('th'):addClass("templatePrimary"):attr("rowspan", "2" ):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Level"}}):done()
			:tag('th'):addClass("templatePrimary"):attr("rowspan", "2" ):cssText("width: 10%"):wikitext("Floors"):done()
			:tag('td'):wikitext(recruit)
		:tag('tr')
			:tag('th'):addClass("templatePrimary"):cssText("width: 25%"):wikitext("English"):done()
			:tag('th'):addClass("templatePrimary"):cssText("width: 25%"):wikitext("Japanese"):done()

	-- Data rows
	local rows = mw.html.create()
	for i = 1, 150 do
		local row = mw.html.create()
		local monsterArg = args["pokémon_" .. i]
		local floorsArg = args["floors_" .. i]
		local levelArg = args["level_" .. i]
		if not monsterArg and not floorsArg 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 ""
		row
			:tag("tr"):addClass("monstersTableRow"):done()
			:tag("th"):addClass("templatePrimary"):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "50x50px"}}):done()
			:tag("td"):addClass("templateSecondary"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}})
			:tag("td"):addClass("templateSecondary"):wikitext(data[monsterArg]["ja"])
			
		if typeTwo == nil or typeTwo == '' then
			row
				:tag('td'):addClass("templatePrimary"):attr("colspan", "2" ):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}}):done()
		else
			row
				:tag('td'):addClass("templatePrimary"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}}):done()
				:tag('td'):addClass("templatePrimary"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {typeTwo}}):done()

		end
			row
				:tag("td"):addClass("templateSecondary"):wikitext(levelArg or ""):done()
				:tag("td"):addClass("templateSecondary"):wikitext(floorsArg or ""):done()
		rows
			:node(row)
			:allDone()
			
	end
		
		output
			:tag('table'):addClass("templateTheme"):cssText("text-align: center; margin: auto; width: 50%")
				:node(header)
				:node(rows)
		return  tostring(output)

end

return p