Module:Utilisateur:SombrAbsol
Apparence
La documentation pour ce module peut être créée à Module:Utilisateur:SombrAbsol/doc
local p = {}
local ressources = {
["infosPokemon"] = require("Module:Ressources/infosPokemon")
}
-- Versions opposées
local versions_opposees = {
["RV"] = {"R-jp", "Rouge (Japon)", "V", "Vert (Japon)"},
["RB"] = {"R", "Rouge", "B", "Bleu"},
["OA"] = {"O", "Or", "A", "Argent"},
["RS"] = {"Ru", "Rubis", "Sa", "Saphir"},
["RFVF"] = {"RF", "Rouge Feu", "VF", "Vert Feuille"},
["DP"] = {"D", "Diamant", "Pt", "Perle"},
["HGSS"] = {"HG", "HeartGold", "SS", "SoulSilver"},
["NB"] = {"No", "Noir", "Bl", "Blanc"},
["N2B2"] = {"N2", "Noir 2", "B2", "Blanc 2"},
["XY"] = {"X", "X", "Y", "Y"},
["ROSA"] = {"RO", "Rubis Oméga", "SA", "Saphir Alpha"},
["SL"] = {"So", "Soleil", "Lu", "Lune"},
["USUL"] = {"US", "Ultra-Soleil", "UL", "Ultra-Lune"},
["LGPE"] = {"LG", "Let's Go, Pikachu", "PE", "Let's Go, Évoli"},
["EB"] = {"Ep", "Épée", "Bo", "Bouclier"},
["DEPS"] = {"DE", "Diamant Étincelant", "PS", "Perle Scintillante"},
["EV"] = {"Ec", "Écarlate", "Vi", "Violet"},
}
-- Compteur utilisé pour donner un identifiant unique à chaque toggle
local toggle_counter = 0
-- Toggles pour choisir l'affichage entre versions opposées
local function build_toggle_links(id_prefix, versions, self_key)
local lien_style = "cursor:pointer; text-decoration:underline; margin-left:6px; white-space:nowrap;"
local function lien(key, label)
return "<span class='mw-customtoggle-" .. id_prefix .. "-" .. self_key
.. " mw-customtoggle-" .. id_prefix .. "-" .. key .. "' style='" .. lien_style .. "'>👁️" .. label .. "</span>"
end
local html = "<span style='float:right; font-weight:normal; font-size:0.8em;'>"
if self_key ~= "deux" then html = html .. lien("deux", versions[1] .. "+" .. versions[3]) end
if self_key ~= "v1" then html = html .. lien("v1", versions[1]) end
if self_key ~= "v2" then html = html .. lien("v2", versions[3]) end
return html .. "</span>"
end
-- Contrôle l'affichage de l'abbréviation de version pour les toggles
local function set_argument(fun_name, expression, new_value)
local fun_name_rat = mw.ustring.gsub(fun_name, "%-", "%%-")
local pattern = fun_name_rat .. "%([^)]*%)"
if string.match(expression, pattern)
then return mw.ustring.gsub(expression, pattern, function() return fun_name .. "(" .. new_value .. ")" end, 1)
else return expression
end
end
-- Filtre une liste de lignes de Pokémon selon le toggle de version cliqué
local function filter_pokemon_lines(pokemon_list, version_code, other_code)
local filtered = {}
local i = 1
while pokemon_list[i] do
local line = pokemon_list[i]
local poke = mw.text.split(line, " / ")
if poke[2] == nil then
-- Ligne simple (changement de lieu ou espèce sans info) : gardée telle quelle
table.insert(filtered, line)
else
local kept = {poke[1]}
local h = 2
while poke[h] do
local info = poke[h]
local keep_line = true
local taux_val = extract_argument("taux", info, nil)
if taux_val ~= nil then
local parts = mw.text.split(taux_val, ", ")
local marque = parts[#parts]
if #parts >= 2 and (marque == version_code or marque == other_code) then
if marque == other_code
then keep_line = false
else
table.remove(parts)
info = set_argument("taux", info, table.concat(parts, ", "))
end
end
end
if keep_line then
table.insert(kept, info)
end
h = h + 1
end
if kept[2] ~= nil then
table.insert(filtered, table.concat(kept, " / "))
end
end
i = i + 1
end
return filtered
end
-- Extrait le contenu d'une fonction de la forme "fun_name(argument)" dans une expression.
function extract_argument(fun_name, expression, default)
-- le tiret est un caractère utilisé pour les noms de fonctions, mais aussi spécial pour les expressions rationnelles
fun_name_rat = mw.ustring.gsub(fun_name, "%-", "%%-")
if (string.match(expression, fun_name_rat .. "%([^)]*%)"))
then return string.sub(string.match(expression, fun_name_rat .. "%([^)]*%)"), string.len(fun_name) + 2, -2)
else return default
end
end
-- Extrait le contenu d'une fonction de la forme "fun_name[argument]" dans une expression.
function extract_argument_bracket(fun_name, expression, default)
-- le tiret est un caractère utilisé pour les noms de fonctions, mais aussi spécial pour les expressions rationnelles
fun_name_rat = mw.ustring.gsub(fun_name, "%-", "%%-")
if (string.match(expression, fun_name_rat .. "%[[^]]*%]"))
then return string.sub(string.match(expression, fun_name_rat .. "%[[^]]*%]"), string.len(fun_name) + 2, -2)
else return default
end
end
-- Fusionne les lignes consécutives de même espèce en une seule entrée
function merge_wild_lines(lines)
local merged = {}
local current_species = nil
local current_signatures = {} -- signature = index dans current_infos
local current_infos = {} -- liste ordonnée des infos déjà rencontrées pour l'espèce en cours
local function flush()
if current_species ~= nil then
local parts = {current_species}
local i = 1
while current_infos[i] do
table.insert(parts, current_infos[i].rendered)
i = i + 1
end
table.insert(merged, table.concat(parts, " / "))
end
current_species = nil
current_signatures = {}
current_infos = {}
end
local i = 1
while lines[i] do
local line = lines[i]
local sep_start, sep_end = string.find(line, " / ", 1, true)
local species, infos = nil, nil
if sep_start then
species = string.sub(line, 1, sep_start - 1)
infos = string.sub(line, sep_end + 1)
end
if not species or string.find(infos, " / ", 1, true) then
-- Pas une ligne simple "Espèce / une seule info" (changement de
-- lieu, ou ligne déjà composée) : on la laisse telle quelle.
flush()
table.insert(merged, line)
else
local rate = string.match(infos, "taux%((%-?%d+)")
if not rate then
-- Pas de fusion possible avec des taux non numériques
flush()
table.insert(merged, line)
else
if current_species ~= species then
flush()
current_species = species
end
-- La signature est l'information complète sans le taux
local signature = string.gsub(infos, "taux%(%-?%d+", "taux(#")
local index = current_signatures[signature]
if index then
local total = current_infos[index].rate + tonumber(rate)
current_infos[index].rate = total
current_infos[index].rendered = string.gsub(infos, "taux%(%-?%d+", "taux(" .. total, 1)
else
table.insert(current_infos, {rate = tonumber(rate), rendered = infos})
current_signatures[signature] = #current_infos
end
end
end
i = i + 1
end
flush()
return merged
end
function p.sauvage(frame)
-- Recense les différents types de rencontre de Pokémon sauvages
local milieu_sauvage = require("Module:Tableau Pokémon/Milieux")
local jeu = frame.args["jeu"]
if jeu == nil then jeu = "" end
-- Miniatures spécifiques
local jeu_miniature = jeu
if jeu == "RV" or jeu == "RB" or jeu == "B-JP" or jeu == "B-jp" or jeu == "J" or jeu == "OA" or jeu == "C" then jeu_miniature = "RS"
elseif jeu == "Démo-ROSA" then jeu_miniature = "ROSA"
elseif jeu == "Démo-SL" then jeu_miniature = "SL"
elseif jeu == "Démo-LGPE" then jeu_miniature = "LGPE"
elseif jeu == "PDMRB" then jeu_miniature = "PDMTO"
end
jeu_miniature = " jeu(" .. jeu_miniature .. ")"
local bordure = frame:expandTemplate{title='Bordure', args={jeu}}
if bordure == nil then bordure = "" end
local image = frame.args["image"]
local fetching_loc = frame.args["localisations"]
fetching_loc = fetching_loc ~= "non"
local i = 1
local j = 1
local k = 1
local h = 1
-- Noms des icônes / Noms des sous-arguments / Classes de couleurs associées (cf. MediaWiki:Gadget-couleurs.css)
-- / Lien vers une page globale qui traite de ces sous-taux, nom du type de sous-taux (météo, horaire, saison),
-- singulier, pluriel, article ("le", "la" ou "l'"), et est-ce que le type du sous-taux est féminin (true ou false)
local sous_taux_dict = require("Module:Tableau Pokémon/sousTaux")
local sous_taux = sous_taux_dict["sous-taux"]
local raccourcis = sous_taux.raccourcis
-- GESTION DES TAUX PRÉSENTS
local taux_presents = nil
local phrase_finale = ""
local union_taux = true
local colspan_niveau = 1
local colspan_taux = 1
-- Jeux récents dont les taux sont trop complexes pour les traiter
if (jeu == "LPA" or jeu == "EV" or jeu == "LPZA")
then colspan_taux = 0
end
-- Paramètre taux-raccourci
local raccourci_arg = frame.args["taux-raccourci"]
if raccourci_arg ~= nil
then taux_presents = raccourcis[raccourci_arg]
if taux_presents ~= nil
then if taux_presents[4] and taux_presents[4][2] then phrase_finale = taux_presents[4][2] end
union_taux = false
local nombre_taux = 1
while taux_presents[1][nombre_taux] do
nombre_taux = nombre_taux + 1
end
colspan_taux = nombre_taux - 1
end
end
-- Paramètre taux-présents
local taux_presents_arg = nil
if taux_presents == nil -- Si les taux présents ont déjà été définis, on passe cette étape
then taux_presents_arg = frame.args["taux-présents"]
end
if taux_presents_arg ~= nil
then
i = 1
local nombre_taux = 0
local taux_presents_max = sous_taux[jeu] -- Le tableau qu'on va émincer pour ne garder que les taux présents
taux_presents = {{}, {}, {}, taux_presents_max[4]} -- Le tableau des taux qu'on va remplir
taux_presents_arg = mw.text.split(taux_presents_arg, "/")
while taux_presents_arg[i] do
taux_i = "taux-" .. taux_presents_arg[i]
j = 1
while taux_presents_max[2][j] and taux_i ~= taux_presents_max[2][j] do
j = j + 1
end
if taux_presents_max[2][j] -- Trouvé !
then
table.insert(taux_presents[1], taux_presents_max[1][j])
table.insert(taux_presents[2], taux_presents_max[2][j])
table.insert(taux_presents[3], taux_presents_max[3][j])
nombre_taux = nombre_taux + 1
end
i = i + 1
union_taux = false
colspan_taux = nombre_taux
end
-- Création de la phrase de bas de tableau
if nombre_taux > 0 then
if nombre_taux >= 2
then phrase_finale = "Les " .. taux_presents[4][3] .. " "
else if taux_presents[4][4] == "l'"
then phrase_finale = "L'"
else phrase_finale = mw.getContentLanguage():ucfirst(taux_presents[4][4]) .. " "
end
phrase_finale = phrase_finale .. taux_presents[4][2] .. " "
end
i = 1
while taux_presents[1][i] and taux_presents[1][i+1] and taux_presents[1][i+2] do
phrase_finale = phrase_finale .. taux_presents[1][i] .. ", "
i = i + 1
end
if taux_presents[1][i] and taux_presents[1][i+1]
then
local e = ""
if taux_presents[4][5] then e = "e" end
phrase_finale = phrase_finale .. taux_presents[1][i] .. " et " .. taux_presents[1][i+1]
.. "<br>sont les seul" .. e .. "s présent" .. e .. "s dans cette zone."
elseif taux_presents[1][i] then
local e = ""
if taux_presents[4][5] then e = "e" end
phrase_finale = phrase_finale .. taux_presents[1][i] .. "<br>est "
if taux_presents[4][5]
then phrase_finale = phrase_finale .. "la"
else phrase_finale = phrase_finale .. "le"
end
phrase_finale = phrase_finale .. " seul" .. e .. " présent" .. e .. " dans cette zone."
else
phrase_finale = "<p>" .. phrase_finale .. " n'est pas disponible dans cette zone.</p>"
end
end
end
-- Paramètre taux-absents
local taux_absents_arg = nil
if taux_presents == nil -- Si les taux présents ont déjà été définis, on passe cette étape
then taux_absents_arg = frame.args["taux-absents"]
end
if taux_absents_arg ~= nil
then
i = 1
colspan_taux = 0
local nombre_taux_absents = 0
local taux_presents_max = sous_taux[jeu] -- Le tableau qu'on va émincer pour ne garder que les taux présents
taux_presents = {{}, {}, {}, taux_presents_max[4]} -- Le tableau des taux qu'on va remplir
taux_absents = {{}, {}, {}, taux_presents_max[4]} -- Le tableau qui va servir à la phrase finale
taux_absents_arg = mw.text.split(taux_absents_arg, "/")
while taux_presents_max[2][i] do
taux_i = taux_presents_max[2][i]
j = 1
while taux_absents_arg[j] and taux_i ~= "taux-" .. taux_absents_arg[j] do
j = j + 1
end
if taux_absents_arg[j] == nil -- Pas trouvé !
then
table.insert(taux_presents[1], taux_presents_max[1][i])
table.insert(taux_presents[2], taux_presents_max[2][i])
table.insert(taux_presents[3], taux_presents_max[3][i])
colspan_taux = colspan_taux + 1
else
table.insert(taux_absents[1], taux_presents_max[1][i])
table.insert(taux_absents[2], taux_presents_max[2][i])
table.insert(taux_absents[3], taux_presents_max[3][i])
nombre_taux_absents = nombre_taux_absents + 1
end
i = i + 1
union_taux = false
end
-- Création de la phrase de bas de tableau
if nombre_taux_absents > 0 then
if nombre_taux_absents >= 2
then phrase_finale = "Les " .. taux_absents[4][3] .. " "
else if taux_absents[4][4] == "l'"
then phrase_finale = "L'"
else phrase_finale = mw.getContentLanguage():ucfirst(taux_absents[4][4]) .. " "
end
phrase_finale = phrase_finale .. taux_absents[4][2] .. " "
end
i = 1
while taux_absents[1][i] and taux_absents[1][i+1] and taux_absents[1][i+2] do
phrase_finale = phrase_finale .. taux_absents[1][i] .. ", "
i = i + 1
end
if taux_absents[1][i] and taux_absents[1][i+1]
then
local e = ""
if taux_absents[4][5] then e = "e" end
phrase_finale = phrase_finale .. taux_absents[1][i] .. " et " .. taux_absents[1][i+1]
.. " sont absent" .. e .. "s dans cette zone."
elseif taux_absents[1][i] then
local e = ""
if taux_absents[4][5] then e = "e" end
phrase_finale = phrase_finale .. taux_absents[1][i] .. " est absent" .. e .. " dans cette zone."
else
phrase_finale = phrase_finale .. " n'est pas disponible dans cette zone."
end
end
end
-- Si aucune restriction de taux n'a été appliquée, on prend par défaut celle associée au jeu.
if taux_presents == nil
then taux_presents = sous_taux[jeu]
end
-- Note de bas du tableau
note = frame.args["note"]
if note
then
if note == "barons communs"
then phrase_finale = "<p><i>En plus des [[Pokémon Baron|Barons]] fixes, tous les Pokémon sauvages communs de<br>"
.. "la zone ont 5 % de chances d'apparaître en tant que Pokémon Baron.</i></p>" .. phrase_finale
elseif note == "ligue"
then phrase_finale = "<p><i>Les niveaux présentés correspondent respectivement à<br>"
.. "avant et après la victoire contre la Ligue Pokémon.</i></p>" .. phrase_finale
elseif note == "éthernatos"
then phrase_finale = "<p><i>Les niveaux présentés correspondent respectivement à<br>"
.. "avant et après le combat contre Éthernatos.<br>"
.. "Les Pokémon vadrouilleurs de niveau 65 apparaissent une fois la Ligue vaincue.</i></p>" .. phrase_finale
elseif note == "trouée cachée"
then phrase_finale = "<p><i>Tous les Pokémon possèdent leur [[talent caché]].</i></p>" .. phrase_finale
elseif note == "zone extradimensionnelle"
then phrase_finale = "<p><i>Dans les zones extradimensionnelles, les Pokémon sauvages<br>"
.. "ont 1 % de chances d'apparaître en tant que Pokémon Baron.<br>"
.. "(Ce taux peut être affecté par des Auras Baron.)</i></p>" .. phrase_finale
colspan_niveau = 0
else phrase_finale = "<p><i>" .. note .. "</i></p>"
end
end
-- TAUX
local raccourcis_sous_taux = {
["taux-journée"] = {"taux-matin", "taux-jour"}
}
-- On remplace les raccourcis de taux
i = 1
local pokemon = frame.args[1]
if pokemon == nil
then pokemon = {}
else
for key, value in pairs(raccourcis_sous_taux) do
local replacement = ""
i = 1
while value[i] do
replacement = replacement .. value[i] .. "(%1) "
i = i + 1
end
local pattern = mw.ustring.gsub(key, "-", "%%-")
pokemon = mw.ustring.gsub(pokemon, pattern .. "%((.-)%)", replacement)
end
pokemon = mw.text.split(pokemon, "\n")
-- Fusion des lignes consécutives de même espèce et additionne les taux pour les couples niveau/version identiques
pokemon = merge_wild_lines(pokemon)
end
local colspan_etage = 0 -- étages de donjon mystère
local colspan_recrutement = 0 -- taux de recrutement de donjon mystère
local colspan_horaire = 0 -- checkmarks pour les moments de la journée (uniquement si le jeu n'a pas de taux)
local colspan_meteo = 0 -- checkmarks pour la météo (uniquement si le jeu n'a pas de taux)
local colspan_blocs_safari = 0 -- blocs du Parc Safari de Johto
local colspan_renfort = 0 -- renfort de SL/USUL et groupes de EV/LPZAmd
local renfort_has_niveaux = false -- le renfort possède-t-il une colonne de niveaux ?
local renfort_has_taux = false -- le renfort possède-t-il une colonne de taux ?
local renfort_string = "renfort" -- conjonction de renfort (SL/USUL) et groupes (EV/LPZAmd)
local union_horaire = true
local union_meteo = true
local horaires = sous_taux_dict["horaires"]
local meteos = sous_taux_dict["météos"]
local horaires_presents = horaires[jeu]
local meteos_presentes = meteos[jeu]
i = 1
-- Première boucle pour voir si on a affaire à des taux particuliers (si les taux doivent être divisés ou s'ils peuvent être réunis)
-- et des renforts.
while pokemon[i] do
-- Taux particuliers
if union_taux
then
j = 1
while taux_presents and taux_presents[2][j] do
-- le tiret est un caractère utilisé pour les noms de fonctions, mais aussi spécial pour les expressions rationnelles
if string.find(pokemon[i], mw.ustring.gsub(taux_presents[2][j], "%-", "%%-"))
then union_taux = false
end
j = j + 1
end
if not union_taux
then colspan_taux = j - 1 -- On récupère la longueur des taux
end
end
-- Étage
if colspan_etage == 0
then if string.find(pokemon[i], "étage%(")
then colspan_etage = 1
end
end
-- Taux de recrutement
if colspan_recrutement == 0
then if string.find(pokemon[i], "recrutement%(")
then colspan_recrutement = 1
end
end
-- Taux (notamment pour les jeux où le taux n'est affiché qu'en cas de besoin)
if colspan_taux == 0
then if string.find(pokemon[i], "taux%(")
then colspan_taux = 1
end
end
-- Horaires
if colspan_horaire == 0 and note ~= "zone extradimensionnelle"
then if string.find(pokemon[i], "horaire%(") or jeu == "LPA" or jeu == "EV" or jeu == "LPZA"
then if horaires_presents ~= nil
then union_horaire = false
colspan_horaire = #horaires_presents[1]
end
end
end
-- Météos
if colspan_meteo == 0 and note ~= "zone extradimensionnelle"
then if string.find(pokemon[i], "météo%(") or jeu == "LPA" or jeu == "LPZA"
then if meteos_presentes ~= nil
then union_meteo = false
colspan_meteo = #meteos_presentes[1]
end
end
end
-- Blocs Safari
if colspan_blocs_safari == 0
then if string.find(pokemon[i], "blocs%(") or string.find(pokemon[i], "attente%(")
then colspan_blocs_safari = 2
end
end
-- Renforts (SL/USUL) et groupes (EV/LPZAmd)
if not renfort_has_taux and string.find(pokemon[i], "renfort%[")
then colspan_renfort = 1
if not renfort_has_taux and string.find(pokemon[i], "taux%-renfort%(") then renfort_has_taux = true end
elseif (not renfort_has_niveaux or not renfort_has_taux) and string.find(pokemon[i], "groupe%[")
then renfort_string = "groupe"
colspan_renfort = 1
if not renfort_has_niveaux and string.find(pokemon[i], "niveaux%-groupe%(") then renfort_has_niveaux = true end
if not renfort_has_taux and string.find(pokemon[i], "taux%-groupe%(") then renfort_has_taux = true end
end
i = i + 1
end
-- EN-TÊTE
local rowspan_en_tete = 1
if not union_taux or not union_horaire or not union_meteo
then rowspan_en_tete = 2
end
local game_suffix = ""
local japan_class = ""
local taux_en_tete = "Taux"
if colspan_recrutement > 0 then taux_en_tete = "Taux<br>d'apparition" end
if colspan_renfort > 0
then if renfort_has_niveaux then colspan_renfort = colspan_renfort + 1 end
if renfort_has_taux then colspan_renfort = colspan_renfort + 1 end
end
local colspan_total = 1 + colspan_etage + colspan_niveau + colspan_recrutement + colspan_taux + colspan_horaire + colspan_meteo + colspan_blocs_safari + colspan_renfort
if jeu == "RV" then game_suffix = " <small>(Japon)</small>" end
if jeu == "RV" or jeu == "B-jp" then japan_class = "japonais" end
-- Toggle entre deux versions opposées
local versions_jeu = versions_opposees[jeu]
-- Construit le tableau complet pour la liste de Pokémon donnée
local function build_full_table(pokemon, header_label, toggle_html)
local resultat = {"<table class='tableaustandard centre tableau-overflow " .. japan_class .. "' style='max-width: 100%;'><tr><td colspan='"
.. colspan_total .. "' class='" .. bordure .. "'><b>" .. header_label .. "</b>" .. (toggle_html or "") .. "</td></tr>"}
if image then table.insert(resultat, "<tr><td colspan='" .. colspan_total .. "'>[[Fichier:" .. image .. "]]</td></tr>") end
if note == "zone extradimensionnelle"
then table.insert(resultat, "<tr><th rowspan='" .. rowspan_en_tete .. "'>Groupe</th>")
else table.insert(resultat, "<tr><th rowspan='" .. rowspan_en_tete .. "'>Pokémon</th>")
end
if colspan_etage > 0
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Étage</th>")
end
if colspan_niveau > 0
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Niveau</th>")
end
if colspan_recrutement > 0
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Taux de<br>recrutement</th>")
end
if colspan_taux == 1
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>" .. taux_en_tete .. "</th>")
elseif colspan_taux > 1
then table.insert(resultat, "<th colspan='" .. colspan_taux .. "'>" .. taux_en_tete .. "</th>")
end
if colspan_horaire == 1
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Horaire</th>")
elseif colspan_horaire > 1
then table.insert(resultat, "<th colspan='" .. colspan_horaire .. "'>Horaire</th>")
end
if colspan_meteo == 1
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Météo</th>")
elseif colspan_meteo > 1
then table.insert(resultat, "<th colspan='" .. colspan_meteo .. "'>Météo</th>")
end
if colspan_blocs_safari > 0
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Blocs</th><th rowspan='" .. rowspan_en_tete .. "'>Attente</th>")
end
if colspan_renfort > 0
then if renfort_string == "renfort"
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Intrusion</th>")
elseif renfort_string == "groupe"
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Pokémon du groupe</th>")
end
if renfort_has_niveaux
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Niveau</th>")
end
if renfort_has_taux
then if renfort_string == "renfort"
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Taux d'appel</th>")
elseif renfort_string == "groupe"
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Taux</th>")
end
end
end
table.insert(resultat, "</tr>")
if rowspan_en_tete ~= 1
then table.insert(resultat, "<tr>")
if not union_taux
then j = 1
while taux_presents[1][j] do
local color = taux_presents[3][j]
if color
then table.insert(resultat, "<th class='" .. color .. "'>[[Fichier:Icône " .. taux_presents[1][j]
.. " " .. jeu .. ".png|" .. taux_presents[1][j] .. "|link=" .. taux_presents[4][1] .. "|x25px]]</th>")
else table.insert(resultat, "<th>[[Fichier:Icône " .. taux_presents[1][j]
.. " " .. jeu .. ".png|" .. taux_presents[1][j] .. "|link=" .. taux_presents[4][1] .. "|x25px]]</th>")
end
j = j + 1
end
end
if not union_horaire
then j = 1
while horaires_presents[1][j] do
local color = horaires_presents[2][j]
if color
then table.insert(resultat, "<th class='" .. color .. "'>[[Fichier:Icône " .. horaires_presents[1][j]
.. " " .. jeu .. ".png|" .. horaires_presents[1][j] .. "|link=" .. horaires_presents[3][1] .. "|x25px]]</th>")
else table.insert(resultat, "<th>[[Fichier:Icône " .. taux_presents[1][j]
.. " " .. jeu .. ".png|" .. horaires_presents[1][j] .. "|link=" .. horaires_presents[3][1] .. "|x25px]]</th>")
end
j = j + 1
end
end
if not union_meteo
then j = 1
while meteos_presentes[1][j] do
local color = meteos_presentes[2][j]
if color
then table.insert(resultat, "<th class='" .. color .. "'>[[Fichier:Icône " .. meteos_presentes[1][j]
.. " " .. jeu .. ".png|" .. meteos_presentes[1][j] .. "|link=" .. meteos_presentes[3][1] .. "|x25px]]</th>")
else table.insert(resultat, "<th>[[Fichier:Icône " .. taux_presents[1][j]
.. " " .. jeu .. ".png|" .. meteos_presentes[1][j] .. "|link=" .. meteos_presentes[3][1] .. "|x25px]]</th>")
end
j = j + 1
end
end
table.insert(resultat, "</tr>")
end
-- Pokémon
local poke = {}
local poke_split = {}
local niveau = ""
local taux = ""
local renfort_poke = {}
local rowspan_ligne = 1
i = 1
while pokemon[i] do
poke = pokemon[i]
poke = mw.text.split(pokemon[i], " / ")
local nb_entrees = 1
while poke[nb_entrees + 1] do
nb_entrees = nb_entrees + 1
end
local rowspan_poke = 0
-- Instance de Pokémon sauvage
if nb_entrees >= 2 then
h = 2
-- On regarde le nombre de lignes nécessaires au total
local rowspan_lignes = {}
local renforts_poke = {}
local renforts_poke_unsplit = {}
while poke[h] do
local renfort_poke_unsplit = extract_argument_bracket(renfort_string, poke[h], "—")
renforts_poke_unsplit[h] = renfort_poke_unsplit
renforts_poke[h] = {}
local renfort_poke = mw.text.split(renfort_poke_unsplit, ", ")
j = 1
while renfort_poke[j] do
renforts_poke[h][j] = renfort_poke[j]
j = j + 1
end
rowspan_poke = rowspan_poke + math.max(1, j - 1)
rowspan_lignes[h] = j - 1
h = h + 1
end
poke_split = mw.text.split(poke[1], ", ")
if poke_split[2]
-- Cas de horde
then table.insert(resultat, '<tr><td rowspan="' .. rowspan_poke .. '">')
j = 1
while poke_split[j] do
table.insert(resultat, ressources.infosPokemon(poke_split[j] .. jeu_miniature, "miniature"))
-- Retour à la ligne pour en montrer 2 sur la première ligne et 3 sur la seconde, comme dans les jeux
if j == 2
then table.insert(resultat, '<br>')
end
j = j + 1
end
table.insert(resultat, "</td>")
-- Cas classique, un seul Pokémon
else
-- Affichage chromatique uniquement pour les jeux concernés
local chromatique = ""
if (jeu == "LPA" or jeu == "LPZA") and poke[2]:find("précision%-taux%(Chromatique%)")
then chromatique = " chromatique(oui)"
end
table.insert(resultat, '<tr><td rowspan="' .. rowspan_poke .. '" style="text-align:left">'
.. ressources.infosPokemon(poke_split[1] .. chromatique .. jeu_miniature) .. "</td>")
end
h = 2
while poke[h] do
if h ~= 2 then table.insert(resultat, "<tr>") end
infos = poke[h]
-- On regarde combien de Pokémon peuvent être en renforts dans cette ligne
local rowspan_ligne = rowspan_lignes[h]
-- On regroupe les renforts avec les lignes d'après s'il n'y en a qu'un et que ce sont les mêmes
-- On vérifie quand même au préalable que ce n'est pas déjà regroupé avec la ligne d'avant
local is_renfort_alone_and_same_than_pred = false
local renfort_poke = renforts_poke[h]
local renfort_poke_unsplit = renforts_poke_unsplit[h]
local renfort_pred = nil
local renfort_pred_unsplit = nil
local rowspan_renfort = 1
if h ~= 1
then renfort_pred = renforts_poke[h-1]
renfort_pred_unsplit = renforts_poke_unsplit[h-1]
end
if not renfort_poke[2]
then if renfort_pred_unsplit == renfort_poke_unsplit
then is_renfort_alone_and_same_than_pred = true
else
local hh = h + 1
while poke[hh] do
local renfort_next_unsplit = renforts_poke_unsplit[hh]
if renfort_next_unsplit == renfort_poke_unsplit
then rowspan_renfort = rowspan_renfort + 1
else break
end
hh = hh + 1
end
end
else
end
-- Ajout de l'étage
if colspan_etage > 0
then
local etage_unsplit = extract_argument("étage", infos, "—")
local etage_pred = extract_argument("étage", poke[h-1], "—")
if not etage then etage = "—" end
local etage = mw.text.split(etage_unsplit, ", ")
local rowspan_etage = rowspan_ligne
if h == 2 or etage_unsplit ~= etage_pred
then
local hh = h + 1
while poke[hh] do
local etage_next = extract_argument("étage", poke[hh], "—")
if etage_next == etage_unsplit
then rowspan_etage = rowspan_etage + rowspan_lignes[hh]
else break
end
hh = hh + 1
end
local etage_text = etage[1]
j = 2
while etage[j] do
etage_j_number = mw.ustring.gsub(mw.ustring.gsub(mw.ustring.gsub(mw.ustring.gsub(etage[j], "–", ""), "-", ""), " à ", ""), " et ", "")
if tonumber(etage_j_number)
then etage_text = etage_text .. "<br>" .. etage[j]
else etage_text = etage_text .. frame:expandTemplate{title='Sup', args={etage[j]}}
end
j = j + 1
end
etage_text = mw.ustring.gsub(etage_text, "-", "−") -- signe moins typographique pour les étages négatifs
table.insert(resultat, "</td><td rowspan='" .. rowspan_etage .. "'>" .. etage_text .. "</td>")
end
end
-- Ajout du niveau
function add_level(niveau_unsplit, jeu)
local niveau = mw.ustring.gsub(niveau_unsplit, "-", "–")
niveau = mw.text.split(niveau, ", ")
niveau_text = ""
-- niveau_j-1 est-il un taux ou un sup ?
local is_pred_rate = false
j = 1
while niveau[j] do
-- Préfixe Baron
baron_image = ""
if niveau[j]:find("Baron ")
then baron_image = "[[Fichier:Icône Pokémon Baron " .. jeu .. ".png|x20px|link=Pokémon Baron]] "
niveau[j] = niveau[j]:gsub("Baron ", "")
end
niveau_j_number = mw.ustring.gsub(niveau[j], "–", "")
if niveau_j_number == "" then
if j ~= 1 then niveau_text = niveau_text .. "<br>" end
niveau_text = niveau_text .. baron_image .. "—"
is_pred_rate = true
elseif not is_pred_rate or tonumber(niveau_j_number) then
if j ~= 1 then niveau_text = niveau_text .. "<br>" end
niveau_text = niveau_text .. baron_image .. niveau[j]
is_pred_rate = true
else
niveau_text = niveau_text .. frame:expandTemplate{title='Sup', args={niveau[j]}}
is_pred_rate = false
end
j = j + 1
end
return niveau_text
end
if colspan_niveau >= 1
then local niveau = extract_argument("niveau", infos, "—")
local niveau_pred = extract_argument("niveau", poke[h-1], "—")
local rowspan_niveau = rowspan_ligne
if h == 2 or niveau ~= niveau_pred
then
local hh = h + 1
while poke[hh] do
local niveau_next = extract_argument("niveau", poke[hh], nil)
if niveau_next == niveau
then rowspan_niveau = rowspan_niveau + rowspan_lignes[hh]
else break
end
hh = hh + 1
end
local niveau_text = add_level(niveau, jeu)
table.insert(resultat, "</td><td style='white-space:nowrap' rowspan='" .. rowspan_niveau .. "'>" .. niveau_text .. "</td>")
end
end
-- Ajout des taux
function add_rate(rate, rate_precision, colspan, rowspan, class)
local seen_games_here = nil
rate = mw.text.split(rate, ", ")
if rate[1] == "-"
then rate[1] = "—"
else
if tonumber(rate[1])
then rate[1] = mw.ustring.gsub(mw.ustring.gsub(rate[1], "%.", ","), "-", "−") .. " %"
else rate[1] = mw.ustring.gsub(rate[1], "{{!}}", "|")
end
if rate[1] == "Fixe" then rate[1] = "[[Fichier:Icône Fixe.svg|class=imagenoire|27px|link=|alt=Fixe|Fixe]]" end
end
table.insert(resultat, "<td")
if colspan then table.insert(resultat, ' colspan="' .. colspan .. '"') end
if rowspan then table.insert(resultat, ' rowspan="' .. rowspan .. '"') end
if class then table.insert(resultat, ' class="' .. class .. '"') end
table.insert(resultat, '>' .. rate[1])
local k = 2
while rate[k] do -- Gestion des taux spécifiques à des jeux
if tonumber(rate[k])
then table.insert(resultat, "<br>" .. mw.ustring.gsub(mw.ustring.gsub(rate[k], "%.", ","), "-", "−") .. " %") -- signe moins typographique pour les taux négatifs
else table.insert(resultat, frame:expandTemplate{title='Sup', args={rate[k]}})
end
k = k + 1
end
if rate_precision then table.insert(resultat, '<br><small><i>' .. rate_precision .. '</i></small>') end
table.insert(resultat, "</td>")
end
-- Taux de recrutement
if colspan_recrutement > 0
then
local taux_recrutement = extract_argument("recrutement", infos, "—")
local taux_recrutement_pred = extract_argument("recrutement", poke[h-1], "—")
if not taux_recrutement then taux_recrutement = "—" end
local rowspan_recrutement = rowspan_ligne
if h == 2 or taux_recrutement ~= taux_recrutement_pred
then
local hh = h + 1
while poke[hh] do
local taux_recrutement_next = extract_argument("recrutement", poke[hh], "—")
if taux_recrutement_next == taux_recrutement
then rowspan_recrutement = rowspan_recrutement + rowspan_lignes[hh]
else break
end
hh = hh + 1
end
if taux_recrutement == "-" then taux_recrutement = "Non recrutable" end
local precision_taux_recrutement = extract_argument("précision-recrutement", infos, nil)
add_rate(taux_recrutement, precision_taux_recrutement, nil, rowspan_recrutement, nil)
end
end
-- Taux d'apparition
if colspan_taux > 0
then if union_taux
then
-- Configuration où les taux ne varient jamais
local taux = extract_argument("taux", infos, "—")
local precision_taux = extract_argument("précision-taux", infos, nil)
add_rate(taux, precision_taux, nil, rowspan_ligne, nil)
else
local taux = extract_argument("taux", infos, "—")
if taux == "—"
then
-- Sur une configuration où les taux sont divisés, cas d'un Pokémon qui plusieurs taux différents
j = 1
while taux_presents[2][j] do
local taux_j = extract_argument(taux_presents[2][j], infos, "—")
local precision_taux_j = extract_argument("précision-" .. taux_presents[2][j], infos, nil)
local color = taux_presents[3][j]
add_rate(taux_j, precision_taux_j, nil, rowspan_ligne, color)
j = j + 1
end
else
-- Sur une configuration où les taux sont divisés, cas d'un Pokémon qui a un taux unique
local precision_taux = extract_argument("précision-taux", infos, nil)
add_rate(taux, precision_taux, colspan_taux, rowspan_ligne, nil)
table.insert(resultat, "</td>")
end
end
end
-- Horaires
if colspan_horaire > 0
then
local horaire = extract_argument("horaire", infos, nil)
if horaire ~= nil
then
local horaire_split = mw.text.split(horaire, ", ")
j = 1
-- On parcourt tous les horaires pour voir lesquels sont listés
while horaires_presents[1][j] do
local horaire_j = ""
k = 1
while horaire_split[k] do
if horaires_presents[1][j] == horaire_split[k] then horaire_j = "✓" end
k = k + 1
end
local color = horaires_presents[2][j]
add_rate(horaire_j, nil, nil, rowspan_ligne, color)
j = j + 1
end
else
-- Pas d'horaire précisé, on met une checkmark partout
add_rate("✓", nil, colspan_horaire, rowspan_ligne, nil)
table.insert(resultat, "</td>")
end
end
-- Météos
if colspan_meteo > 0
then
local meteo = extract_argument("météo", infos, nil)
if meteo ~= nil
then
local meteo_split = mw.text.split(meteo, ", ")
j = 1
-- On parcourt tous les horaires pour voir lesquels sont listés
while meteos_presentes[1][j] do
local meteo_j = ""
k = 1
while meteo_split[k] do
if meteos_presentes[1][j] == meteo_split[k] then meteo_j = "✓" end
k = k + 1
end
local color = meteos_presentes[2][j]
add_rate(meteo_j, nil, nil, rowspan_ligne, color)
j = j + 1
end
else
-- Pas d'horaire précisé, on met une checkmark partout
add_rate("✓", nil, colspan_meteo, rowspan_ligne, nil)
table.insert(resultat, "</td>")
end
end
-- Ajout des Blocs du Parc Safari
if colspan_blocs_safari > 0
then
local j = 1
local blocs_unsplit = extract_argument("blocs", infos, "—")
local blocs_pred = extract_argument("blocs", poke[h-1], "—")
local blocs = mw.ustring.gsub(blocs_unsplit, ", ", "<br>")
local attente_default
if blocs_unsplit ~= "—" then attente_default = "Immédiatement" else attente_default = "—" end
local attente = extract_argument("attente", infos, attente_default)
if tonumber(attente)
then if tonumber(attente) >= 2
then attente = attente .. " jours"
else attente = attente .. " jour"
end
end
if blocs_pred ~= "—" then attente_default = "Immédiatement" else attente_default = "—" end
local attente_pred = extract_argument("attente", poke[h-1], attente_default)
if tonumber(attente_pred)
then if tonumber(attente_pred) >= 2
then attente_pred = attente_pred .. " jours"
else attente_pred = attente_pred .. " jour"
end
end
local rowspan_blocs = rowspan_ligne
local rowspan_attente = rowspan_ligne
local extending_blocs_beginning = h > 2 and blocs_unsplit == blocs_pred
local extending_attente_beginning = h > 2 and attente == attente_pred
if not (extending_blocs_beginning and extending_attente_beginning)
then
local hh = h + 1
local extending_blocs = extending_blocs_beginning
local extending_attente = extending_attente_beginning
while poke[hh] do
local blocs_next = extract_argument("blocs", poke[hh], "—")
if not extending_blocs and blocs_next == blocs_unsplit
then rowspan_blocs = rowspan_blocs + rowspan_lignes[hh]
else extending_blocs = true
end
if not extending_attente
then if blocs_next ~= "—" then attente_default = "Immédiatement" else attente_default = "—" end
local attente_next = extract_argument("attente", poke[hh], attente_default)
if tonumber(attente_next)
then if tonumber(attente_next) >= 2
then attente_next = attente_next .. " jours"
else attente_next = attente_next .. " jour"
end
end
if attente == attente_next
then rowspan_attente = rowspan_attente + rowspan_lignes[hh]
else extending_attente = true
end
end
if extending_blocs and extending_attente then break end
hh = hh + 1
end
if h == 2 or not extending_blocs_beginning
then table.insert(resultat, '<td rowspan="' .. rowspan_blocs .. '">' .. blocs .. '</td>')
end
if h == 2 or not extending_attente_beginning
then table.insert(resultat, '<td rowspan="' .. rowspan_attente .. '">' .. attente .. '</td>')
end
end
end
-- Ajout du renfort
if not is_renfort_alone_and_same_than_pred and colspan_renfort > 0
then
k = 1
local renfort_niveaux = extract_argument("niveaux-" .. renfort_string, infos, "—")
renfort_niveaux = mw.text.split(renfort_niveaux, " ; ")
local renfort_taux = extract_argument("taux-" .. renfort_string, infos, "100")
renfort_taux = mw.text.split(renfort_taux, ", ")
if renfort_poke[1] == "—"
-- Cas où le Pokémon n'a pas de renforts, mais d'autres en ont
then table.insert(resultat, '<td colspan="' .. colspan_renfort .. '" style="background-color:#F0F0F0" rowspan="'
.. rowspan_renfort .. '">—</td>')
else
while renfort_poke[k] do
if k >= 2 then table.insert(resultat, "<tr>") end
local image_renfort = ""
if renfort_string == "renfort"
then image_renfort = "[[Fichier:Miniature Orbe Frousse SL.png|link=Intrusion]] "
end
table.insert(resultat, '<td style="text-align:left; white-space:nowrap; background-color:#F0F0F0" rowspan="' .. rowspan_renfort
.. '">' .. image_renfort .. ressources.infosPokemon(renfort_poke[k] .. jeu_miniature) .. '</td>')
if renfort_has_niveaux
then
local renfort_niveau_k = renfort_niveaux[k]
if not (renfort_niveaux[k-1] and renfort_niveaux[k-1] == renfort_niveaux[k])
then if renfort_niveau_k == nil or renfort_niveau_k == "-" then renfort_niveau_k = "—" end
local rowspan_renfort_niveaux = rowspan_renfort
local kk = k + 1
while renfort_niveaux[kk] do
if renfort_niveaux[kk] == renfort_niveaux[k]
then rowspan_renfort_niveaux = rowspan_renfort_niveaux + 1
else break
end
kk = kk + 1
end
renfort_niveau_k_text = add_level(renfort_niveau_k, jeu)
table.insert(resultat, '<td style="background-color:#F0F0F0; white-space:nowrap" rowspan="' .. rowspan_renfort_niveaux
.. '">' .. renfort_niveau_k_text .. '</td>')
end
end
if renfort_has_taux
then
local renfort_taux_k = renfort_taux[k]
if renfort_taux_k == nil or renfort_taux_k == "-" then renfort_taux_k = "100" end
if tonumber(renfort_taux_k) then renfort_taux_k = mw.ustring.gsub(mw.ustring.gsub(renfort_taux_k, "%.", ","), "-", "−") .. " %" end
table.insert(resultat, '<td style="background-color:#F0F0F0" rowspan="' .. rowspan_renfort
.. '">' .. renfort_taux_k .. '</td>')
end
k = k + 1
end
end
end
table.insert(resultat, "</tr>")
h = h + 1
end
-- Ligne de changement d'endroit de Poké sauvage
elseif poke[1] then
local endroit_unsplit = mw.text.split(poke[1], ",, ")
local prefixe_endroit = endroit_unsplit[2] -- éventuellement nil
local endroit = mw.text.split(endroit_unsplit[1], ",")
local endroit_untouched = endroit[1]
if prefixe_endroit == nil
then prefixe_endroit = ""
else prefixe_endroit = prefixe_endroit .. " "
if endroit[1]:sub(1,2) == "É"
then endroit[1] = "é" .. endroit[1]:sub(3, endroit[1]:len())
else endroit[1] = endroit[1]:sub(1,1):lower() .. endroit[1]:sub(2, endroit[1]:len())
end -- on a mis la première lettre de l'endroit en minuscule, puisqu'elle est précédée de prefixe_endroit
end
if endroit[2] == nil then endroit[2] = "" end
-- Seule la première virgule sert à séparer
k = 3
while endroit[k] ~= nil do
endroit[2] = endroit[2] .. ", " .. endroit[k]
k = k + 1
end
endroit[2] = mw.ustring.gsub(endroit[2], "{{!}}", "|")
local template_replacement = mw.ustring.gsub(endroit[2], ".*{{(.-)|(.-)}}.*", "%1") -- sert à process les modèles, qu'ils utilisent "|" ou "{{!}}"
local templates_replaced = 0
while template_replacement ~= endroit[2] and templates_replaced < 4 do -- pour empêcher une boucle infinie en cas de pépin, 4 modèles max devraient suffire
local arg_template_teplacement = mw.ustring.gsub(endroit[2], ".*{{(.-)|(.-)}}.*", "%2")
local template_result = frame:expandTemplate{title=template_replacement, args={arg_template_teplacement}}
endroit[2] = mw.ustring.gsub(endroit[2], "(.*){{(.-)|(.-)}}(.*)", "%1" .. template_result .. "%4")
local template_replacement = mw.ustring.gsub(endroit[2], ".*{{(.-)|(.-)}}.*", "%1")
templates_replaced = templates_replaced + 1
end
if endroit[1] ~= ""
then
local milieu = milieu_sauvage[jeu]
if milieu ~= nil then milieu = milieu[endroit_untouched] end
if milieu == nil
then milieu = "'>[[Catégorie:Article avec un milieu de capture non normalisé]]" .. prefixe_endroit .. endroit[1] .. endroit[2]
else
-- Si aucun nom n'est précisé dans les données des milieux, on prend celui par défaut (celui indiqué)
if milieu:sub(-6, -1) == ".png]]" or milieu:sub(-4, -1) == "px]]"
then milieu = milieu .. " " .. prefixe_endroit .. endroit[1] .. endroit[2]
else milieu = milieu .. endroit[2]
end
end
table.insert(resultat, "<tr><th colspan='" .. colspan_total .. "' class='" .. milieu .. "</th></tr>")
end
end
i = i + 1
end
if phrase_finale ~= ""
then table.insert(resultat, "<tr><td style='white-space: nowrap' colspan='" .. colspan_total .. "'><i>" .. phrase_finale .. "</i></td></tr>")
end
table.insert(resultat, '</table>')
return table.concat(resultat, "")
end
local sortie
if versions_jeu == nil
then
-- Jeu simple = un seul tableau
sortie = build_full_table(pokemon, frame:expandTemplate{title='Jeu', args={jeu}} .. game_suffix, nil)
else
-- Jeu double = trois tableaux, un seul affiché à la fois (voir build_toggle_links)
toggle_counter = toggle_counter + 1
local toggle_id = "tggl-tableau-pokemon-" .. toggle_counter
local pokemon_v1 = filter_pokemon_lines(pokemon, versions_jeu[1], versions_jeu[3])
local pokemon_v2 = filter_pokemon_lines(pokemon, versions_jeu[3], versions_jeu[1])
local function entete_version(nom)
return "''[[Pokémon " .. nom .. "]]''"
end
local table_deux = build_full_table(pokemon, frame:expandTemplate{title='Jeu', args={jeu}} .. game_suffix,
build_toggle_links(toggle_id, versions_jeu, "deux"))
local table_v1 = build_full_table(pokemon_v1, entete_version(versions_jeu[2]), build_toggle_links(toggle_id, versions_jeu, "v1"))
local table_v2 = build_full_table(pokemon_v2, entete_version(versions_jeu[4]), build_toggle_links(toggle_id, versions_jeu, "v2"))
sortie = "<div class='mw-collapsible' id='mw-customcollapsible-" .. toggle_id .. "-deux'>" .. table_deux .. "</div>"
.. "<div class='mw-collapsible mw-collapsed' id='mw-customcollapsible-" .. toggle_id .. "-v1'>" .. table_v1 .. "</div>"
.. "<div class='mw-collapsible mw-collapsed' id='mw-customcollapsible-" .. toggle_id .. "-v2'>" .. table_v2 .. "</div>"
end
if fetching_loc then sortie = sortie .. "[[Catégorie:Page avec un module Tableau Pokémon]]" end
return sortie
end
function p.antre(frame)
local pokemon = frame.args[1]
if pokemon ~= nil then pokemon = mw.text.split(pokemon, "\n") else pokemon = {} end
local page = frame.args["page"]
local pagename = frame:preprocess("{{PAGENAME}}")
local fetching_loc = frame.args["localisations"]
fetching_loc = fetching_loc ~= "non"
local i = 1
local j = 1
local k = 1
taux_presents = {{"★<br><i><small>(Niveau 15–20)</small></i>", "★★<br><i><small>(Niveau 25–30)</small></i>",
"★★★<br><i><small>(Niveau 35–40)</small></i>", "★★★★<br><i><small>(Niveau 45–50)</small></i>",
"★★★★★<br><i><small>(Niveau 55–60)</small></i>"},
{"1", "2", "3", "4", "5"},
{"raid1", "raid2", "raid3", "raid4", "raid5"}}
-- Première boucle pour voir si on a affaire à des notes/remarques sur certains Pokémon
i = 1
local colspan_notes = 0
while pokemon[i] do
poke = mw.text.split(pokemon[i], "/")
local h = 2
while poke[h] do
if extract_argument("notes", poke[h], nil)
then colspan_notes = 1
break
end
h = h + 1
end
if colspan_notes == 1 then break end
i = i + 1
end
local colspan_taux = 5
local rowspan_en_tete = 2
-- EN-TÊTE
local resultat = {"<table class='tableaustandard centre' style='max-width: 100%;'><tr>"
.. "<th rowspan='" .. rowspan_en_tete .. "'>Pokémon</th><th rowspan='" .. rowspan_en_tete .. "'>Talent caché</th><th rowspan='"
.. rowspan_en_tete .. "'>[[IV]] parfaits<br>garantis</th><th colspan='" .. colspan_taux .. "'>Taux"}
if page ~= nil and page ~= pagename
then table.insert(resultat, frame:preprocess(" ([[" .. page .. "|source]])"))
end
table.insert(resultat, "</th>")
if colspan_notes > 0
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Notes</th>")
end
table.insert(resultat, "</tr>")
j = 1
table.insert(resultat, "<tr>")
while taux_presents[1][j] do
local color = taux_presents[3][j]
if color
then table.insert(resultat, "<th class='" .. color .. "'>" .. taux_presents[1][j] .. "</th>")
else table.insert(resultat, "<th>taux_presents[1][j]</th>")
end
j = j + 1
end
table.insert(resultat, "</tr>")
-- Pokémon
local poke = {}
local poke_split = {}
local niveau = ""
local taux = ""
local renfort_poke = {}
local rowspan_ligne = 1
i = 1
while pokemon[i] do
poke = mw.text.split(pokemon[i], "/")
local nb_entrees = 1
while poke[nb_entrees + 1] do
nb_entrees = nb_entrees + 1
end
local rowspan_poke = 0
-- Instance de Pokémon sauvage
if nb_entrees >= 2 then
h = 2
-- On regarde le nombre de lignes nécessaires au total
while poke[h] do
rowspan_poke = rowspan_poke + 1
h = h + 1
end
table.insert(resultat, '<tr><td rowspan="' .. rowspan_poke .. '" style="text-align:left">'
.. ressources.infosPokemon(poke[1] .. " jeu(EB)") .. "</td>")
h = 2
while poke[h] do
if h ~= 2 then table.insert(resultat, "<tr>") end
infos = poke[h]
talent_cache = extract_argument("talent-caché", infos, nil)
local talent_cache_pred = extract_argument("talent-caché", poke[h-1], nil)
local rowspan_talent_cache = 1
if h == 2 or talent_cache ~= talent_cache_pred
then
local hh = h + 1
while poke[hh] do
local talent_cache_next = extract_argument("talent-caché", poke[hh], nil)
if talent_cache_next == talent_cache
then rowspan_talent_cache = rowspan_talent_cache + 1
else break
end
hh = hh + 1
end
if talent_cache == "Possible"
then table.insert(resultat, "<td rowspan='" .. rowspan_talent_cache .. "'class='résistance'>Possible</td>")
elseif talent_cache == "Toujours"
then table.insert(resultat, "<td rowspan='" .. rowspan_talent_cache .. "'class='standard'>Toujours</td>")
elseif talent_cache == "Impossible" or talent_cache == nil
then table.insert(resultat, "<td rowspan='" .. rowspan_talent_cache .. "'class='faiblesse'>Impossible</td>")
else table.insert(resultat, "<td rowspan='" .. rowspan_talent_cache .. "'>" .. talent_cache .. "</td>")
end
end
local iv_unsplit = extract_argument("iv", infos, "—")
local iv_pred = extract_argument("iv", poke[h-1], nil)
iv = mw.text.split(iv_unsplit, ", ")
local rowspan_iv = 1
if h == 2 or iv_unsplit ~= iv_pred
then
local hh = h + 1
while poke[hh] do
local iv_next = extract_argument("iv", poke[hh], nil)
if iv_next == iv_unsplit
then rowspan_iv = rowspan_iv + 1
else break
end
hh = hh + 1
end
table.insert(resultat, "<td rowspan='" .. rowspan_iv .. "'>" .. iv[1])
j = 2
while iv[j] do
if tonumber(iv[j])
then table.insert(resultat, "<br>" .. iv[j])
else table.insert(resultat, frame:expandTemplate{title='Sup', args={iv[j]}})
end
j = j + 1
end
table.insert(resultat, "</td>")
end
taux = extract_argument("taux", infos, "—")
if taux == "—"
then
-- Cas d'un Pokémon qui plusieurs taux différents
j = 1
while taux_presents[2][j] do
local taux_j = extract_argument(taux_presents[2][j], infos, "—")
taux_j = mw.text.split(taux_j, ", ")
local precision_taux_j = extract_argument("précision-" .. taux_presents[2][j], infos, nil)
if tonumber(taux_j[1]) then taux_j[1] = mw.ustring.gsub(taux_j[1], "%.", ",") .. " %" end
local color = taux_presents[3][j]
if color
then table.insert(resultat, "<td class='" .. color .. "' rowspan='" .. rowspan_ligne
.. "'>" .. taux_j[1])
else table.insert(resultat, "<td rowspan='" .. rowspan_ligne .. "'>" .. taux_j[1])
end
k = 2
while taux_j[k] do -- Gestion des taux spécifiques à des jeux
if tonumber(taux_j[k])
then table.insert(resultat, "<br>" .. mw.ustring.gsub(taux_j[k], "%.", ",") .. " %")
else table.insert(resultat, frame:expandTemplate{title='Sup', args={taux_j[k]}})
end
k = k + 1
end
if precision_taux_j then table.insert(resultat, '<br><small><i>' .. precision_taux_j .. '</i></small>') end
table.insert(resultat, "</td>")
j = j + 1
end
else
-- Cas d'un Pokémon qui a un taux unique
local precision_taux = extract_argument("précision-taux", infos, nil)
taux = mw.text.split(taux, ", ")
if tonumber(taux[1]) then taux[1] = mw.ustring.gsub(taux[1], "%.", ",") .. " %" end
table.insert(resultat, '<td colspan="' .. colspan_taux .. '">' .. taux[1])
j = 2
while taux[j] do -- Gestion des taux spécifiques à des jeux
if tonumber(taux[j])
then table.insert(resultat, "<br>" .. mw.ustring.gsub(taux[j], "%.", ",") .. " %")
else table.insert(resultat, frame:expandTemplate{title='Sup', args={taux[j]}})
end
j = j + 1
end
if precision_taux then table.insert(resultat, '<br><small><i>' .. precision_taux .. '</i></small>') end
table.insert(resultat, "</td>")
end
-- Notes (colonne optionnelle)
if colspan_notes > 0
then
local notes_unsplit = extract_argument("notes", infos, "—")
local notes_pred = extract_argument("notes", poke[h-1], "—")
notes = mw.text.split(notes_unsplit, ", ")
local rowspan_notes = 1
if h == 2 or notes_unsplit ~= notes_pred
then
local hh = h + 1
while poke[hh] do
local notes_next = extract_argument("notes", poke[hh], "—")
if notes_next == notes_unsplit
then rowspan_notes = rowspan_notes + 1
else break
end
hh = hh + 1
end
table.insert(resultat, "<td rowspan='" .. rowspan_notes .. "'>")
j = 1
while notes[j] do
-- Expansion de certaines notes
if notes[j] == "Toujours chromatique"
then notes[j] = "[[Fichier:Miniature Chromatique EB.png|x15px|link=Pokémon chromatique|Ce Pokémon est toujours chromatique.]]"
.. " Toujours chromatique"
elseif notes[j] == "Doté du gène Gigamax"
then notes[j] = "[[Fichier:Miniature Gigamax EB.png|x15px|link=Gigamax|Gigamax]] Doté du gène Gigamax"
end
if j == 1
then table.insert(resultat, notes[j])
else table.insert(resultat, "<br>" .. notes[j])
end
j = j + 1
end
table.insert(resultat, "</td>")
end
end
h = h + 1
end
end
i = i + 1
end
table.insert(resultat, '</table>')
if fetching_loc and (page == nil or page == pagename) then table.insert(resultat, "[[Catégorie:Page avec un module Tableau Pokémon]]") end
return table.concat(resultat, "")
end
function p.teracristal(frame)
local data_capacites = require("Module:Data/TypesCapacités")
local id_separator = "_"
-- Fonction intermédiaire qui transforme une capacité en une ligne avec le type et le lien de la capacité
function capacite_to_line(capacite, type_teracristal)
local link_capacite = capacite
local image_capacite = ""
local type_capacite = data_capacites[capacite]
if (capacite == "Téra Explosion" or capacite == "Danse Éveil") and type_teracristal ~= nil and type_teracristal ~= "Par défaut"
then type_capacite = type_teracristal
elseif type_capacite == nil
then type_capacite = data_capacites[capacite .. " (capacité)"]
if type_capacite ~= nil
then link_capacite = capacite .. " (capacité)"
end
end
if type_capacite ~= nil
then image_capacite = "[[Fichier:Icône Type " .. type_capacite .. " EV.png|x20px|link=" .. type_capacite .. " (type)|alt=" .. type_capacite .. "]] "
end
return image_capacite .. " [[" .. link_capacite .. "|" .. capacite .. "]]"
end
local pokemon = frame.args[1]
if pokemon ~= nil then pokemon = mw.text.split(pokemon, "\n") else pokemon = {} end
-- local page = frame.args["page"]
-- local pagename = frame:preprocess("{{PAGENAME}}")
local fetching_loc = frame.args["localisations"]
fetching_loc = fetching_loc ~= "non"
local i = 1
local j = 1
local k = 1
-- Première boucle pour voir si on a affaire à des notes/remarques sur certains Pokémon
i = 1
local colspan_notes = 0
while pokemon[i] do
poke = mw.text.split(pokemon[i], "/")
local h = 2
while poke[h] do
if extract_argument("notes", poke[h], nil)
then colspan_notes = 1
break
end
h = h + 1
end
if colspan_notes == 1 then break end
i = i + 1
end
local coslpan_capacites = 2
local rowspan_en_tete = 2
-- EN-TÊTE
local resultat = {"<table class='tableaustandard centre' style='max-width: 100%;'><tr>"
.. "<th rowspan='" .. rowspan_en_tete .. "'>Pokémon</th><th rowspan='" .. rowspan_en_tete .. "'>Type Téracristal</th><th rowspan='" .. rowspan_en_tete .. "'>Talent caché</th><th rowspan='"
.. rowspan_en_tete .. "'>Difficulté</th><th colspan='" .. coslpan_capacites .. "'>Capacités</th>"}
if colspan_notes > 0
then table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Notes</th>")
end
table.insert(resultat, "<th rowspan='" .. rowspan_en_tete .. "'>Récompenses</th></tr>")
table.insert(resultat, "<tr><th>À la capture</th><th>Supplémentaires</th></tr>")
-- Pokémon
local poke = {}
local poke_split = {}
local niveau = ""
local taux = ""
local renfort_poke = {}
local rowspan_ligne = 1
local id_dict = {}
i = 1
while pokemon[i] do
poke = mw.text.split(pokemon[i], "/")
local nb_entrees = 1
while poke[nb_entrees + 1] do
nb_entrees = nb_entrees + 1
end
local rowspan_poke = 0
-- Instance de Pokémon sauvage
if nb_entrees >= 2 then
h = 2
-- On regarde le nombre de lignes nécessaires au total
while poke[h] do
rowspan_poke = rowspan_poke + 1
h = h + 1
end
table.insert(resultat, '<tr><td rowspan="' .. rowspan_poke .. '" style="text-align:left">'
.. ressources.infosPokemon(poke[1] .. " jeu(EV)") .. "</td>")
h = 2
while poke[h] do
if h ~= 2 then table.insert(resultat, "<tr>") end
infos = poke[h]
-- Type Téracristal
local type_teracristal = extract_argument("type-téracristal", infos, nil)
local type_teracristal_pred = extract_argument("type-téracristal", poke[h-1], nil)
local rowspan_type_teracristal = 1
if h == 2 or type_teracristal ~= type_teracristal_pred
then
local hh = h + 1
while poke[hh] do
local type_teracristal_next = extract_argument("type-téracristal", poke[hh], nil)
if type_teracristal_next == type_teracristal
then rowspan_type_teracristal = rowspan_type_teracristal + 1
else break
end
hh = hh + 1
end
table.insert(resultat, "<td rowspan='" .. rowspan_type_teracristal .. "'>")
if type_teracristal == nil
then table.insert(resultat, "Aléatoire")
elseif type_teracristal == "Par défaut"
then table.insert(resultat, type_teracristal)
else
table.insert(resultat, frame:expandTemplate{title='Type', args={type_teracristal, ["téra"] = "oui"}})
end
table.insert(resultat, "</td>")
end
-- Talent caché
local talent_cache = extract_argument("talent-caché", infos, nil)
local talent_cache_pred = extract_argument("talent-caché", poke[h-1], nil)
local rowspan_talent_cache = 1
if h == 2 or talent_cache ~= talent_cache_pred
then
local hh = h + 1
while poke[hh] do
local talent_cache_next = extract_argument("talent-caché", poke[hh], nil)
if talent_cache_next == talent_cache
then rowspan_talent_cache = rowspan_talent_cache + 1
else break
end
hh = hh + 1
end
if talent_cache == "Possible"
then table.insert(resultat, "<td rowspan='" .. rowspan_talent_cache .. "'class='résistance'>Possible</td>")
elseif talent_cache == "Toujours"
then table.insert(resultat, "<td rowspan='" .. rowspan_talent_cache .. "'class='standard'>Toujours</td>")
elseif talent_cache == "Impossible" or talent_cache == nil
then table.insert(resultat, "<td rowspan='" .. rowspan_talent_cache .. "'class='faiblesse'>Impossible</td>")
else table.insert(resultat, "<td rowspan='" .. rowspan_talent_cache .. "'>" .. talent_cache .. "</td>")
end
end
-- Difficulté
difficulte = extract_argument("difficulté", infos, nil)
local difficulte_pred = extract_argument("difficulté", poke[h-1], nil)
local rowspan_difficulte = 1
if h == 2 or difficulte ~= difficulte_pred
then
local hh = h + 1
while poke[hh] do
local difficulte_next = extract_argument("difficulté", poke[hh], nil)
if difficulte_next == difficulte
then rowspan_difficulte = rowspan_difficulte + 1
else break
end
hh = hh + 1
end
local difficulte_number = tonumber(difficulte)
if difficulte_number == nil
then table.insert(resultat, "<td rowspan='" .. rowspan_difficulte .. ">—</td>")
else table.insert(resultat, "<td rowspan='" .. rowspan_difficulte .. ">" .. difficulte_number .. "★" .. "</td>")
end
end
-- Capacités
capacites = extract_argument("capacités", infos, nil)
local capacites_pred = extract_argument("capacités", poke[h-1], nil)
local rowspan_capacites = 1
if h == 2 or capacites ~= capacites_pred
then
local hh = h + 1
while poke[hh] do
local capacites_next = extract_argument("capacités", poke[hh], nil)
if capacites_next == capacites
then rowspan_capacites = rowspan_capacites + 1
else break
end
hh = hh + 1
end
local capacites_split = {}
if capacites then capacites_split = mw.text.split(capacites, "; ") end
local capacites_capture = capacites_split[1]
local capacites_supplementaires = capacites_split[2]
if capacites_capture == nil
then capacites_capture = {}
else capacites_capture = mw.text.split(capacites_capture, ", ")
end
if capacites_supplementaires == nil
then capacites_supplementaires = {}
else capacites_supplementaires = mw.text.split(capacites_supplementaires, ", ")
end
local c = 1
if capacites_capture[1] == nil or capacites_capture[1] == ""
then table.insert(resultat, "<td rowspan='" .. rowspan_capacites .. "'>—</td>")
else
table.insert(resultat, "<td rowspan='" .. rowspan_capacites .. "' style='text-align:left; white-space:nowrap'>")
while capacites_capture[c] do
if c > 1
then table.insert(resultat, "<br>")
end
table.insert(resultat, capacite_to_line(capacites_capture[c], type_teracristal))
c = c + 1
end
table.insert(resultat, "</td>")
end
local c = 1
if capacites_supplementaires[1] == nil or capacites_supplementaires[1] == ""
then table.insert(resultat, "<td rowspan='" .. rowspan_capacites .. "'>—</td>")
else
table.insert(resultat, "<td rowspan='" .. rowspan_capacites .. "' style='text-align:left; white-space:nowrap'>")
while capacites_supplementaires[c] do
if c > 1
then table.insert(resultat, "<br>")
end
table.insert(resultat, capacite_to_line(capacites_supplementaires[c], type_teracristal))
c = c + 1
end
table.insert(resultat, "</td>")
end
end
-- Notes (colonne optionnelle)
if colspan_notes > 0
then
local notes_unsplit = extract_argument("notes", infos, "—")
local notes_pred = extract_argument("notes", poke[h-1], "—")
notes = mw.text.split(notes_unsplit, "%. ")
local rowspan_notes = 1
if h == 2 or notes_unsplit ~= notes_pred
then
local hh = h + 1
while poke[hh] do
local notes_next = extract_argument("notes", poke[hh], "—")
if notes_next == notes_unsplit
then rowspan_notes = rowspan_notes + 1
else break
end
hh = hh + 1
end
table.insert(resultat, "<td rowspan='" .. rowspan_notes .. "' style='white-space:nowrap'>")
j = 1
while notes[j] do
if notes[j+1] ~= nil
then notes[j] = notes[j] .. "."
end
-- Expansion de certaines notes
if notes[j] == "Toujours chromatique."
then notes[j] = "[[Fichier:Miniature Chromatique (avec fond) EV.png|x15px|link=Pokémon chromatique|Ce Pokémon est toujours chromatique.]]"
.. " Toujours chromatique."
elseif notes[j] == "Jamais chromatique."
then notes[j] = "[[Fichier:Miniature Chromatique (barrée) EV.png|x15px|link=Pokémon chromatique|Ce Pokémon n'est jamais chromatique.]]"
.. " Jamais chromatique."
elseif notes[j] == "Capturable une seule fois."
then notes[j] = "[[Fichier:Miniature Honor Ball EV.png|x20px|link=|Ce Pokémon n'est capturable qu'une seule fois.]]"
.. " Capturable une seule fois."
elseif notes[j] == "Exclusif Ec."
then notes[j] = "[[Fichier:Icône Pokémon Écarlate HOME.png|x20px|link=|Ce Pokémon est exclusif à Écarlate.]]"
.. " Exclusif à ''Écarlate''."
elseif notes[j] == "Exclusif Vi."
then notes[j] = "[[Fichier:Icône Pokémon Violet HOME.png|x20px|link=|Ce Pokémon est exclusif à Violet.]]"
.. " Exclusif à ''Violet''."
elseif notes[j]:sub(1, 7) == "Insigne"
then mark_type = notes[j]:sub(9, -2)
notes[j] = "[[Fichier:Insigne " .. mark_type .. " EV.png|x20px|link=Insigne]] [[Insigne]] " .. mark_type .. "."
end
if j == 1
then table.insert(resultat, notes[j])
else table.insert(resultat, "<br>" .. notes[j])
end
j = j + 1
end
table.insert(resultat, "</td>")
end
end
-- Récompenses
local id = extract_argument("id", infos, nil)
if id == nil
then id = ""
local w = 1
local poke_words = mw.text.split(poke[1], " ")
while poke_words[w] and poke_words[w] ~= "" do
local l = 1
local b = false
while poke_words[w]:sub(l, l) ~= "" do
if poke_words[w]:sub(l, l) == "("
then b = true
break
end
l = l + 1
end
if b then break end
if w > 1 then id = id .. " " end
id = id .. poke_words[w]
w = w + 1
end
if tonumber(difficulte)
then id = id .. id_separator .. difficulte
end
end
if id_dict[id] == nil
then id_dict[id] = 1
else id_dict[id] = id_dict[id] + 1
id = id .. id_separator .. id_dict[id]
end
table.insert(resultat, "<td id='Pokémon" .. id_separator .. id .. "'>[[#Objet" .. id_separator .. id .. "|[voir]]]</td></tr>")
h = h + 1
end
end
i = i + 1
end
table.insert(resultat, '</table>')
if fetching_loc then table.insert(resultat, "[[Catégorie:Page avec un module Tableau Pokémon]]") end
return table.concat(resultat, "")
end
return p