Module:Rescue Team 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
 
(3 intermediate revisions by the same user not shown)
Line 44: Line 44:
local recruitableArg = args["recruitable_" .. i]
local recruitableArg = args["recruitable_" .. i]


if not boss and not caseArg and not recruitableArg and not expArg and not levelArg then
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
break -- exit loop when no more rows are found
end
end
Line 51: Line 51:
local boss = (bossArg or "")
local boss = (bossArg or "")


if caseArg.lower() == 'dojo' then
if not (caseArg == '') and not (caseArg == nil) then
boss = boss .. " (dojo)"
if string.lower(caseArg) == 'dojo' then
elseif not (caseArg == '') and not (caseArg == nil) then
boss = boss .. " (dojo)"
boss = boss .. " (boss - " .. string.lower(caseArg) .. ")"
else
boss = boss .. " (boss - " .. string.lower(caseArg) .. ")"
end
else
else
boss = boss .. " (boss)"
boss = boss .. " (boss)"
Line 179: Line 181:


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

Latest revision as of 09:41, 26 January 2025

Documentation for this module may be created at Module:Rescue Team Dungeon Bosses table/doc

--------------------------------------------------------------------------------
--
--					Module:Rescue Team Dungeon Bosses table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local data = require("Module:Rescue Team 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 = "RescueTeam", args = {"Pokémon"}}):done()
			:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "RescueTeam", args = {"Type"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "RescueTeam", args = {"Level"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "RescueTeam", args = {"Experience"}}):done()
			:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "RescueTeam", args = {"Recruiting", "Recruit Chance"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "RescueTeam", args = {"Move"}}):done()
		:tag('tr')
			:tag('th'):cssText("width: 15%"):wikitext("English"):done()
			:tag('th'):cssText("width: 15%"):wikitext("Japanese"):done()
			:tag('th'):cssText("width: 10%"):wikitext("Base Chance"):done()
			:tag('th'):cssText("width: 10%"):wikitext("Friend Area"):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
			if string.lower(caseArg) == 'dojo' then
				boss = boss .. " (dojo)"
			else
				boss = boss .. " (boss - " .. string.lower(caseArg) .. ")"
			end
		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 = "RescueTeamSprite", args = {(bossArg or ""), size = "64x64px"}}):done()
				:tag('td'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "RescueTeam", 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 = "RescueTeamType", args = {typeOne}}):done()
		else
			row
				:tag('th'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "RescueTeamType", args = {typeOne}}):done()
				:tag('th'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "RescueTeamType", 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):attr("colspan", "2"):wikitext("Unrecruitable"):done()
		else
			row
				:tag('td'):attr("rowspan", #countMoves):wikitext(data[boss]["recruit"]):done()
				:tag('td'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "RescueTeam", args = {data[boss]["friendArea"]}}):done()
		end

		row
			:tag('td'):wikitext(frame:expandTemplate{title = "RescueTeam", args = {moveOne}}):done()
		
		if not (moveTwo == '') and not (moveTwo == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "RescueTeam", args = {moveTwo}}):done()
		end
		if not (moveThree == '') and not (moveThree == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "RescueTeam", args = {moveThree}}):done()
		end
		if not (moveFour == '') and not (moveFour == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "RescueTeam", args = {moveFour}}):done()
		end
		if not (moveFive == '') and not (moveFive == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "RescueTeam", args = {moveFive}}):done()
		end
		if not (moveSix == '') and not (moveSix == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "RescueTeam", args = {moveSix}}):done()
		end
		if not (moveSeven == '') and not (moveSeven == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "RescueTeam", args = {moveSeven}}):done()
		end
		if not (moveEight == '') and not (moveEight == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "RescueTeam", args = {moveEight}}):done()
		end
		if not (moveNine == '') and not (moveNine == nil) then
			row
				:tag('tr')
					:tag('td'):wikitext(frame:expandTemplate{title = "RescueTeam", 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