Module:Adventure Squad Dungeon Bosses table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
No edit summary
mNo edit summary
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Adventure Squad Dungeon Bosses table
-- Module:Adventure Squad Dungeon Bosses table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 69: Line 69:
row
row
:tag('td'):wikitext(levelArg or frame:expandTemplate{title = "Research"}):done()
:tag('td'):wikitext(levelArg or frame:expandTemplate{title = "Research"}):done()
:tag('td'):wikitext(expArg or frame:expandTemplate{title = "Research"}):done()


rows
rows

Revision as of 21:11, 6 November 2024

Documentation for this module may be created at Module:Adventure Squad Dungeon Bosses table/doc

--------------------------------------------------------------------------------
--
--				Module:Adventure Squad Dungeon Bosses table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local data = require("Module:Adventure Squad 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'):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Model"):done()
			:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "AdventureSquad", args = {"Pokémon"}}):done()
			:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "AdventureSquad", args = {"Type"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "AdventureSquad", args = {"Level"}}):done()
		:tag('tr'):done()
			: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 levelArg = args["level_" .. 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 ""

		row
			:tag('tr'):done()
				:tag('th'):wikitext(frame:expandTemplate{title = "AdventureSquadModel", args = {(bossArg or ""), size = "64x64px"}}):done()
				:tag('td'):wikitext(frame:expandTemplate{title = "AdventureSquad", args = {boss, (bossArg or "")}}):done()
				:tag('td'):wikitext(data[boss]["ja"]):done()

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

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

		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