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 = "" 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 nil local floor = args[2] or '??-??' local recruit = args[3] or nil local time = args["time"] 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 In parenthesis and superscript

--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.."") if string.match(recruit, "{{") then rate = string.gsub(recruit, "{{.-}}", "") recruit = string.gsub(recruit, rate, rate.."%%") else recruit = recruit.."%" end else recruit = "Unrecruitable" 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