« Module:Abréviation » : différence entre les versions
Page créée avec « local p = {} local tools = require('Module:Outils') ------------------------------------------------------ ------------ Référentiel des jeux Fallout ------------ --- M… » |
(Aucune différence)
|
Version du 20 juin 2021 à 23:30
La documentation pour ce module peut être créée à Module:Abréviation/doc
local p = {}
local tools = require('Module:Outils')
------------------------------------------------------
------------ Référentiel des jeux Fallout ------------
--- Merci de ne pas dupliquer ces données ailleurs ---
-- Si un nouveau jeu sort (\o/), merci de l'ajouter --
------------------------------------------------------
local abr = {
['2D20'] = 'Fallout 2d20',
AR = 'All Roads',
D20 = 'Fallout Pen and Paper d20',
FB = 'Fallout Bible',
FILM = 'Fallout (film)',
FIXT = 'Fallout FIXT',
FNV = 'Fallout: New Vegas',
FNVCS = 'Courier\'s Stash',
FNVDM = 'Dead Money',
FNVGRA = 'Gun Runners\' Arsenal',
FNVHH = 'Honest Hearts',
FNVLR = 'Lonesome Road',
FNVOWB = 'Old World Blues',
FO = 'Fallout',
FO1 = 'Fallout',
FO2 = 'Fallout 2',
FO3 = 'Fallout 3',
FO3BS = 'Broken Steel',
FO3MZ = 'Mothership Zeta',
FO3OA = 'Operation: Anchorage',
FO3PL = 'Point Lookout',
FO3TP = 'Point Lookout',
FO3TP = 'The Pitt',
FO4 = 'Fallout 4',
FO4AM = 'Automatron',
FO4FH = 'Wasteland Workshop',
FO4NW = 'Nuka-World',
FO4VW = 'Vault-Tec Workshop',
FO76 = 'Fallout 76',
FOBOS = 'Fallout: Brotherhood of Steel',
FOBOS2 = 'Fallout: Brotherhood of Steel 2',
FOOL = 'Fallout Online',
FOS = 'Fallout Shelter',
FOT = 'Fallout Tactics',
FOT2 = 'Fallout Tactics 2',
FOW = 'Fallout: Warfare',
FOX = 'Fallout Extreme',
FS = 'Fallout Shelter',
JES = 'J.E. Sawyer\'s Fallout RPG',
LH = 'Lionheart',
NON = 'uniquement mentionné(e)',
PA = 'One Man, and a Crate of Puppets',
TAR = 'The Armageddon Rag',
TORN = 'TORN',
V13 = 'Project V13',
VB = 'Van Buren',
WIKI = 'Les Archives de Vault-Tec',
}
------------------------------------------------------
-- Vérifie l'existence d'une abréviation
function p.contains(frame)
local arg = tools.extractArgs(frame)[1] or ''
return abr[arg:upper()] ~= nil
end
-- Génère une liste de catégories
function p.categories(frame)
local args = tools.extractArgs(frame)
local categories = ''
local abbs = args[1] or ''
local subject = args[2]
if #abbs > 0 then
abbs = mw.text.split(abbs, "%s*,%s*")
end
if #abbs > 0 then
local prefix = ''
if subject then
prefix = subject .. ' de '
end
for i, abb in ipairs(abbs) do
local gameName = abr[abb:upper()]
if gameName then
categories = categories .. '[[Catégorie:' .. prefix .. gameName .. ']]'
end
end
end
if categories == '' then categories = nil end
return categories
end
-- Génère une liste de lien
function p.links(frame)
local args = tools.extractArgs(frame)
local links = ''
local abbs = args[1] or ''
local link = args['lien'] or args[2]
local subject = args['sujet'] or args[3]
local separator = args['séparateur'] or ', '
if #abbs > 0 then
abbs = mw.text.split(abbs, "%s*,%s*")
end
if #abbs > 0 then
local linkPrefix = ''
if link then
linkPrefix = link .. ' de '
end
local subjectPrefix = ''
if subject then
subjectPrefix = subject .. ' de '
end
for i, abb in ipairs(abbs) do
local gameName = abr[abb:upper()]
if gameName then
if i == 1 then
links = '[['..linkPrefix..gameName..'|'..subjectPrefix..'\'\''..gameName..'\'\']]'
else
links = links..separator..'[['..linkPrefix..gameName..'|\'\''..gameName..'\'\']]'
end
end
end
elseif link then
links = '[['..link..'|'..(subject or link)..']]'
elseif subject then
links = subject
end
if links == '' then links = nil end
return links
end
return p