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

Adding plain links
m (Fixing mistake)
(Adding plain links)
local tab = require('Modulo:Wikilib/tables') -- luacheck: no unused
 
-- TODO: refactor link creations
--[[
 
 
Arguments:
- context: a string containing a ${link} replacement. The string is a
- black: a boolean value. If true returns black links, otherwise normal
context in which ${link} is replaced with the actual link
- formName: name of the specific form
- poke: base name of the Pokémon
 
--]]
local function makeSingleLink(blackcontext, formName, poke, general)
if formName == "" then
return ""
target = table.concat{string.fu(poke), "/Forme"}
end
return string.interp('<div class="small-text${black}">[[${target}|${formName}]]</div>'context, {
link = table.concat{"[[", target, "|", formName, "]]"}
black = black and " black-text" or "",
formName = formName,
target = target
})
end
for a given list of abbrs, and doesn't change other links.
Arguments:
- index: the index in the Pokémon's table at which store the link
- black: a boolean value. Is true adds blacklinks, otherwise normal
- context: a context for the link, containin a ${link} replacement
- target: the target page name
- list: a list of keys to which add the links for this target
 
--]]
local function makeTargetedLink(blackindex, context, target, list, abbrs)
local index = black and 'blacklinks' or 'links'
 
for _, name in pairs(list) do
t[name][index] = table.map(t[name].names, function(formName, formAbbr)
if table.search(abbrs, formAbbr) then
return makeSingleLink(blackcontext, formName, name, target)
else
return t[name][index] and t[name][index][formAbbr]
 
-- Creates links to alternative forms
local function makeLinksmakeIndexLinks(blackindex, context)
local index = black and 'blacklinks' or 'links'
 
-- Removing support tables since we don't want to operate on them
local stdLinks = table.filter(t, function(_, key)
for name, poke in pairs(stdLinks) do
poke[index] = table.map(poke.names, function(formName)
return makeSingleLink(blackcontext, formName, name)
-- return formName == ''
-- and ''
-- or string.interp(link, {
-- anchor = poke.anchor or string.fu(name),
-- formName = formName
-- })
end)
end
 
-- Adds links of forms with a dedicated page
makeTargetedLink(blackindex, context, 'Megaevoluzione', table.merge(t.mega, t.megaxy), {"base", "M", "MX", "MY"})
makeTargetedLink(blackindex, context, 'Archeorisveglio', t.archeo, {"base", "A"})
makeTargetedLink(blackindex, context, 'Forma di Alola', t.alola, {"base", "A"})
makeTargetedLink(blackindex, context, 'Forma di Galar', t.galar, {"base", "G"})
makeTargetedLink(blackindex, context, 'Gigamax', t.gigamax, {"base", "Gi"})
end
 
-- Create all links for alternative forms (black, blue and plain)
local function makeLinks()
local contexts = {
links = '<div class="small-text">${link}</div>',
blacklinks = '<div class="small-text black-text">${link}</div>',
plainlinks = '${link}',
}
for index, context in pairs(contexts) do
makeIndexLinks(index, context)
end
end
 
-- Link creation should be done AFTER copying Pokémon with same forms, in order
-- to use the right name for the link
makeLinks() -- normal links
makeLinks(true) -- black links
 
t[19] = t.rattata