Module:Explorers of Sky Dungeon Bosses table

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 19:24, 17 January 2024 by Adkuate (talk | contribs) (Created page with "-------------------------------------------------------------------------------- -- -- Module:Explorers of Sky Dungeon Bosses table -- -------------------------------------------------------------------------------- local p = {} local mw = require('mw') function p.main(frame) local args = frame.args local output = {} -- Header row table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">') table.insert(output, '<t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 args = frame.args
	local output = {}
	-- Header row
	table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">')
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%">Sprite</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "explorersOfSky", args = {"Bosses"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" colspan="2" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "explorersOfSky", args = {"Types"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "explorersOfSky", args = {"Level"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "explorersOfSky", args = {"Recruiting", "Recruit Chance"}} .. '</th>')
	table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 20%">' .. frame:expandTemplate{title = "explorersOfSky", args = {"Moves"}} .. '</th>')
	table.insert(output, '</tr>')
	table.insert(output, '<tr>')
	table.insert(output, '<th class="templatePrimary" style="width: 20%;">English</th>')
	table.insert(output, '<th class="templatePrimary" style="width: 20%;">Japanese</th>')
	table.insert(output, '</tr>')
	-- Data rows
	for i = 1, 100 do
		local bossArg = args["boss_" .. i]
		local caseArg = args["case_" .. i]
		local levelArg = args["level_" .. i]
		local recruitableArg = args["recruitable_" .. i]
		
		if not bossArg and not caseArg and not levelArg and not recruitableArg then
			break -- exit loop when no more rows are found
		end
		
		-- Sprite
		local sprite = (bossArg or "")
		if bossArg == "Mankey Gang" then
			sprite = "Mankey"
		end
		
		-- Case
		local boss = (bossArg or "")
		if caseArg == "post-credits" then
			boss = boss .. " (boss - post-credits)"
		end
		
		-- Count moves
		local moveOne = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=move1}}')
		local moveTwo = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=move2}}')
		local moveThree = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=move3}}')
		local moveFour = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=move4}}')
		local moveFive = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=move5}}')
		local moveSix = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=move6}}')
		local moveSeven = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=move7}}')
		local moveEight = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=move8}}')
		local moveNine = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=move9}}')
		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
		
		-- Types
		local typeOne = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=type1}}')
		local typeTwo = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=type2}}')
		
		-- Recruitable
		local recruitable = (recruitableArg or "")
		if recruitable:lower() == "false" then
			recruitable = "Unrecruitable"
		else
			recruitable = frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. boss .. '|getVar=recruit}}')
		end
		
		local rowData = {}
		table.insert(rowData, '<tr class="bossesTableRow">')
		table.insert(rowData, '<th class="templatePrimary" rowspan="' .. #countMoves .. '">' .. frame:expandTemplate{title = "explorersOfSkySprite", args = {sprite}} ..'</th>')
		if caseArg then
			table.insert(rowData, '<td class="templateSecondary" rowspan="' .. #countMoves .. '">' .. frame:expandTemplate{title = "explorersOfSky", args = {(bossArg or "") .. ' (boss - ' .. (caseArg or "") .. ')', (bossArg or "")}} .. '<br>(' .. caseArg .. ')</td>')
		else
			table.insert(rowData, '<td class="templateSecondary" rowspan="' .. #countMoves .. '">' .. frame:expandTemplate{title = "explorersOfSky", args = {(bossArg or "") .. ' (boss)', (bossArg or "")}} .. '</td>')
		end
		table.insert(rowData, '<td class="templateSecondary" rowspan="' .. #countMoves .. '">' .. frame:preprocess('{{#invoke:Explorers of Sky Boss Data Cell|explorersOfSkyBossDataCell|name=' .. (bossArg or "") .. '|getVar=ja}}') .. '</td>')
		if not (typeTwo == '') and not (typeTwo == nil) then
			table.insert(rowData, '<td class="templatePrimary" rowspan="' .. #countMoves .. '">' .. frame:expandTemplate{title = "TypePKMN", args = {typeOne}} .. '</td>')
			table.insert(rowData, '<td class="templatePrimary" rowspan="' .. #countMoves .. '">' .. frame:expandTemplate{title = "TypePKMN", args = {typeTwo}} .. '</td>')
		else
			table.insert(rowData, '<td class="templatePrimary" rowspan="' .. #countMoves .. '" colspan="2">' .. frame:expandTemplate{title = "TypePKMN", args = {typeOne}} .. '</td>')
		end
		table.insert(rowData, '<td class="templateSecondary" rowspan="' .. #countMoves .. '">' .. (levelArg or "") .. '</td>')
		table.insert(rowData, '<td class="templateSecondary" rowspan="' .. #countMoves .. '">' .. recruitable .. '</td>')
		table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "explorersOfSky", args = {moveOne}} .. '</td>')
		table.insert(rowData, '</tr>')
		if not (moveTwo == '') and not (moveTwo == nil) then
			table.insert(rowData, '<tr class="bossesTableRow">')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "explorersOfSky", args = {moveTwo}} .. '</td>')
			table.insert(rowData, '</tr>')
		end
		if not (moveThree == '') and not (moveThree == nil) then
			table.insert(rowData, '<tr class="bossesTableRow">')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "explorersOfSky", args = {moveThree}} .. '</td>')
			table.insert(rowData, '</tr>')
		end
		if not (moveFour == '') and not (moveFour == nil) then
			table.insert(rowData, '<tr class="bossesTableRow">')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "explorersOfSky", args = {moveFour}} .. '</td>')
			table.insert(rowData, '</tr>')
		end
		if not (moveFive == '') and not (moveFive == nil) then
			table.insert(rowData, '<tr class="bossesTableRow">')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "explorersOfSky", args = {moveFive}} .. '</td>')
			table.insert(rowData, '</tr>')
		end
		if not (moveSix == '') and not (moveSix == nil) then
			table.insert(rowData, '<tr class="bossesTableRow">')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "explorersOfSky", args = {moveSix}} .. '</td>')
			table.insert(rowData, '</tr>')
		end
		if not (moveSeven == '') and not (moveSeven == nil) then
			table.insert(rowData, '<tr class="bossesTableRow">')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "explorersOfSky", args = {moveSeven}} .. '</td>')
			table.insert(rowData, '</tr>')
		end
		if not (moveEight == '') and not (moveEight == nil) then
			table.insert(rowData, '<tr class="bossesTableRow">')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "explorersOfSky", args = {moveEight}} .. '</td>')
			table.insert(rowData, '</tr>')
		end
		if not (moveNine == '') and not (moveNine == nil) then
			table.insert(rowData, '<tr class="bossesTableRow">')
			table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "explorersOfSky", args = {moveNine}} .. '</td>')
			table.insert(rowData, '</tr>')
		end
		table.insert(output, table.concat(rowData))
	end
	table.insert(output, '</table>')
	return table.concat(output)
end

return p