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
No edit summary
Line 44: Line 44:
local recruitableArg = args["recruitable_" .. i]
local recruitableArg = args["recruitable_" .. i]


if not bossArg and not caseArg and not recruitableArg and not expArg and not levelArg then
if not boss 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
local typeOne = data[bossArg]["type1"] or ""
local typeTwo = data[bossArg]["type2"] or ""


-- Case
-- Case
Line 59: Line 56:
boss = boss .. " (boss)"
boss = boss .. " (boss)"
end
end
local typeOne = data[boss]["type1"] or ""
local typeTwo = data[boss]["type2"] or ""


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


Line 99: Line 99:
row
row
:tag('tr'):done()
:tag('tr'):done()
:tag('th'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "RescueTeamSprite", args = {(bossArg or ""), size = "64x64px"}}):done()
:tag('th'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "RescueTeamSprite", args = {(boss 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(frame:expandTemplate{title = "RescueTeam", args = {boss, (boss or "")}}):done()
:tag('td'):attr("rowspan", #countMoves):wikitext(data[bossArg]["ja"]):done()
:tag('td'):attr("rowspan", #countMoves):wikitext(data[boss]["ja"]):done()


if typeTwo == nil or typeTwo == '' then
if typeTwo == nil or typeTwo == '' then
Line 121: Line 121:
else
else
row
row
:tag('td'):attr("rowspan", #countMoves):wikitext(data[bossArg]["recruit"]):done()
:tag('td'):attr("rowspan", #countMoves):wikitext(data[boss]["recruit"]):done()
:tag('td'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "RescueTeam", args = {data[bossArg]["friendArea"]}}):done()
:tag('td'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "RescueTeam", args = {data[boss]["friendArea"]}}):done()
end
end



Revision as of 19:17, 12 October 2024

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 boss 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 = "RescueTeamSprite", args = {(boss or ""), size = "64x64px"}}):done()
				:tag('td'):attr("rowspan", #countMoves):wikitext(frame:expandTemplate{title = "RescueTeam", args = {boss, (boss 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("MDWiki"):cssText("text-align: center; margin: auto; width: 50%;")
			:node(header)
			:node(rows)
	return tostring(output)

end

return p