Aller au contenu

« Module:Test » : différence entre les versions

De Poképédia
mAucun résumé des modifications
Nettoyage tests
 
Ligne 332 : Ligne 332 :
end
end
return formatted
return formatted
end
function p.testListe(frame)
local jeu = frame.args["jeu"]
local pokemon = frame.args[1]
local titre = (frame.args["titre"] or "Pokémon")
local tableauType = (frame.args["type"] or "")
if pokemon ~= nil then pokemon = mw.text.split(pokemon, "\n") else pokemon = {} end
local resultat = {}
table.insert(resultat, '<table class="tableaustandard ' .. tableauType .. ' capacité-liste"><tr><th colspan="4">'.. titre ..'</th></tr><tr>')
local i = 1
local j = 1
while pokemon[i] do
if mw.text.trim(pokemon[i]) ~= "" then
if string.match(pokemon[i], "^Section ") then
pokemon[i] = string.gsub( pokemon[i], "Section ", "" )
table.insert(resultat, '</tr><tr>')
table.insert(resultat, '<th colspan="4">'.. pokemon[i] ..'</th></tr><tr>')
j = 1
else
if jeu then pokemon[i] = pokemon[i] .. 'jeu(' .. jeu .. ')' end
table.insert(resultat, '<td style="vertical-align:top; min-width:25%">')
table.insert(resultat, ressources.infosPokemon(pokemon[i]))
table.insert(resultat, '</td>')
if j == 4 then
j = 1
table.insert(resultat, '</tr><tr>')
else
j = j + 1
end
end
end
i = i + 1
end
table.insert(resultat, '</tr></table>')
return table.concat(resultat, '')
end
function p.testMiniature(frame)
local jeu = frame.args["jeu"]
local pokemon = frame.args[1]
local titre = (frame.args["titre"] or "Pokémon")
local tableauType = (frame.args["type"] or "")
if pokemon ~= nil then pokemon = mw.text.split(pokemon, "\n") else pokemon = {} end
local resultat = {}
table.insert(resultat, '<table class="tableaustandard ' .. tableauType .. ' centre"><tr><th>'.. titre ..'</th></tr><tr><td>')
local i = 1
while pokemon[i] do
if mw.text.trim(pokemon[i]) ~= "" then
if string.match(pokemon[i], "^Section ") then
pokemon[i] = string.gsub( pokemon[i], "Section ", "" )
table.insert(resultat, '</tr><tr>')
table.insert(resultat, '<th colspan="4">'.. pokemon[i] ..'</th></tr><tr><td>')
else
if jeu then pokemon[i] = pokemon[i] .. 'jeu(' .. jeu .. ')' end
table.insert(resultat, ressources.infosPokemon(pokemon[i], "miniature"))
end
end
i = i + 1
end
table.insert(resultat, '</td></tr></table>')
return table.concat(resultat, '')
end
end


