Differenze tra le versioni di "Modulo:AltForms/data"

Updating alt forms links to point to specific subpages *** sovrascritto il testo esistente ***
(First bunch of data updates for the first DLC *** sovrascritto il testo esistente ***)
(Updating alt forms links to point to specific subpages *** sovrascritto il testo esistente ***)
local tab = require('Modulo:Wikilib/tables') -- luacheck: no unused
 
--[[
-- Creates link to alternative forms in list pointing to target instead of
 
-- "Differenze di forma"
Creates the link for an alternative form. There are two general
-- abbrs is an optional parameter, if specified this function modifies only the
kinds of link: those pointing to the specific subpage of the Pokémon,
-- link for base and the specified abbrs
and those pointing to general pages (eg: "Forma di Alola").
local makeTargetedLink = function(linkstr, index, target, list, abbrs)
This function handles boths, depending on the arguments.
linkstr = linkstr:gsub('Differenze di forma', target)
This function also handles empty form name, yielding no link at all
for _, poke in pairs(list) do
(an empty string).
t[poke][index] = table.map(t[poke].names, function(formName, formAbbr)
 
if abbrs and (formAbbr == 'base' or table.search(abbrs, formAbbr)) then
Arguments:
return formName == ''
- black: a boolean value. If true returns black links, otherwise normal
and ''
- formName: name of the specific form
or string.interp(linkstr, {
- poke: base name of the Pokémon
anchor = t[poke].anchor or string.fu(poke),
- general: an optional string argument. If given, the function assumes
formName = formName
the link target should be the general page whose title is given by
})
the value of this parameter (eg: for a Megaevoluzione, this
parameter should be "Megaevoluzione")
 
--]]
local function makeSingleLink(black, formName, poke, general)
if formName == formName"" then
return ""
end
 
local target
if general then
target = table.concat{general, "#", t[poke].anchor or string.fu(poke)}
else
target = table.concat{string.fu(poke), "/Forme"}
end
and return string.interp('<div class="small-text ${black-text}">[[Differenze di forma#${anchortarget}|${formName}]]</div>', {
black = black and " black-text" or "",
formName = formName,
target = target
})
end
 
--[[
 
--Adds Creates linklinks to alternative forms inpointing listto pointinga togeneric targetpage instead of
the specific subpage of the Pokémon. This function modifies links only
for a given list of abbrs, and doesn't change other links.
Arguments:
- black: a boolean value. Is true adds blacklinks, otherwise normal
- target: the target page name
- list: a list of keys to which add the links for this target
- abbrs: the list of abbrs to modify
 
--]]
local function makeTargetedLink = function(linkstr, indexblack, target, list, abbrs)
local index = black and 'blacklinks' or 'links'
 
for _, pokename in pairs(list) do
t[pokename][index] = table.map(t[pokename].names, function(formName, formAbbr)
if abbrs and (formAbbr == 'base' or table.search(abbrs, formAbbr)) then
return makeSingleLink(black, formName, name, target)
else
return t[pokename][index] and t[pokename][index][formAbbr]
end
end)
 
-- Creates links to alternative forms
local function makeLinks = function(black)
local link = black
and '<div class="small-text black-text">[[Differenze di forma#${anchor}|${formName}]]</div>'
or '<div class="small-text">[[Differenze di forma#${anchor}|${formName}]]</div>'
local index = black and 'blacklinks' or 'links'
 
-- Removing support tables since we don't want to operate on them
-- Si eliminano le table di supporto e i
-- Pokémon che non hanno i link standard
local stdLinks = table.filter(t, function(_, key)
return not table.search({'mega', 'megaxy', 'archeo', 'alola', 'galar',
'archeo', 'alola', 'galar', 'gigamax'}, key)
-- and not table.search(t.mega, key)
-- and not table.search(t.megaxy, key)
-- and not table.search(t.archeo, key)
-- and not table.search(t.alola, key)
-- and not table.search(t.galar, key)
-- and not table.search(t.gigamax, key)
end)
 
-- LinksAdds standard links
for name, poke in pairs(stdLinks) do
poke[index] = table.map(poke.names, function(formName)
return formNamemakeSingleLink(black, ==formName, ''name)
-- return formName and== ''
-- or string.interp(link,and {''
-- anchor = poke.anchor or string.fuinterp(name)link, {
-- anchor = t[poke].anchor or string.fu(pokename),
formName = formName
return-- formName == ''formName
})
-- })
end)
end
 
-- LinkAdds links of forms with a dedicated page instead of "Differenze di forma"
makeTargetedLink(link, indexblack, 'Megaevoluzione', table.merge(t.mega, t.megaxy), {"base", "M", "MX", "MY"})
makeTargetedLink(link, indexblack, 'Archeorisveglio', t.archeo, {"base", "A"})
makeTargetedLink(link, indexblack, 'Forma di Alola', t.alola, {"base", "A"})
makeTargetedLink(link, indexblack, 'Forma di Galar', t.galar, {"base", "G"})
makeTargetedLink(link, indexblack, 'Gigamax', t.gigamax, {"base", "Gi"})
end
 
t.grimer.anchor = 'Grimer e Muk'
t.zigzagoon.anchor = 'Zigzagoon e Linoone'
-- t.wormadam.anchor = 'Burmy e Wormadam'
-- t.tornadus.anchor = 'Forze della Natura'
-- t.pumpkaboo.anchor = 'Pumpkaboo e Gourgeist'
 
-- Alternative forms' links
79 548

contributi