79 548
contributi
(Adding plain links to PokémonData *** sovrascritto il testo esistente ***) |
(Adding code to check how much crying before a breaking change *** sovrascritto il testo esistente ***) |
||
local f = {}
local tab = require('Modulo:Wikilib/tables') -- luacheck: no unused▼
-- stylua: ignore start
local txt = require('Modulo:Wikilib/strings') -- luacheck: no unused▼
local genUtil = require('Modulo:Wikilib/gens')
local alt = mw.loadData('Modulo:AltForms/data')
-- stylua: ignore end
-- Boolean used to avoid double loading of useless forms
end
local all =
local useless = mw.loadData('Modulo:UselessForms/data')
local both = mw.loadData('Modulo:BothForms/data')
--[[
Estrae la sigla della forma alternativa dal nome del Pokémon così come è negli
indici delle tabelle dati o negli ndex dei Mini Sprite, oppure a partire dal▼
nome del Pokémon e quello esteso della forma alternativa. In caso di▼
▲delle tabelle dati o negli ndex dei Mini
▲e quello esteso della forma alternativa. In
DEPRECATION NOTICE: this function is deprecated. Use getnameabbr or getndexabbr
▲caso di fallimento, ritorna la stringa vuota.
instead.
--]]
---@deprecated
f.getabbr = function(name, extform)
if alt[tonumber(name) or name:lower()] then
extform = string.lower(extform or
name = tonumber(name) or name:lower()
return alt[name].ext[extform] or
end
return name:match(
end
--[[
f.getnameabbr = function(name, extform)
if alt[tonumber(name) or name:lower()] then
extform = string.lower(extform or
name = tonumber(name) or name:lower()
return name, alt[name].ext[extform] or
end
local poke, abbr = name:match("^([%lé%-♂♀'%s%.&#;%d]+)(%u*%a*)$")
return tonumber(poke) or poke or
end
f.getNameAbbr, f.get_name_abbr = f.getnameabbr, f.getnameabbr
--[[
Given a Pokémon ndex, possibly followed by a form abbr, split the ndex itself
from the abbr. If given a Pokémon name instead of an ndex, the function returns
it unchanged.
The name behaviour is needed because in general it not possible to separate the
name from the abbr. If there is some extra assumption (eg. the name is all
lowercase, its the caller's resposibility to exploit it.)
--]]
--@param name string An ndex+abbr or Pokémon name
---@return number|string, string
f.getndexabbr = function(name)
-- name is just an ndex
local ndex = string.match(name, "^(%d+)$")
if ndex then
return tonumber(ndex), "base" ---@diagnostic disable-line: return-type-mismatch
end
-- name is an ndex followed by an abbr
local ndex, abbr = string.match(name, "^(%d+)(%u%a*)$")
if ndex then
return tonumber(ndex), abbr ---@diagnostic disable-line: return-type-mismatch
end
-- name is not an ndex: it's assumed to be a Pokémon name. In this case,
-- there is no abbr and the name is returned as-is
return name, "base"
end
--[[
--]]
f.getlink = function(poke, black, extform)
black = black or
poke, extform = f.getnameabbr(poke, extform)
if extform ==
return
end
return alt[poke] and alt[poke][black ..
end
--]]
f.getNdexForm = function(poke)
if type(poke) ==
return poke
end
end
for k, tab in pairs(alt) do
if type(k) ==
return k
end
-- Converte la sigla vuota in 'base'
f.toBase = function(abbr)
return abbr ==
end
-- Converte la sigla 'base' nella sigla vuota
f.toEmptyAbbr = function(abbr)
return abbr ==
end
--]]
f.hasMega = function(poke)
poke = string.lower(poke or
if alt.mega then
return
or
or
end
return false
--]]
f.hasAlola = function(poke)
poke = string.lower(poke or
if alt.alola then
return
end
return false
f.formSpan = function(poke, abbr)
return alt[poke].since[abbr],
alt[poke]["until"]
end
--]]
f.nameToDataindex = function(name)
name =
local trueName, extform = f.getnameabbr(name)
-- If the name contains uppercase letters it's not recognized by
-- getnameabbr, so this mess is needed
trueName = type(trueName) ==
or
-- The local variable is needed because global alt can be changed with
-- loadUseless
-- extform == 'base' settles problems with numbers and string concat
-- The last check is for Pokémon with both forms
if
extform == "base"
or not trueAlt[tonumber(trueName) or trueName]
or not trueAlt[tonumber(trueName) or trueName].names[extform]
then
return trueName
end
trueName = type(trueName) ==
return trueName .. f.toEmptyAbbr(extform)
end
--]]
f.abbrLT = function(formsData, abbr1, abbr2)
return
end
--]]
f.formSortValue = function(ndex, abbr, poke)
ndex = f.getNdexForm(type(ndex) ==
local data, value, name = alt[ndex],
local formName
if data and data.links[abbr] ~=
formName = data.names[abbr]
value =
end
return
name = name,
form = formName,
})
end
|