Module:Rescue Team DX Dungeon Pokémon table: Difference between revisions

MDFW - The Mystery Dungeon Tree of Information.
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--
--
-- Module:Rescue Team DX Dungeon Pokémon table
-- Module:Rescue Team DX Dungeon Pokémon table
--
--
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 9: Line 9:


function p.main(frame)
function p.main(frame)
local data = require("Module:Rescue Team DX 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="width: 10%;">Sprite</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Sprite"):done()
table.insert(output, '<th class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Pokémon"}} .. '</th>')
:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Pokémon"}}):done()
table.insert(output, '<th class="templatePrimary" colspan="2" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Type", "Types"}} .. '</th>')
:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Type"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Level"}} .. '</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Level"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Experience"}} .. '</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Experience"}}):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">' .. frame:expandTemplate{title = "RescueTeamDX", args = {"Recruiting", "Recruit Chance"}} .. '</th>')
:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Floors"):done()
table.insert(output, '<th class="templatePrimary" rowspan="2" style="width: 10%;">Floors</th>')
:tag('th'):attr("colspan", "3"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Recruiting", "Recruit Chance"}}):done()
table.insert(output, '</tr>')
:tag('tr')
table.insert(output, '<tr>')
:tag('th'):cssText("width: 20%"):wikitext("English"):done()
table.insert(output, '<th class="templatePrimary" style="width: 20%;">English</th>')
:tag('th'):cssText("width: 20%"):wikitext("Japanese"):done()
table.insert(output, '<th class="templatePrimary" style="width: 20%;">Japanese</th>')
:tag('th'):cssText("width: 5%"):wikitext("Base Chance"):done()
table.insert(output, '</tr>')
:tag('th'):cssText("width: 10%"):wikitext("Recruit Camp"):done()
:tag('th'):cssText("width: 5%"):wikitext("Story"):done()
-- Data rows
-- Data rows
for i = 1, 150 do
local rows = mw.html.create()
local monsterArg = args["pokémon_" .. i]
local i = 1
while true do
local row = mw.html.create()
local monsterArg = args["monster_" .. i]
local floorsArg = args["floors_" .. i]
local floorsArg = args["floors_" .. i]
local levelArg = args["level_" .. i]
local levelArg = args["level_" .. i]
local expArg = args["exp_" .. i]
local expArg = args["exp_" .. i]
local recruitableArg = args["recruitable_" .. i]
local recruitableArg = args["recruitable_" .. i]
if not monsterArg and not floorsArg and not recruitableArg and not expArg and not levelArg then
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
break -- exit loop when no more rows are found
end
end
local typeOne = frame:preprocess('{{#invoke:Rescue Team DX Pokémon Data Cell|rescueTeamDXPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=type1}}')
local typeTwo = frame:preprocess('{{#invoke:Rescue Team DX Pokémon Data Cell|rescueTeamDXPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=type2}}')
row
local rowData = {}
:tag("tr")
table.insert(rowData, '<tr class="monstersTableRow">')
:tag("th"):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "32px"}}):done()
table.insert(rowData, '<th class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "50x50px"}} .. '</th>')
:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}}):done()
table.insert(rowData, '<td class="templateSecondary">' .. frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}} .. '</td>')
:tag("td"):wikitext(data[monsterArg]["ja"]):done()
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team DX Pokémon Data Cell|rescueTeamDXPokemonDataCell|name=' .. (monsterArg or "") .. '|getVar=ja}}') .. '</td>')
if typeTwo == nil or typeTwo == '' then
if typeTwo == nil or typeTwo == '' then
row
table.insert(rowData, '<td class="templatePrimary" colspan="2">' .. frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}} .. '</td>')
:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {data[monsterArg]["type1"]}}):done()
else
:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {data[monsterArg]["type2"]}}):done()
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXType", args = {typeOne}} .. '</td>')
else
table.insert(rowData, '<td class="templatePrimary">' .. frame:expandTemplate{title = "RescueTeamDXType", args = {typeTwo}} .. '</td>')
row
end
:tag("td"):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {data[monsterArg]["type1"]}}):done()
table.insert(rowData, '<td class="templateSecondary">' .. (levelArg or frame:expandTemplate{title = "Research"}) .. '</td>')
end
table.insert(rowData, '<td class="templateSecondary">' .. (expArg or frame:expandTemplate{title = "Research"}) .. '</td>')
 
