Module:DunPokemon

local getArgs = require('Module:Arguments').getArgs local Wdstt = require('Module:Wdstt').main local p = {}

function p.main(frame) local args = getArgs(frame) return p._main(args) end

function p._main(args) local form = nil local name = nil local MS = require('Module:MS').main local ND2 = require('Module:PData').ND2 local PN = require('Module:PData').PN	local port = args[1] or nil local num = args[1] or nil local pokemon = args[1] or "" local floor = args[2] or '??-??' local recruit = args[3] or nil local time = args["time"] or nil local evo = args["evo"] or nil local unrec = args["unrec"] or nil local row = mw.html.create local cells = mw.html.create

local times = { ["dawn"] = "(dawn)", ["day"] = "(day)", ["dusk"] = "(dusk)", ["night"] = "(night)", --(dawn/day) ["dawnday"] = "(dawn/day)", ["daydawn"] = "(dawn/day)", --(dawn/dusk) ["dawndusk"] = "(dawn/dusk)", ["duskdawn"] = "(dawn/dusk)", --(dawn/night) ["dawnnight"] = "(dawn/night)", ["nightdawn"] = "(dawn/night)", --(day/dusk) ["duskday"] = "(day/dusk)", ["daydusk"] = "(day/dusk)", --(day/night) ["daynight"] = "(day/night)", ["nightday"] = "(day/night)", --(dusk/night) ["dusknight"] = "(dusk/night)", ["nightdusk"] = "(dusk/night)", --(dawn/day/dusk) ["daydawndusk"] = "(dawn/day/dusk)", ["dayduskdawn"] = "(dawn/day/dusk)", ["dawndaydusk"] = "(dawn/day/dusk)", ["duskdaydawn"] = "(dawn/day/dusk)", ["duskdawnday"] = "(dawn/day/dusk)", ["dawnduskday"] = "(dawn/day/dusk)", --(dawn/day/night) ["nightdaydawn"] = "(dawn/day/night)", ["nightdawnday"] = "(dawn/day/night)", ["daynightdawn"] = "(dawn/day/night)", ["dawnnightday"] = "(dawn/day/night)", ["dawndaynight"] = "(dawn/day/night)", ["daydawnnight"] = "(dawn/day/night)", --(day/dusk/night) ["nightduskday"] = "(day/dusk/night)", ["nightdaydusk"] = "(day/dusk/night)", ["daynightdusk"] = "(day/dusk/night)", ["dusknightday"] = "(day/dusk/night)", ["daydusknight"] = "(day/dusk/night)", ["duskdaynight"] = "(day/dusk/night)", --(dawn/dusk/night) ["nightduskdawn"] = "(dawn/dusk/night)", ["nightdawndusk"] = "(dawn/dusk/night)", ["dusknightdawn"] = "(dawn/dusk/night)", ["dawnnightdusk"] = "(dawn/dusk/night)", ["dawndusknight"] = "(dawn/dusk/night)", ["duskdawnnight"] = "(dawn/dusk/night)" }

if string.match(pokemon, "<") then name = string.gsub(pokemon, "<.+>", "") num = ND2({name}) port = MS({name}) else name = pokemon num = ND2({pokemon}) port = MS({pokemon}) end

--To not reqiure both ND and ND2, --ND2 ( the one that Includes form names ) Is used if string.match(num, "-") then split = mw.text.split(num, "-") num = split[1] end

species = PN({name}) --PN Is a template that displays a Pokemon's name and Its form

--To not make the table cell too long, the form --Is split and then put below the name if string.match(species, " ") then form = " "..string.gsub(species, ".- ", " ") species = string.gsub(species, "(.-) .+", "%1") end pokemon = string.gsub(pokemon, name, species)

--Recruitability if recruit ~= nil and recruit ~= "passive" then pokemon = string.gsub(pokemon, species, ""..species.."") recruit = recruit.."%" if unrec ~= nil then recruit = recruit..Wdstt({"*", "unrecruitable after floor "..unrec}) end else recruit = "Unrecruitable" end

if evo ~= nil then pokemon = pokemon .. Wdstt({"*", "evolves into "..evo}) end --Passive Pokémon ( do people actually care about this? 	--a past editor started doing It so I Integrated It Into the template ) for _, arg in pairs(args) do		if arg == "passive" then pokemon = pokemon .. Wdstt({"*", "only attacks in self-defense"}) end end

--Time appearances if time ~= nil then time = string.lower(time) if string.match(time, "/") then time = string.gsub(time, "/", "") end floor = floor.." "..times[time] end

--Putting the form name ( If there Is one ) below everything if form then pokemon = pokemon..form end

cells :tag('td'):wikitext(port) :done :tag('td'):wikitext(num) :done :tag('td'):wikitext(pokemon) :done :tag('td'):wikitext(floor) :done :tag('td'):wikitext(recruit) :done

row :tag('tr') :node(cells)

return row end

return p