Ligne 631 : Ligne 561 :
return table.concat(result, "")
return table.concat(result, "")
end
end
function p.autresJeux(frame)
    -- Localisation des fonctions globales
    local loadData = mw.loadData
    local split = mw.text.split
    local trim = mw.text.trim
    local insert = table.insert
    local gsub = string.gsub
    local sub = string.sub
    local expand = frame.expandTemplate
    local nom_pokemon = loadData("Module:Data/NomsPokémon")
    local taille_par_jeu = {
        -- Ajouter ici les jeux pour lesquels la taille des sprites (ou autres) doit être adaptée
        ["GO"] = { ["Sprite"] = 125 },
        ["GO-v1"] = { ["Sprite"] = 120 },
        ["Sleep"] = { ["Sprite"] = 115, ["Miniature"] = 100 },
        ["Friends"] = { ["Sprite"] = 110 },
        ["UNITE"] = { ["Sprite"] = 110, ["Miniature"] = 80 },
        ["Smile"] = { ["Sprite"] = 115 },
        ["PM"] = { ["Sprite"] = 105 },
        ["Q"] = { ["Sprite"] = 120, ["Miniature"] = 95 },
        ["DéPi"] = { ["Sprite"] = 105 },
        ["Pav"] = { ["Sprite"] = 115 },
        ["MJ"] = { ["Sprite"] = 115 },
        ["Pic"] = { ["Sprite"] = 105 },
        ["P3DP"] = { ["Sprite"] = 100 },
        ["APCC"] = { ["Sprite"] = 105 },
        ["PPk1"] = { ["Sprite"] = 100 },
        ["PPk2"] = { ["Sprite"] = 100 },
        ["MPR"] = { ["Sprite"] = 75 },
        ["PDMDX"] = { ["Miniature"] = 95 },
        ["CM"] = { ["Sprite"] = 110, ["Portrait"] = 105 },
        ["CM-v1"] = { ["Sprite"] = 110 },
        ["Sh"] = { ["Sprite"] = 105 },
        ["LB"] = { ["Sprite"] = 110 },
        ["St1"] = { ["Sprite"] = 125 },
        ["St2"] = { ["Sprite"] = 125 },
        ["PBR"] = { ["Sprite"] = 95 },
    }
   
    local jeu_sprites = {
    -- Ajouter ici les jeux dont les sprites sont pixélisés et qui ne doivent jamais être redimensionés, même sur mobile
    "TCG", "TCG2", "Pin", "PinRS", "PuzC", "Pokéwalker", "Colo", "XD", "L!", "PDMRB", "PDMTO", "Ra1", "Ra2", "Ra3", "Cq"
    }
    local numdex = frame.args[1]
    local lignes = frame.args[2]
    local poke_forme = frame.args["forme"] or ""
    local resultat = {}
    insert(resultat, '<table class="tableaustandard centre" style="width:80%; table-layout:fixed"><colgroup><col style="width:7em;"><col></colgroup><tr><th colspan="2">Sprites d\'autres jeux</th></tr>')
    if lignes then lignes = split(lignes, "\n") else lignes = {} end
    for _, ligne in ipairs(lignes) do
        if ligne ~= "" then
            local formes = split(ligne, "/")
            local jeux = split(trim(formes[1]), " ")
            local jeu = jeux[1]
            local extra_jeux = ""
            local i = 2
            while jeux[i] do
                if jeux[i + 1] then
                    extra_jeux = extra_jeux .. ', ' .. expand(frame, { title = 'Abréviation', args = { jeux[i] } })
                else
                    extra_jeux = extra_jeux .. ' et ' .. expand(frame, { title = 'Abréviation', args = { jeux[i] } })
                end
                i = i + 1
            end
            local abreviation = ""
            if sub(jeu, -3) == "-v1" then
                abreviation = expand(frame, { title = 'Abréviation', args = { sub(jeu, 1, -4) } }) .. '<br><div style="line-height:100%"><small>Ancienne version</small></div>'
            else
                abreviation = expand(frame, { title = 'Abréviation', args = { jeu } })
            end
            insert(resultat, '<tr><th>' .. abreviation .. extra_jeux .. '</th><td><div class="imagerie-secondaire">')
local zoom_class = ""
for _, jeu_sprite in ipairs(jeu_sprites) do
if jeu == jeu_sprite then zoom_class = "-pixel" end
end
-- Réduction de la taille des sprites selon le nombre de formes
if zoom_class == ""
then
local nb_formes = #formes
if nb_formes >= 19
then zoom_class = " image-imagerie-secondaire-zoom2"
elseif nb_formes >= 10
then zoom_class = " image-imagerie-secondaire-zoom1"
end
end
            i = 3
            if jeu == "TCG" or jeu == "TCG2" then
                local nom_poke = nom_pokemon[tonumber(numdex)]["fr"]
                if jeu == "TCG" then jeu = "TCG1" end
                while formes[i] do
                    local carte = split(trim(formes[i]), " ")
                    local numero = carte[1]
                    local forme = carte[2] or ""
                    if forme ~= "" then forme = " " .. forme end
                    local fichier = 'Fichier:' .. jeu .. ' ' .. numero .. ' ' .. nom_poke .. forme .. ".png"
                    insert(resultat, '<div class="image-imagerie-secondaire' .. zoom_class .. '" style="display:inline-block">[[' .. fichier .. ']]</div>')
                    i = i + 1
                end
            else
                while formes[i] do
                    local forme = trim(formes[i])
                    local type_image = split(forme, " ")[1]
                    forme = gsub(forme, type_image, "")
                    local tailles = taille_par_jeu[jeu]
                    local taille_image = ""
                    if tailles and tailles[type_image] then
                        taille_image = '|' .. tailles[type_image] .. 'px'
                    end
                    local extension = ".png"
                    if (sub(forme, -4) == " gif") then
                        extension = ".gif"
                        forme = sub(forme, 1, -5)
                    end
                    local fichier = 'Fichier:' .. type_image .. ' ' .. numdex .. ' ' .. poke_forme .. ' ' .. forme .. ' ' .. jeu .. extension
                    insert(resultat, '<div class="image-imagerie-secondaire' .. zoom_class .. '" style="display:inline-block">[[' .. fichier .. taille_image .. ']]</div>')
                    i = i + 1
                end
            end
            insert(resultat, '</div></td></tr>')
        end
    end
    insert(resultat, '</table>')
    return table.concat(resultat, '')
