16 403
contributi
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
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(
if formName == "" then
return ""
target = table.concat{string.fu(poke), "/Forme"}
end
return string.interp(
link = table.concat{"[[", target, "|", formName, "]]"}
})
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
- 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(
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(
else
return t[name][index] and t[name][index][formAbbr]
-- Creates links to alternative forms
local function
-- 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(
end)
end
-- Adds links of forms with a dedicated page
makeTargetedLink(
makeTargetedLink(
makeTargetedLink(
makeTargetedLink(
makeTargetedLink(
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()
t[19] = t.rattata
|