Module:Shiren 3 Wii Dungeon Monsters table

MDFW - The Mystery Dungeon Tree of Information.
Revision as of 11:53, 14 July 2024 by Adkuate (talk | contribs)
Jump to navigation Jump to search
Template-info.png Documentation

This template generates a list of monsters present in a dungeon for Shiren the Wanderer 3: The Sleeping Princess and the Karakuri Mansion.

Usage

{{#invoke:Shiren 3 Wii Dungeon Monsters table|main
  | type      =
  | monster_1 = 
  | floor_1   = 
  ...
  | monster_n = 
  | floor_n   = 
}}

Example

{{#invoke:Shiren 3 Wii Dungeon Monsters table|main
  | type      = past
  | monster_1 = Mamel
  | floor_1   = 1 - 3
  | monster_2 = Balsam Bug
  | floor_2   = 1 - 3
  | monster_3 = Mouse Minion
  | floor_3   = 1 - 3
}}
ModelMonsterExperienceAttributeFloors
EnglishJapanese
Mamel's model.Mamelマムル2Water[Research required]
Balsam Bug's model.Balsam Bugホウセンムシ3Fire[Research required]
Mouse Minion's model.Mouse Minionねずみ子分4Water[Research required]

--------------------------------------------------------------------------------
--
--				Module:Shiren 3 Wii Dungeon Monsters table
--
--------------------------------------------------------------------------------

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

function p.main(frame)
	local data = require("Module:Shiren 3 Wii Monster 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 = "Shiren3Wii", args = {"Monster"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "Shiren3Wii", args = {"Experience"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 10%"):wikitext(frame:expandTemplate{title = "Shiren3Wii", args = {"Attribute"}}):done()
			:tag('th'):attr("rowspan", "2"):cssText("width: 20%"):wikitext("Floors"):done()
		:tag('tr')
			:tag('th'):cssText("width: 25%"):wikitext("English"):done()
			:tag('th'):cssText("width: 25%"):wikitext("Japanese"):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]
		
		if not monsterArg and not floorsArg then
			break -- exit loop when no more rows are found
		end
		
		row
			:tag("tr")
				:tag("th"):wikitext(frame:expandTemplate{title = "Shiren3WiiModel", args = {(monsterArg or ""), size = "50x50px"}}):done()
				:tag("td"):wikitext(frame:expandTemplate{title = "Shiren3Wii", args = {(monsterArg or "")}}):done()
				:tag("td"):wikitext(data[monsterArg]["ja"])
				:tag("td"):wikitext(data[monsterArg]["exp"])
				:tag("td"):wikitext(data[monsterArg]["type"]):cssText("background-color: " .. frame:preprocess('{{#switch:{{#invoke:Shiren 3 Monster Data Cell|shiren3MonsterDataCell|name=' .. (monsterArg or "") .. '|getVar=type}} | Water=background: #0000FF!important; color: white; | Nature=background: #228B22!important; | Fire=background: #FF0000!important; | Thunder=background: #FFFF00!important; | Shadow=background: #000000!important; color: white; | Earth=background: #8B4513!important; | Spirit=background: #FF69B4!important; | Illusion=background: #8A2BE2!important; }}'))
				:tag("td"):wikitext(floorsArg or frame:expandTemplate{title = "Research"}):done()
		
		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