Module:Shiren 1 SFC Monsters List

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search

Documentation for this module may be created at Module:Shiren 1 SFC Monsters List/doc

--------------------------------------------------------------------------------
--
--					Module:Shiren 1 SFC Monsters List
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local data = require("Module:Shiren 1 SFC Monster 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'):done()
			:tag('th'):attr("rowspan", "2"):attr("colspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "Shiren1SFC", args = {"Type"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "Shiren1SFC", args = {"Level"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Sprite"):done()
			:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "Shiren1SFC", args = {"Monster"}}):done()
		:tag('tr'):done()
			:tag('th'):cssText("width: 25%"):wikitext("English"):done()
			:tag('th'):cssText("width: 25%"):wikitext("Japanese"):done()

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

	while true do
		local row = mw.html.create()
		local monsterArg = args["monster_" .. i]

		if not monsterArg then
			break -- exit loop when no more rows are found
		end

		local type1 = data[monsterArg]["type1"] or ""
		local type2 = data[monsterArg]["type2"] or ""

		row
			:tag("tr"):done()
		
		if type2 == "" then
			row
				:tag("td"):attr("colspan", "2"):wikitext(data[monsterArg]["type1"]):done()
		else
			row
				:tag("td"):wikitext(data[monsterArg]["type1"]):done()
				:tag("td"):wikitext(data[monsterArg]["type2"]):done()
		end

		row
			:tag("td"):wikitext(data[monsterArg]["level"]):done()
			:tag("th"):wikitext(frame:expandTemplate{title = "Shiren1SFCSprite", args = {(monsterArg or ""), size = "50x50px"}}):done()
			:tag("td"):wikitext(frame:expandTemplate{title = "Shiren1SFC", args = {(monsterArg or "")}}):done()
			:tag("td"):wikitext(data[monsterArg]["ja"]):done()

		rows
			:node(row)
			:allDone()

		i = i + 1
	end

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

return p