ARK: Survival Evolved Wiki
S'inscrire
Advertisement

local p = {}
local MAPPING_PATTERNS = {
	-- Ajouter la partie du nom qui doit être contrôlée pour trouver l'icône.
	-- Chaque entrée doit avoir les informations suivantes:
	-- 1: Forme à trouver de ce qui sera enlevé de l'affichage . Les parenthèses doivent être éludées avec %.
	-- 2: Nom de fichier de l'icône
	-- 3: Nom du lien pour l'icône
	{' %(The Island%)', 'The Island Icon.png', 'The Island'},
	{' %(Scorched Earth%)', 'Scorched Earth Icon.png', 'Scorched Earth'},
	{' %(Aberration%)', 'Aberration Icon.png', 'Aberration'},
	{' %(Extinction%)', 'Extinction Icon.png', 'Extinction'},
	{' %(Genesis%)', 'Genesis Part 1 Icon.png', 'Genesis'},
	{' %(Genesis: Part 1%)', 'Genesis Part 1 Icon.png', 'Genesis: Part 1'},
	{' %(Genesis: Part 2%)', 'Genesis Part 2 Icon.png', 'Genesis: Part 2'},
	{' %(Primitive Plus%)', 'Primitive Plus Icon.png', 'Primitive Plus'},
	{' %(The Center%)', 'The Center Icon.png', 'The Center'},
	{' %(Ragnarok%)', 'Ragnarok Icon.png', 'Ragnarok'},
	{' %(Valguero%)', 'Valguero Icon.png', 'Valguero'},
	{' %(Crystal Isles%)', 'Crystal Isles Icon.png', 'Crystal Isles'},
	{' %(Lost Island%)', 'Lost Island Icon.png', 'Lost Island'},
	{' %(Fjordur%)', 'Mod Fjordur Icon.png', 'Fjordur'},
	{' %(Mobile%)', 'Logo Mobile.svg', 'ARK: Survival Evolved Mobile'},
	-- MODS
	{'Mod:Ebenus Astrum/', 'Ebenus Astrum Icon.png', 'Mod:Ebenus Astrum'},
	{'Mod:Primal Fear/', 'PrimalFearIcon.png', 'Mod:Primal Fear'},
	{'Mod:Ebenus Astrum/', 'Ebenus Astrum Icon.png', 'Mod:Ebenus Astrum'},
	{'Mod:ARK Additions/', 'ARK Additions Icon.png', 'Mod:ARK Additions'},
	{'Mod:Better MEKs!/', 'Mod Better MEKs! Icon.png', 'Mod:Better MEKs!'},
	{'Mod:Steampunk/', 'Mod Steampunk Icon.png', 'Mod:Steampunk'},
	{'Mod:Structures Plus/', 'Structures Plus Icon.png', 'Mod:Structures Plus'},
	{'Mod:Ark Eternal/', 'Mod Ark Eternal Icon.png', 'Mod:Ark Eternal'},
	{'Mod:Archaic Ascension/', 'Mod Archaic Ascension Icon.png', 'Mod:Archaic Ascension'},
	{'Mod:The Chasm/', 'ChasmLogoSmall.jpg', 'Mod:The Chasm'},
	{'Mod:Primal NPCs/', 'Mod Primal NPCs Icon.png', 'Mod:Primal NPCs'},
	{'Mod:Caballus/', 'Mod Caballus Icon.png', 'Mod:Caballus'},
	{'Mod:Prehistoric Beasts/', 'Mod Prehistoric Beasts Icon.png', 'Mod:Prehistoric Beasts'},
	{'Mod:Castles, Keeps, and Forts Remastered/', 'Mod Castles Keeps Forts Architecture Remastered Icon.png', 'Mod:Castles, Keeps, and Forts Remastered'},
	{'Mod:Crystal Isles Dino Collection/', 'Crystal Isles Dino Collection Icon.png', 'Mod:Crystal Isles Dino Collection'},
	{'Mod:Additional Creatures: Grand Hunt/', 'Additional Creatures Grand Hunt Icon.png', 'Mod:Additional Creatures: Grand Hunt'},
	{'Mod:Super Structures/', 'Mod Super Structures icon.png', 'Mod:Super Structures'},
	{'Mod:ARK: The Sunken World/', 'Mod ARK The Sunken World icon.png', 'Mod:ARK: The Sunken World'},
	{'Mod:Fjordur/', 'Mod Fjordur Icon.png', 'Mod:Fjordur'},
	{'Mod:Glacius/', 'Mod Glacius Icon.png', 'Mod:Glacius'},
	{'Mod:Dino Storage/', 'Blank.png', 'Mod:Dino Storage'},
	{'Mod:The Eärrion/', 'Mod The Eärrion Icon.png', 'Mod:The Eärrion'},
}
local EXTRA_DLC_NAMES = {
	-- Ajouter un nom alternatif aux DLC pour les recherches d'une icône de DLC lorsque
	-- il n'y a pas de nom d'objet.
	-- il y a une cartographie "de-vers". Le côté droit ne doit offrir qu'une seule
	-- entrée dans MAPPING_PATTERNS pour la troisième valeur. Le côté gauche doit être en minuscules.
	["island"] = "The Island",
	["center"] = "The Center",
	["scorched"] = "Scorched Earth",
	["primitive"] = "Primitive Plus",
	["mobile"] = "ARK: Survival Evolved Mobile",
	["s+"] = "Mod:Structures Plus",
	["better meks"] = "Mod:Better MEKs!",
}

