Module:Gates to Infinity Dungeon Pokémon table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(21 intermediate revisions by 3 users not shown)
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Gates to Infinity Dungeon Pokémon table
-- Module:Gates to Infinity Dungeon Pokémon table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 9: Line 9:


function p.main(frame)
function p.main(frame)
local data = require("Module:Gates to Infinity Pokémon Data Cell")
local metatable = {__index = function () return "" end}
setmetatable(data, metatable)
local args = frame.args
local args = frame.args
local output = {}
 
local output = mw.html.create()
local header = mw.html.create()
-- Header row
-- Header row
table.insert(output, '<table class="templateTheme" style="text-align: center; margin: auto; width: 50%;">')
header
table.insert(output, '<tr>')
:tag('tr')
table.insert(output, '<th class="templatePrimary" rowspan="2" style="border-radius: 1rem 0 0 0; width: 10%;">Model</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Model"):done()
table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "GatesToInfinity", args = {"Pokémon"}} .. '</th>')
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {"Pokémon"}}):done()
table.insert(output, '<th class="templatePrimary" colspan="2" rowspan="2" style="width: 20%;">' .. frame:expandTemplate{title = "GatesToInfinity", args = {"Types"}} .. '</th>')
:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {"Type"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "GatesToInfinity", args = {"Level"}} .. '</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {"Level"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "GatesToInfinity", args = {"Experience"}} .. '</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {"Experience"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "GatesToInfinity", args = {"Recruitment rate"}} .. '</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Floors"):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">Spawn rate</th>')
:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {"Recruiting", "Recruit Chance"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="border-radius: 0 1rem 0 0; width: 10%;">Floors</th>')
:tag('tr')
table.insert(output, '</tr>')
:tag('th'):cssText("width: 15%"):wikitext("English"):done()
table.insert(output, '<tr>')
:tag('th'):cssText("width: 15%"):wikitext("Japanese"):done()
table.insert(output, '<th class="templatePrimary" style="width: 10%;">English</th>')
 
table.insert(output, '<th class="templatePrimary" style="width: 10%;">Japanese</th>')
table.insert(output, '</tr>')
-- Data rows
-- Data rows
for i = 1, 100 do
local rows = mw.html.create()
local pokemonArg = args["pokémon_" .. i]
local i = 1
 
while true do
local row = mw.html.create()
local monsterArg = args["pokémon_" .. i]
local floorsArg = args["floors_" .. i]
local levelArg = args["level_" .. i]
local expArg = args["exp_" .. i]
local expArg = args["exp_" .. i]
local recruitArg = args["recruit_" .. i]
local recruitableArg = args["recruitable_" .. i]
local spawnRateArg = args["spawnRate_" .. i]
 
local floorArg = args["floor_" .. i]
if not monsterArg and not floorsArg and not recruitableArg and not expArg and not levelArg then
if not pokemonArg and not expArg and not recruitArg and not spawnRateArg and not floorArg then
break -- exit loop when no more rows are found
break -- exit loop when no more rows are found
end
end
local rowData = {}
 
table.insert(rowData, '<tr class="monstersTableRow">')
local typeOne = data[monsterArg]["type1"] or ""
table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "GatesToInfinityModel", args = {(pokemonArg or "")}} .. '</th>')
local typeTwo = data[monsterArg]["type2"] or ""
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "GatesToInfinity", args = {(pokemonArg or "")}} .. '</td>')
local recruitOne = data[monsterArg]["recruit1"] or ""
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Gates to Infinity Monster Data Cell|gatesToInfinityPokemonDataCell|name=' .. (pokemonArg or "") .. '|getVar=ja}}') .. '</td>')
local recruitTwo = data[monsterArg]["recruit2"] or ""
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Gates to Infinity Monster Data Cell|gatesToInfinityPokemonDataCell|name=' .. (pokemonArg or "") .. '|getVar=exp}}') .. '</td>')
 
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Gates to Infinity Monster Data Cell|gatesToInfinityPokemonDataCell|name=' .. (pokemonArg or "") .. '|getVar=type1}}') .. '</td>')
row
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Gates to Infinity Monster Data Cell|gatesToInfinityPokemonDataCell|name=' .. (pokemonArg or "") .. '|getVar=type2}}') .. '</td>')
:tag('tr'):done()
table.insert(rowData, '<td class="templateSecondary">' .. (expArg or "") .. '</td>')
:tag('th'):wikitext(frame:expandTemplate{title = "GatesToInfinityModel", args = {(monsterArg or ""), size = "50x50px"}}):done()
table.insert(rowData, '<td class="templateSecondary">' .. (recruitArg or "") .. '</td>')
:tag('td'):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {(monsterArg or "")}}):done()
table.insert(rowData, '<td class="templateSecondary">' .. (spawnRateArg or "") .. '</td>')
:tag('td'):wikitext(data[monsterArg]["ja"]):done()
table.insert(rowData, '<td class="templateSecondary">' .. (floorArg or "") .. '</td>')
table.insert(rowData, '</tr>')
if typeTwo == nil or typeTwo == '' then
table.insert(output, table.concat(rowData))
row
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "GatesToInfinityType", args = {typeOne}}):done()
else
row
:tag('th'):wikitext(frame:expandTemplate{title = "GatesToInfinityType", args = {typeOne}}):done()
:tag('th'):wikitext(frame:expandTemplate{title = "GatesToInfinityType", args = {typeTwo}}):done()
end
 