end


return p
return p

Dernière version du 26 novembre 2025 à 18:34

Seulement pour tester. Si un modèle utilise une fonction de ce module, il cassera un jour !


local p = {}
local ressources = {
	["infosPokemon"] = require("Module:Ressources/infosPokemon")
}

function p.yop() -- met un mot en lowercase
	return mw.ustring.lower( "ÉLLOÈ" )
end

function p.poy() -- première lettre en majuscule
	return mw.getContentLanguage():ucfirst( "ébloubi" )
end

local numeros = mw.loadData("Module:Data/NumérosPokémon")

function p.infosPokemon( poke, mode )
	local forme, sexe, nom, lien, jeu, jeu_miniature
	if ( string.match(poke, "forme%([^)]*%)") ) then
		forme = " " .. string.sub(string.match(poke, "forme%([^)]*%)"), 7, -2)
		poke = string.gsub( poke, "forme%([^)]*%)", "" )
	else forme = "" end
	if ( string.match(poke, "sexe%([^)]*%)") ) then
		sexe = string.sub(string.match(poke, "sexe%([^)]*%)"), 6, -2)
		if sexe == "f" then sexe = " ♀" else sexe = " ♂" end
		poke = string.gsub( poke, "sexe%([^)]*%)", "" )
	else sexe = "" end
	if ( string.match(poke, "jeu%([^)]*%)") ) then
		jeu = mw.getCurrentFrame():expandTemplate{ title = 'Sup', args = { string.sub(string.match(poke, "jeu%([^)]*%)"), 5, -2) } }
		poke = string.gsub( poke, "jeu%([^)]*%)", "" )
	else jeu = "" end
	if ( string.match(poke, "jeu%-miniature%([^)]*%)") ) then
		jeu_miniature = " " .. string.sub(string.match(poke, "jeu%-miniature%([^)]*%)"), 15, -2)
		poke = string.gsub( poke, "jeu%-miniature%([^)]*%)", "" )
	else jeu_miniature = "" end
	
	if forme == " Alola" then
		poke = mw.text.trim( poke )
		nom = "Forme d'Alola"
		lien = poke .. " d'Alola"
	elseif forme == " Galar" then
		poke = mw.text.trim( poke )
		nom = "Forme de Galar"
		lien = poke .. " de Galar"
	elseif forme == " Gigamax" then
		poke = mw.text.trim( poke )
		nom = "Gigamax"
		lien = poke .. " Gigamax"
	else
		if ( string.match(poke, "nom%([^)]*%)") ) then
			nom = string.sub(string.match(poke, "nom%([^)]*%)"), 5, -2)
			poke = string.gsub( poke, "nom%([^)]*%)", "" )
		elseif forme ~= "" then nom = "Forme" .. forme
		elseif sexe == " ♀" then nom = "Femelle"
		elseif sexe == " ♂" then nom = "Mâle"
		else nom = "" end
		if ( string.match(poke, "lien%([^)]*%)") ) then
			lien = string.sub(string.match(poke, "lien%([^)]*%)"), 6, -2)
			poke = string.gsub( poke, "lien%([^)]*%)", "" )
		else lien = mw.text.trim( poke ) end
	end
	
	poke = mw.text.trim( poke )
	local num = numeros[poke]
	if num == nil then num = "???" end
	
	if mode == "miniature" then 
		if nom == "" then return "[[Fichier:Miniature " .. num .. forme .. sexe .. jeu_miniature .. ".png|link=" .. lien .. "|alt=" .. lien .. "|" .. lien .. "]]" .. jeu
		else return "[[Fichier:Miniature " .. num .. forme .. sexe .. jeu_miniature .. ".png|link=" .. lien .. "|alt=" .. poke .. " (" .. nom .. ")|" .. poke .. " (" .. nom .. ")]]" .. jeu
		end
	else
		if nom == "" then return "<span style='white-space: nowrap;' class='miniat-poke'>" .. num .. " [[Fichier:Miniature  " .. num .. forme .. sexe .. jeu_miniature .. ".png|link=" .. lien .. "|alt=]] [[" .. lien .. "|" .. poke .. "]]" .. jeu .. "</span>"
		else return "<span style='white-space: nowrap;' class='miniat-poke'>" .. num .. " [[Fichier:Miniature " .. num .. forme .. sexe .. jeu_miniature .. ".png|link=" .. lien .. "|alt=]] [[" .. lien .. "|" .. poke .. "]]" .. jeu .. "</span><br /><span style='font-style: italic; font-size: 90%;'>" .. nom .. "</span>"
		end
	end
