Aller au contenu

Module:TestMatt

De Poképédia

La documentation pour ce module peut être créée à Module:TestMatt/doc

local p = {}

function p.premiertype(frame)
	local pokemon = frame.args[1]
	local form
	
	local replacement_ids = {
		[" d'Alola"] = "Alola",
		[" de Galar"] = "Galar",
		[" de Hisui"] = "Hisui",
		[" de Paldea"] = "Paldea",
		["Méga%-"] = "Méga",
		[" Gigamax"] = "Gigamax"
	}
	for replacing, replaced in pairs(replacement_ids) do
		if mw.ustring.find(pokemon, replacing)
		then pokemon = mw.ustring.gsub(pokemon, replacing, "")
			form = replaced
		end
	end
	
	local datatypes = require("Module:Data/TypesPokémon")
	local form_arg = frame.args["forme"]
	if form_arg == nil or form_arg == ""
	then if form == nil
		then form = 1
		end
	else form = form_arg
	end
	
	local types = datatypes[pokemon]
	if types == nil
	then return ""
	end
	
	local types_form = types[form]
	if types_form == nil
	then return ""
	end
	
	local first_type = types_form[1]
	
	return first_type
end

return p