Module:Explorers of Sky Dungeon Bosses table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 103: Line 103:
if typeTwo == nil or typeTwo == '' then
if typeTwo == nil or typeTwo == '' then
row
row
:tag('td'):attr("rowspan", #countMoves):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}}):done()
:tag('th'):attr("rowspan", #countMoves):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}}):done()
else
else
row
row
:tag('td'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}}):done()
:tag('th'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}}):done()
:tag('td'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeTwo}}):done()
:tag('th'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeTwo}}):done()
end
end



Latest revision as of 20:56, 7 February 2025

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

--------------------------------------------------------------------------------
--
--					Module:Explorers of Sky Dungeon Bosses table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local data = require("Module:Explorers of Sky Boss 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: 15%"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Recruiting", "Recruit Chance"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 15%"):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {"Move"}}):done()
		:tag('tr')
			:tag('th'):cssText("width: 15%"):wikitext("English"):done()
			:tag('th'):cssText("width: 15%"):wikitext("Japanese"):done()

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

	while true do
		local row = mw.html.create()
		local bossArg = args["boss_" .. i]
		local caseArg = args["case_" .. i]
		local levelArg = args["level_" .. i]
		local expArg = args["exp_" .. i]
		local recruitableArg = args["recruitable_" .. i]

		if not bossArg and not caseArg and not recruitableArg and not expArg and not levelArg then
			break -- exit loop when no more rows are found
		end

		-- Case
		local boss = (bossArg or "")

		if not (caseArg == '') and not (caseArg == nil) then
			boss = boss .. " (boss - " .. string.lower(caseArg) .. ")"
		else
			boss = boss .. " (boss)"
		end

		local typeOne = data[boss]["type1"] or ""
		local typeTwo = data[boss]["type2"] or ""

		-- Count moves
		local moveOne = data[boss]["move1"] or ""
		local moveTwo = data[boss]["move2"] or ""
		local moveThree = data[boss]["move3"] or ""
		local moveFour = data[boss]["move4"] or ""
		local moveFive = data[boss]["move5"] or ""
		local moveSix = data[boss]["move6"] or ""
		local moveSeven = data[boss]["move7"] or ""
		local moveEight = data[boss]["move8"] or ""
		local moveNine = data[boss]["move9"] or ""
		local countMoves = {moveOne}

		if not (moveTwo == '') and not (moveTwo == nil) then
			table.insert(countMoves, moveTwo)
		end
		if not (moveThree == '') and not (moveThree == nil) then
			table.insert(countMoves, moveThree)
		end
		if not (moveFour == '') and not (moveFour == nil) then
			table.insert(countMoves, moveFour)
		end
		if not (moveFive == '') and not (moveFive == nil) then
			table.insert(countMoves, moveFive)
		end
		if not (moveSix == '') and not (moveSix == nil) then
			table.insert(countMoves, moveSix)
		end
		if not (moveSeven == '') and not (moveSeven == nil) then
			table.insert(countMoves, moveSeven)
		end
		if not (moveEight == '') and not (moveEight == nil) then
			table.insert(countMoves, moveEight)
		end
		if not (moveNine == '') and not (moveNine == nil) then
			table.insert(countMoves, moveNine)
		end

		row
			:tag('tr'):done()
				:tag('th'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "ExplorersOfSkySprite", args = {(bossArg or ""), size = "50x50px"}}):done()
				:tag('td'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {boss, (bossArg or "")}}):done()
				:tag('td'):attr("rowspan", #countMoves):wikitext(data[boss]["ja"]):done()

		if typeTwo == nil or typeTwo == '' then
			row
				:tag('th'):attr("rowspan", #countMoves):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}}):done()
		else
			row
				:tag('th'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeOne}}):done()
				:tag('th'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "ExplorersOfSkyType", args = {typeTwo}}):done()
		end

		row
			:tag('td'):attr("rowspan", #countMoves):wikitext(levelArg or frame:expandTemplate{title = "Research"}):done()
			:tag('td'):attr("rowspan", #countMoves):wikitext(expArg 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("rowspan", #countMoves):wikitext("Unrecruitable"):done()
		else
			row
				:tag('td'):attr("rowspan", #countMoves):wikitext(data[boss]["recruit"]):done()
		end

		row
			:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {moveOne}}):done()
		
		if not (moveTwo == '') and not (moveTwo == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {moveTwo}}):done()
		end
		if not (moveThree == '') and not (moveThree == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {moveThree}}):done()
		end
		if not (moveFour == '') and not (moveFour == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {moveFour}}):done()
		end
		if not (moveFive == '') and not (moveFive == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {moveFive}}):done()
		end
		if not (moveSix == '') and not (moveSix == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {moveSix}}):done()
		end
		if not (moveSeven == '') and not (moveSeven == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {moveSeven}}):done()
		end
		if not (moveEight == '') and not (moveEight == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {moveEight}}):done()
		end
		if not (moveNine == '') and not (moveNine == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "ExplorersOfSky", args = {moveNine}}):done()
		end

		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