end

function p.infosPokemon2(frame)
	poke = frame.args[1]
	mode = frame.args[2]
	return p.infosPokemon(poke, mode)
end

function p.testregexp(frame)
	a = frame.args[1]
	
	b = a:gsub(".*{{Abréviation|(.*)}}.*", "%1")
	return b
end

local numeros = mw.loadData("Module:Data/NumérosPokémon")

function p.newInfosPokemon(frame)
	local numeros = mw.loadData("Module:Data/NumérosPokémon")
	local poke = frame.args[1]
	local mode = frame.args[2]
	local forme, sexe, nom, lien, jeu, sup
	
	-- Fonction qui récupère les détails indiqués d'un Pokémon entre parenthèses
	-- '\' fait office de caractère d'échappement en cas de parenthèse fermante
	local function get_modifier(modifier)
		local regex = modifier .. "%([^)]*[^\\]%)"
		if (string.match(poke, regex)) then
			local ret = string.sub(string.match(poke, regex), string.len(modifier)+2, -2)
			ret = string.gsub(ret, "\\", "")
			poke = string.gsub(poke, regex, "")
			return ret
		else return "" end
	end
	
	-- Récupération des données additionnelles
	forme = get_modifier("forme")
	jeu = get_modifier("jeu")
	sexe = get_modifier("sexe")
	if (sexe == "f") then sexe = "♀" 
	elseif (sexe == "m") then sexe = "♂" end
	sup = get_modifier("sup")
	if (sup ~= "") then sup = mw.getCurrentFrame():expandTemplate{ title = 'Sup', args = { sup } } end
	-- Pour pouvoir overwrite par la suite si nécessaire
	local temp_nom = get_modifier("nom")
	local temp_lien = get_modifier("lien")
	
	-- Nettoyage du nom et valeurs par défaut
	poke = mw.text.trim(poke)
	lien = poke
	nom = ""
	local poke_file = poke -- Si jamais on veut changer le nom du lien
	local num = numeros[poke] or "???"
		
	if (forme ~= "")
	then
		-- Dictionnaires pour largement simplifier la gestion des formes spéciales
		local common_forms = {
			["Alola"] = { "Forme d'Alola", " d'Alola" },
			["Galar"] = { "Forme de Galar", " de Galar" },
			["Hisui"] = { "Forme de Hisui", " de Hisui" },
			["Paldea"] = { "Forme de Paldea", " de Paldea" },
			["Gigamax"] = { "Gigamax", " Gigamax" }
		}
		
		-- Lorsque le nom d'affichage = nom des formes
		local poke_short_forms = { ["Évoli"] = true, ["Zarbi"] = true, ["Arceus"] = true,
			["Magaerna"] = true, ["Charmilly"] = true, ["Bekaglaçon"] = true, ["Zacian"] = true,
			["Zamazenta"] = true, ["Éthernatos"] = true, ["Sylveroy"] = true, ["Ursaking"] = true }
		
		-- Lorsque le nom d'affichage = préfix autre que "Forme " + nom des formes
		local poke_prefix_forms = {
			["Cheniti"] = "Cape ",
			["Cheniselle"] = "Cape ",
			["Ceriflor"] = "Temps ",
			["Sancoki"] = "Mer ",
			["Tritosor"] = "Mer ",
			["Bargantua"] = "Motif ",
			["Keldeo"] = "Aspect ",
			["Genesect"] = "Module ",
			["Prismillon"] = "Motif ",
			["Flabébé"] = "Fleur ",
			["Floette"] = "Fleur ",
			["Florges"] = "Fleur ",
			["Pitrouille"] = "Taille ",
			["Banshitrouye"] = "Taille ",
			["Xerneas"] = "Mode ",
			["Plumeline"] = "Style ",
			["Silvallié"] = "Type : ",
			["Morpeko"] = "Mode ",
			["Famignol"] = "Famille de ",
			["Tapatoès"] = "Plumage ",
		}
		
		-- Pokémon avec beaucoup de formes et un pattern utilisable
		local other_patterns = {
			["Pikachu"] = function()
				if (forme == "Partenaire") then return { mw.text.trim(forme), "Pikachu Partenaire" }
				elseif (string.match(forme, "^Casquette ")) then return { forme, "Pikachu" }
				elseif (string.match(forme, "^Halloween ")) then return { "Chapeau d'Halloween", "Pikachu" }
				elseif (string.match(forme, "^Fêtes ")) then return { "Chapeau rouge", "Pikachu" }
				else return { "Pikachu " .. forme, "Pikachu " .. forme } -- Les Cosplayeurs
				end
			end,
			["Couafarel"] = function()
				if (forme == "Sauvage") then return { "Forme Sauvage", "Couafarel" }
				else return { "Coupe " .. forme, "Couafarel" }
				end
			end,
			["Météno"] = function()
				if (forme == "Météore") then return { "Forme Météore", "Météno" }
				else return { "Noyau " .. forme, "Météno" }
				end
			end }
					
		
		-- Toutes les autres formes où le nom d'affichage n'est pas juste "Forme <forme>"
		local other_forms = {
			["Tauros"] = {
				["Paldea Combative"] = { "Forme de Paldea<br>Race Combative", "Tauros de Paldea" },
				["Paldea Flamboyante"] = { "Forme de Paldea<br>Race Flamboyante", "Tauros de Paldea" },
				["Paldea Aquatique"] = { "Forme de Paldea<br>Race Aquatique", "Tauros de Paldea" }
			},
			["Darumacho"] = {
				["Transe"] = { "Mode Transe", "Darumacho" },
				["Galar Transe"] = { "Forme de Galar<br>Mode Transe", "Darumacho de Galar" }
			},
			["Kyurem"] = {
				["Blanc"] = { "Kyurem Blanc", "Kyurem Blanc" },
				["Noir"] = { "Kyurem Noir", "Kyurem Noir" }
			},
			["Necrozma"] = {
				["Crinière du Couchant"] = { "Crinière du Couchant", "Necrozma Crinière du Couchant" },
				["Ailes de l'Aurore"] = { "Ailes de l'Aurore", "Necrozma Ailes de l'Aurore" },
				["Ultra"] = { "Ultra-Necrozma", "Ultra-Necrozma" }
			},
			["Shifours"] = {
				["Poing Final"] = { "Style Poing Final", "Shifours" },
				["Mille Poings"] = { "Style Mille Poings", "Shifours" },
				["Gigamax Poing Final"] = { "Gigamax<br>Style Poing Final", "Shifours-Gigamax" },
				["Gigamax Mille Poings"] = { "Gigamax<br>Style Mille Poings", "Shifours-Gigamax" }
			},
			["Koraidon"] = {
				["Finale"] = { "Forme Finale", "Koraidon" },
				["Course"] = { "Forme de Course", "Koraidon" },
				["Nage"] = { "Forme de Nage", "Koraidon" },
				["Vol"] = { "Forme de Vol", "Koraidon" }
			},
			["Miraidon"] = {
				["Ultime"] = { "Mode Ultime", "Miraidon" },
				["Terrestre"] = { "Mode Terrestre", "Miraidon" },
				["Aquatique"] = { "Mode Aquatique", "Miraidon" },
				["Aérien"] = { "Mode Aérien", "Miraidon" }
			},
			["Ogerpon"] = {
				["Turquoise"] = { "Masque Turquoise", "Ogerpon" },
				["Puits"] = { "Masque du Puits", "Ogerpon" },
				["Fourneau"] = { "Masque du Fourneau", "Ogerpon" },
				["Pierre"] = { "Masque de la Pierre", "Ogerpon" }
			}
		}
			
		if common_forms[forme] then
			nom = common_forms[forme][1]
			lien = poke .. common_forms[forme][2]
			
		elseif (forme == "Méga") then
			nom = "Méga-".. poke
			lien = "Méga-" .. poke
			
		elseif (forme == "Primo") then
			nom = "Primo-" .. poke
			lien = "Primo-" .. poke
			
		
		elseif (forme == "Méga X") then
			nom = "Méga-".. poke .. " X"
			lien = "Méga-" .. poke .. " X"
			
		elseif (forme == "Méga Y") then
			nom = "Méga-".. poke .. " Y"
			lien = "Méga-" .. poke .. " Y"
			
		elseif poke_short_forms[poke] then
			nom = mw.text.trim(forme)
			
		elseif poke_prefix_forms[poke] then
			nom = poke_prefix_forms[poke] .. forme
			
		elseif (poke == "Motisma" or poke == "Hoopa") then
			nom = poke .. " " .. forme
			
		elseif other_patterns[poke] then
			f = other_patterns[poke]
			local r = f()
			nom = r[1]
			lien = r[2]
			
		elseif (other_forms[poke] and other_forms[poke][forme]) then
			local r = other_forms[poke][forme]
			nom = r[1]
			lien = r[2]
			
		else -- Toutes les formes où le nom d'affichage est juste "Forme <forme>" sans redirection
			nom = "Forme " .. forme
			lien = poke
		end
	end
		
	-- Gestion des sous pages pour jeux spécifiques
	if (jeu ~= "") then
		local games_with_pages = {
			["PDMRB"] = "Pokémon Donjon Mystère",
			["PDMTOC"] = "Pokémon Donjon Mystère",
			["PDMTO"] = "Pokémon Donjon Mystère",
			["PDMC"] = "Pokémon Donjon Mystère",
			["PDMPI"] = "Pokémon Donjon Mystère",
			["PMDM"] = "Pokémon Donjon Mystère",
			["PDMDX"] = "Pokémon Donjon Mystère"
		}
		
		if (games_with_pages[jeu]) then
			lien = poke .. "/" .. games_with_pages[jeu]
		end
	end
	
	-- Gestion des formes séxuées
	if (sexe == "♀") then nom = "Femelle" end
	if (sexe == "♂") then nom = "Mâle" end
	
	-- Si "nom" ou "lien" ont été indiqués, on overwrite les valeurs
	if (temp_nom ~= "") then nom = temp_nom end
	if (temp_lien ~= "") then lien = temp_lien end
	
	-- Ajouts d'espaces pour la valeur de retour
	if (forme ~= "") then forme = " " .. forme end
	if (sexe ~= "") then sexe = " " .. sexe end
	if (jeu ~= "") then jeu = " " .. jeu end
	
	-- Retour
	if (mode == "miniature") then
		if (nom ~= "") then nom = " (" .. nom .. ")" end
		return "[[Fichier:Miniature " .. num .. forme .. sexe .. jeu .. ".png|link=" .. lien .. "|alt=" .. poke .. nom .. "|" .. poke .. nom .. "|class=miniature" .. jeu .. "]]" .. sup
	else
		if (nom ~= "") then nom = "<br><span style='font-style: italic; font-size: 90%;'>" .. nom .. "</span>" end
		return "<span style='white-space: nowrap;' class='miniat-poke'>" .. num .. " [[Fichier:Miniature " .. num .. forme .. sexe .. jeu .. ".png|link=" .. lien .. "|alt=|class=miniature" .. jeu .. "]] [[" .. lien .. "|" .. poke .. "]]" .. sup .. "</span>" .. nom
	end