if recruitableArg == nil or string.lower(recruitableArg) == "false" or string.lower(recruitableArg) == "no" then
row
table.insert(rowData, '<td class="templateSecondary">Unrecruitable</td>')
:tag("td"):wikitext(data[monsterArg]["exp"])
else
:tag("td"):wikitext(floorsArg or frame:expandTemplate{title = "Research"}):done()
table.insert(rowData, '<td class="templateSecondary">' .. frame:preprocess('{{#invoke:Rescue Team DX Pokémon Data Cell|rescueTeamDXPokemonDataCell|name=' .. monsterArg .. '|getVar=recruit}}') .. '</td>')
end
if recruitableArg == nil or string.lower(recruitableArg) == "false" or string.lower(recruitableArg) == "no" then
table.insert(rowData, '<td class="templateSecondary">' .. (floorsArg or frame:expandTemplate{title = "Research"}) .. '</td>')
row
table.insert(rowData, '</tr>')
:tag("td"):attr("colspan", "3"):wikitext("Unrecruitable"):done()
table.insert(output, table.concat(rowData))
else
row
:tag("td"):wikitext(data[monsterArg]["recruit"]):done()
:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {data[monsterArg]["rescueCamp"]}}):done()
:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {data[monsterArg]["story"]}}):done()
end
 
rows
:node(row)
:allDone()
i = i + 1
end
end
table.insert(output, '</table>')
return table.concat(output)
output
:tag('table'):addClass("MDWiki"):cssText("text-align: center; margin: auto; width: 50%;")
:node(header)
:node(rows)
return tostring(output)
end
end


return p
return p

Revision as of 17:50, 24 July 2024

Template-info.png Documentation

This template generates a list of pokemons present in a dungeon for Pokémon Mystery Dungeon: Rescue Team DX.

Usage

{{#invoke:Rescue Team DX Dungeon Pokémon table|main
  | pokémon_1 = 
  | floors_1  = 
  | level_1   = 
  | exp_1     = 
  ...
  | pokémon_n = 
  | floors_n  = 
  | level_n   = 
  | exp_n     = 
}}

Example

{{#invoke:Rescue Team DX Dungeon Pokémon table|main
  | pokémon_1 = 
  | floors_1  = 
}}
SpritePokémonTypeLevelExperienceFloorsRecruit Chance
EnglishJapaneseBase ChanceRecruit CampStory
[[Rescue Team DX:|]]
1 - 3Unrecruitable

--------------------------------------------------------------------------------
--
--					Module:Rescue Team DX Dungeon Pokémon table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local data = require("Module:Rescue Team DX 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("Sprite"):done()
			:tag('th'):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Pokémon"}}):done()
			:tag('th'):attr("colspan", "2"):attr("rowspan", "2"):cssText("width: 20%"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Type"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Level"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Experience"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext("Floors"):done()
			:tag('th'):attr("colspan", "3"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {"Recruiting", "Recruit Chance"}}):done()
		:tag('tr')
			:tag('th'):cssText("width: 20%"):wikitext("English"):done()
			:tag('th'):cssText("width: 20%"):wikitext("Japanese"):done()
			:tag('th'):cssText("width: 5%"):wikitext("Base Chance"):done()
			:tag('th'):cssText("width: 10%"):wikitext("Recruit Camp"):done()
			:tag('th'):cssText("width: 5%"):wikitext("Story"):done()
	
	-- Data rows
	local rows = mw.html.create()
	local i = 1
	
	while true do
		local row = mw.html.create()
		local monsterArg = args["monster_" .. 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
		
		row
			:tag("tr")
				:tag("th"):wikitext(frame:expandTemplate{title = "RescueTeamDXSprite", args = {(monsterArg or ""), size = "32px"}}):done()
				:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDX", args = {(monsterArg or "")}}):done()
				:tag("td"):wikitext(data[monsterArg]["ja"]):done()
				if typeTwo == nil or typeTwo == '' then
					row
						:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {data[monsterArg]["type1"]}}):done()
						:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {data[monsterArg]["type2"]}}):done()
				else
					row
						:tag("td"):attr("colspan", "2"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {data[monsterArg]["type1"]}}):done()
				end

				row
					:tag("td"):wikitext(data[monsterArg]["exp"])
					:tag("td"):wikitext(floorsArg or frame:expandTemplate{title = "Research"}):done()
					
				if recruitableArg == nil or string.lower(recruitableArg) == "false" or string.lower(recruitableArg) == "no" then
					row
						:tag("td"):attr("colspan", "3"):wikitext("Unrecruitable"):done()
				else
					row
						:tag("td"):wikitext(data[monsterArg]["recruit"]):done()
						:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {data[monsterArg]["rescueCamp"]}}):done()
						:tag("td"):wikitext(frame:expandTemplate{title = "RescueTeamDXType", args = {data[monsterArg]["story"]}}):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