row
:tag('td'):wikitext(levelArg or frame:expandTemplate{title = "Research"}):done()
 
if expArg == nil or expArg == '' then
row
:tag('td'):wikitext(frame:expandTemplate{title = "Research"}):done()
else
row
:tag('td'):wikitext(frame:expandTemplate{title = "Tt", args = {expArg, frame:preprocess('{{#expr:' .. expArg .. '/2 round 0}}') .. ' if K.O.\'d without using a move.'}}):done()
end
 
row
:tag('td'):wikitext(floorsArg 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("colspan", "2"):wikitext("Unrecruitable"):done()
else
if recruitTwo == nil or recruitTwo == '' then
row
:tag('td'):attr("colspan", "2"):wikitext(data[monsterArg]["recruit1"]):done()
else
row
:tag('td'):wikitext(data[monsterArg]["recruit1"]):done()
:tag('td'):wikitext(data[monsterArg]["recruit2"]):done()
end
end
 
rows
:node(row)
:allDone()
 
i = i + 1
end
end
table.insert(output, '</table>')
 
return table.concat(output)
output
:tag('table'):addClass("wikitable"):cssText("text-align: center; margin: auto; width: 50%;")
:node(header)
:node(rows)
return tostring(output)
 
end
end


return p
return p

Latest revision as of 20:36, 20 May 2025

Template-info.png Documentation

This template generates a list of monsters present in a dungeon for Gates to Infinity.

Usage

{{#invoke:Gates to Infinity Dungeon Pokémon table|main
  | pokémon_1   = 
  | exp_1       = 
  | recruit_1   = 
  | spawnRate_1 = 
  | floor_1     = 
  ...
  | pokémon_n   = 
  | exp_n       = 
  | recruit_n   = 
  | spawnRate_n = 
  | floor_n     = 
}}

Example

{{#invoke:Gates to Infinity Dungeon Pokémon table|main
  | pokémon_1   = Pikachu
  | level_1     = 2
  | exp_1       = 50
  | recruit_1   = 50%
  | spawnRate_1 = 20%
  | floor_1     = 1 - 5
}}
ModelPokémonTypeLevelExperienceFloorsRecruit Chance
EnglishJapanese
Pikachu's model.PikachuピカチュウElectric-type250[Research required]Unrecruitable

--------------------------------------------------------------------------------
--
--				Module:Gates to Infinity Dungeon Pokémon table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local data = require("Module:Gates to Infinity Pokémon 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("Model"):done()
			:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {"Pokémon"}}):done()
			:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {"Type"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {"Level"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {"Experience"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Floors"):done()
			:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {"Recruiting", "Recruit Chance"}}):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 monsterArg = args["pokémon_" .. i]
		local floorsArg = args["floors_" .. i]
		local levelArg = args["level_" .. i]
		local expArg = args["exp_" .. i]
		local recruitableArg = args["recruitable_" .. i]

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

		local typeOne = data[monsterArg]["type1"] or ""
		local typeTwo = data[monsterArg]["type2"] or ""
		local recruitOne = data[monsterArg]["recruit1"] or ""
		local recruitTwo = data[monsterArg]["recruit2"] or ""

		row
			:tag('tr'):done()
				:tag('th'):wikitext(frame:expandTemplate{title = "GatesToInfinityModel", args = {(monsterArg or ""), size = "50x50px"}}):done()
				:tag('td'):wikitext(frame:expandTemplate{title = "GatesToInfinity", args = {(monsterArg or "")}}):done()
				:tag('td'):wikitext(data[monsterArg]["ja"]):done()
	
		if typeTwo == nil or typeTwo == '' then
			row
				:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "GatesToInfinityType", args = {typeOne}}):done()
		else
			row
				:tag('th'):wikitext(frame:expandTemplate{title = "GatesToInfinityType", args = {typeOne}}):done()
				:tag('th'):wikitext(frame:expandTemplate{title = "GatesToInfinityType", args = {typeTwo}}):done()
		end

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

		if expArg == nil or expArg == '' then
			row
				:tag('td'):wikitext(frame:expandTemplate{title = "Research"}):done()
		else
			row
				:tag('td'):wikitext(frame:expandTemplate{title = "Tt", args = {expArg, frame:preprocess('{{#expr:' .. expArg .. '/2 round 0}}') .. ' if K.O.\'d without using a move.'}}):done()
		end

		row
			:tag('td'):wikitext(floorsArg 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("colspan", "2"):wikitext("Unrecruitable"):done()
		else
		if recruitTwo == nil or recruitTwo == '' then
			row
				:tag('td'):attr("colspan", "2"):wikitext(data[monsterArg]["recruit1"]):done()
		else
			row
				:tag('td'):wikitext(data[monsterArg]["recruit1"]):done()
				:tag('td'):wikitext(data[monsterArg]["recruit2"]):done()
		end
		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