-- La fonction Helper à utiliser avec les autres modules Lua pour disséquer un nom d'objet en
-- nom d'affichage, icône de DLC et article de DLC.
-- Retourne vide si le suffixe de DLC manque ou n'est pas reconnu.
function p.tryMatch(name)
	for _, entry in ipairs(MAPPING_PATTERNS) do
		if string.find(name, entry[1]) ~= nil then
			return {
				["displayName"] = string.gsub(name, entry[1], ''),
				["dlcIcon"] = entry[2],
				["dlcArticle"] = entry[3]
			}
		end
	end
	return nil
end

-- La fonction Helper pour les modèles de Wiki afin de disséquer les noms d'objets en variables.
-- Règle chaque variable sur rien si le suffixe de DLC manque ou n'est pas reconnu.
-- Accepte cinq paramètres:
-- 1: Nom d'objet
-- 2: Nom variable pour le nom d'affichage
-- 3: Nom variable pour le nom d'icône du DLC
-- 4: Nom variable pour le nom d'article du DLC
function p.tryMatchW(frame)
	local args = frame.args
	local result = p.tryMatch(args[1])
	local varDisplayName = args[2]
	local varDlcIcon = args[3]
	local varDlcArticle = args[4]
	
	local displayName = result and result.displayName or ''
	local dlcIcon = result and result.dlcIcon or ''
	local dlcArticle = result and result.dlcArticle or ''

	frame:callParserFunction( '#vardefine', varDisplayName, displayName )
	frame:callParserFunction( '#vardefine', varDlcIcon, dlcIcon )
	frame:callParserFunction( '#vardefine', varDlcArticle, dlcArticle )

	return ''
end

-- Fonction Helper pour que les modèles du wiki trouvent un nom d'icône de DLC.
-- Règle chaque variable sur rien si le suffixe de DLC manque ou n'est pas reconnu.
-- Accepte trois paramètres:
-- 1: nom du DLC
-- 2: Nom variable pour le nom d'icône du DLC
-- 3: Nom variable pour le nom d'article du DLC
function p.getIcon(frame)
	local args = frame.args
	local dlc = mw.text.trim(mw.ustring.lower(args[1]))
	local varDlcIcon = args[2]
	local varDlcArticle = args[3]

	if EXTRA_DLC_NAMES[dlc] then
		dlc = mw.ustring.lower(EXTRA_DLC_NAMES[dlc])
	end

	local dlcIcon = ''
	local dlcArticle = ''

	for _, entry in ipairs(MAPPING_PATTERNS) do
		local third = mw.ustring.lower(entry[3])
		if dlc == third or (string.sub(third, 1, 4) == 'mod:' and 'mod:'..dlc == third) then
			dlcIcon = entry[2]
			dlcArticle = entry[3]
			break
		end
	end

	frame:callParserFunction( '#vardefine', varDlcIcon, dlcIcon )
	frame:callParserFunction( '#vardefine', varDlcArticle, dlcArticle )

	return ''
end

return p
Advertisement