end


function separate_thousands(amount)
	local formatted = amount
	while true do
		formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1 %2')
		if (k==0) then
			break
		end
	end
	return formatted
end

function p.donnees(frame)
	local donnees = frame.args[1]
	local lignes = {}
	if donnees ~= nil then lignes = mw.text.split(donnees, "\n") end
	
	images_rangement = {
		["RB"] = "[[Fichier:Vide.png|32px]]",
		["J"] = "[[Fichier:Vide.png|32px]]",
		["OA"] = "[[Fichier:Sprite XXX OA.png|32px]]",
		["C"] = "[[Fichier:Sprite XXX OA.png|32px]]",
		["RS"] = "[[Fichier:Sprite Sac (XXX) ♂ RS.png|32px]]",
		["RFVF"] = "[[Fichier:Sprite Sac (XXX) ♂ RFVF.png|32px]]",
		["E"] = "[[Fichier:Sprite Sac (XXX) ♂ E.png|32px]]",
		["DP"] = "[[Fichier:Miniature Poche XXX (sélectionnée) DP.png|32px]]",
		["Pt"] = "[[Fichier:Miniature Poche XXX (sélectionnée) Pt.png|32px]]",
		["HGSS"] = "[[Fichier:Miniature Poche XXX (sélectionnée) HGSS.png]]",
		["NB"] = "[[Fichier:Sprite Sac (XXX, transition) ♂ NB.png|32px]]",
		["N2B2"] = "[[Fichier:Sprite Sac (XXX, transition) ♂ N2B2.png|32px]]",
		["XY"] = "[[Fichier:Miniature Poche XXX (sélectionnée) XY.png]]",
		["ROSA"] = "[[Fichier:Miniature Poche XXX (sélectionnée) ROSA.png]]",
		["SL"] = '<div style="width:32px; text-align:center; display:inline-block">[[Fichier:Miniature Poche XXX SL.png]]</div>',
		["USUL"] = '<div style="width:32px; text-align:center; display:inline-block">[[Fichier:Miniature Poche XXX USUL.png]]</div>',
		["LGPE"] = "[[Fichier:Miniature XXX LGPE.png]]",
		["EB"] = "[[Fichier:Miniature Poche XXX (sélectionnée) EB.png|class=imagenoire|32px]]",
		["DEPS"] = "[[Fichier:Miniature Poche XXX (sélectionnée) DEPS.png|32px]]",
		["LPA"] = "[[Fichier:Miniature Sacoche LPA.png|32px]]",
		["EV"] = "[[Fichier:Miniature Poche XXX (sélectionnée) EV.png|32px]]",
		["LPZA"] = "[[Fichier:Miniature Poche XXX LPZA.png|class=imagenoire|32px]]",
	}
	
	function afficher_monnaie(monnaie, jeu)
		local d = {
			["P"] = frame:expandTemplate({ title = 'P'}),
			["Poké"] = frame:expandTemplate({ title = 'Monnaie PDM', args = { ["jeu"] = jeu }}),
			["Méga-Fragment"] = frame:expandTemplate({ title = "Objet", args = { "Méga-Fragment", ["jeu"] = jeu, ["nom"] = "non" }}),
			["Méga-Fragments"] = frame:expandTemplate({ title = "Objet", args = { "Méga-Fragment", ["jeu"] = jeu, ["nom"] = "non" }})
		}
		if d[monnaie]
		then return d[monnaie]
		else return monnaie
		end
	end
	
	local corps_result = {}
	local has_notes = false
	local donnees_dict = {}

	local i = 1
	while lignes[i] ~= nil do
		local ligne = lignes[i]
		local ligne_split = mw.text.split(ligne, " / ")
		
		for j = 3, 5 do
			if ligne_split[j] == nil or ligne_split[j] == "-"
			then ligne_split[j] = "—"
			end
		end
		
		donnees_dict[i] = {
			["jeu"] = ligne_split[1],
			["rangement"] = ligne_split[2],
			["achat"] = ligne_split[3],
			["vente"] = ligne_split[4],
			["note"] = ligne_split[5]
		}
		
		i = i + 1
	end
	
	i = 1
	while lignes[i] ~= nil do
		local jeu = donnees_dict[i].jeu
		local rangement = donnees_dict[i].rangement
		local achat = donnees_dict[i].achat
		local vente = donnees_dict[i].vente
		local note = donnees_dict[i].note
		
		if jeu ~= ""
		then
			precedent_exists = donnees_dict[i-1] ~= nil and donnees_dict[i-1].jeu ~= ""
			
			table.insert(corps_result, "<tr><td>" .. frame:expandTemplate({ title = 'Abréviation', args = { jeu } }) .. "</td>")
			
			if not rangement
			then rangement = "—"
			else
				if jeu == "OA" or jeu == "C"
				then rangement = "Poche " .. rangement
				end
				
				if images_rangement[jeu]
				then rangement = images_rangement[jeu]:gsub("XXX", rangement) .. " " .. rangement
				end
			end
			table.insert(corps_result, '<td style="white-space:nowrap; text-align:left">' .. rangement .. '</td>')
			
			achat_texte = "—"
			local rowspan = 1
			if not(precedent_exists and achat == donnees_dict[i-1].achat)
			then
				while donnees_dict[i + rowspan] and achat == donnees_dict[i + rowspan].achat do
					rowspan = rowspan + 1
				end
				
				if achat
				then
					achats = mw.text.split(achat, ", ")
					achat_texte = ""
					local j = 1
					while achats[j] do
						achat_j = achats[j]
						local precision_achat = ""
						local parenthese_pos = achat_j:find(" %(")
						if parenthese_pos
						then precision_achat = achat_j:sub(parenthese_pos):gsub(" %(", " <small>(") .. "</small>"
							achat_j = achat_j:sub(0, parenthese_pos - 1)
						end
						
						espace_pos = achat_j:find(" ")
						local unite_achat = ""
						if espace_pos
						then unite_achat = achat_j:sub(espace_pos + 1) -- + 1 pour enlever l'espace
							unite_achat = " " .. afficher_monnaie(unite_achat, jeu)
							achat_j = achat_j:sub(0, espace_pos)
						end
						
						if achat_j == "-"
						then achat_j = "—"
						else achat_j = separate_thousands(achat_j)
						end
						
						if achat_texte ~= "" then achat_texte = achat_texte .. "<br>" end
						achat_texte = achat_texte .. achat_j .. unite_achat .. precision_achat
						
						j = j + 1
					end
				end
				table.insert(corps_result, '<td rowspan="' .. rowspan .. '" style="white-space:nowrap">' .. achat_texte .. "</td>")
			end
			
			vente_texte = "—"
			rowspan = 1
			if not(precedent_exists and vente == donnees_dict[i-1].vente)
			then 
				while donnees_dict[i + rowspan] and vente == donnees_dict[i + rowspan].vente do
					rowspan = rowspan + 1
				end
				
				if vente
				then
					ventes = mw.text.split(vente, ", ")
					vente_texte = ""
					local j = 1
					while ventes[j] do
						vente_j = ventes[j]
						local precision_vente = ""
						local parenthese_pos = vente_j:find(" %(")
						if parenthese_pos
						then precision_vente = vente_j:sub(parenthese_pos):gsub(" %(", " <small>(") .. "</small>"
							vente_j = vente_j:sub(0, parenthese_pos - 1)
						end
						
						mw.log(vente_j)
						
						espace_pos = vente_j:find(" ")
						local unite_vente = ""
						if espace_pos
						then unite_vente = vente_j:sub(espace_pos + 1) -- + 1 pour enlever l'espace
							
						mw.log(unite_vente)
							unite_vente = " " .. afficher_monnaie(unite_vente, jeu)
							vente_j = vente_j:sub(0, espace_pos)
						end
						
						mw.log(vente_j)
						
						if vente_j == "-"
						then vente_j = "—"
						else vente_j = separate_thousands(vente_j)
						end
						
						if vente_texte ~= "" then vente_texte = vente_texte .. "<br>" end
						vente_texte = vente_texte .. vente_j .. unite_vente .. precision_vente
						
						j = j + 1
					end
				end
				table.insert(corps_result, '<td rowspan="' .. rowspan .. '" style="white-space:nowrap">' .. vente_texte .. "</td>")
			end
			
			rowspan = 1
			if not(precedent_exists and note == donnees_dict[i-1].note)
			then
				while donnees_dict[i + rowspan] and note == donnees_dict[i + rowspan].note do
					rowspan = rowspan + 1
				end
				
				if note
				then has_notes = true
				else note = "—"
				end
				
				table.insert(corps_result, '<td rowspan="' .. rowspan .. '">' .. note .. "</td>")
			end
			table.insert(corps_result, "</tr>")
		end
		
		i = i + 1
	end

	local result = {}
	local corps = table.concat(corps_result, "")
	
	table.insert(result, '<table class="tableaustandard centre">')
	table.insert(result, '<tr><th rowspan="2">Jeu</th><th rowspan="2">Rangement</th><th colspan="2">Prix</th>')
	if has_notes
	then table.insert(result, '<th rowspan="2">Notes</th>')
	else corps = corps:gsub('<td rowspan="%d">—</td></tr>', '</tr') -- on enlève la colonne Notes
	end
	
	table.insert(result, '</tr><tr><th>Achat</th><th>Vente</th></tr>')

	table.insert(result, corps)
	table.insert(result, "</table>")
	
	return table.concat(result, "")
end

return p