79 548
contributi
m (Annullate le modifiche di F3Bot (discussione), riportata alla versione precedente di Ff300) |
(Preparing for multigen in Poké/data *** sovrascritto il testo esistente ***) |
||
--[[
Module used as a frontend to wikicode for data modules.
Each interface function is documented in its own comment, with examples.
--]]
local txt = require('Modulo:Wikilib/strings') -- luacheck: no unused
local
local multigen = require('Modulo:Wikilib/multigen')
local pokes
local abils
local forms
if not tab then
local loadFunction = useRequire and require or mw.loadData
return loadFunction(moduleName) --loadFunction('Modulo:' .. moduleName)
end
return tab
--[[
Returns ndex given the name.
--]]
b.getNdex = function(frame)
return string.tf(
end
b.get_ndex = b.getNdex
--[[
Returns the name given ndex. The argument can be an alternative forms' ndex.
Ex:
{{#invoke: PokémonData | getNdex | 398 }} --> Staraptor
{{#invoke: PokémonData | getNdex | 65 }} --> Alakazam
{{#invoke: PokémonData | getNdex | 487O }} --> Giratina
--]]
b.getName = function(frame)
end
--[[
Return the form name given ndex with abbr. If the
(or there's no abbr at all) it returns an empty string.
Ex:
{{#invoke: PokémonData | getFormName | 800A }} --> Ali dell'Aurora
{{#invoke: PokémonData | getFormName | 422E }} --> Mare Est
{{#invoke: PokémonData | getFormName | 422 }} --> Mare Ovest
{{#invoke: PokémonData | getFormName | 28 }} --> (empty string)
--]]
b.getFormName = function(frame)
forms =
local name, abbr =
return forms[name] and forms[name].names[formlib.toBase(abbr)] or
end
Returns a Pokémon's ability (specified by the second parameter) given its name
or ndex. The optional third parameter is the generation.
The name can contain a form abbreviation, and if it's a Pokémon name (not an
ndex) it should be lowercase but the first letter, that can be both upper or
--]]
local getAbil = function(name, abilityNumber, gen)
abils = loadData(abils, 'PokéAbil
return multigen.getGenValue(
abils[formlib.nameToDataindex(name)]['ability' .. abilityNumber] or '',
tonumber(gen)
)
end
--[[
Returns a Pokémon's first ability given its name or ndex. An optional 'gen'
parameter specifies the generation.
Ex:
{{#invoke: PokémonData | getAbil1 | 065 }} --> Sincronismo
{{#invoke: PokémonData | getAbil1 | 487O }} --> Levitazione
{{#invoke: PokémonData | getAbil1 | 094 | gen = 5 }} --> Levitazione
--]]
b.getAbil1 = function(frame)
return getAbil(frame.args[1]
end
b.get_abil_1 = b.getAbil1
--[[
Returns a Pokémon's second ability given its name or ndex. If the Pokémon
has no second ability, it returns an empty string. An optional 'gen'
parameter specifies the generation.
Ex:
{{#invoke: PokémonData | getAbil2 | 65 }} --> Forza Interiore
{{#invoke: PokémonData | getAbil2 | 398 }} --> (empty string)
--]]
b.getAbil2 = function(frame)
return getAbil(frame.args[1]
end
b.get_abil_2 = b.getAbil2
--[[
Returns a Pokémon's hidden ability given its name or ndex. If the Pokémon
has no second ability, it returns an empty string. An optional 'gen'
parameter specifies the generation.
Ex:
{{#invoke: PokémonData | getAbild | 65 }} --> Magicscudo
{{#invoke: PokémonData | getAbild | 487O }} --> (empty string)
--]]
b.getAbild = function(frame)
return getAbil(frame.args[1]
end
Returns a Pokémon's type (specified by the second parameter) given its name or
ndex. The optional third parameter is the generation.
The name can contain a form abbreviation, and if it's a Pokémon name (not an
ndex) it should be lowercase but the first letter, that can be both upper or
--]]
local getType = function(name, typeNumber, gen)
return string.fu(
pokes[formlib.nameToDataindex(name)]['type' .. typeNumber],
tonumber(gen)
))
end
--[[
Returns a Pokémon's first type given its name or ndex. An optional 'gen'
parameter specifies the generation.
Ex:
{{#invoke: PokémonData | getType1 | 398 }} --> Normale
{{#invoke: PokémonData | getType1 | 493Fu }} --> Fuoco
--]]
b.getType1 = function(frame)
return getType(frame.args[1]
end
b.get_type_1 = b.getType1
--[[
Returns a Pokémon's second type given its name or ndex. If the Pokémon has
only one type, it returns the first type instead. An optional 'gen' parameter
specifies the generation.
Ex:
{{#invoke: PokémonData | getType2 | 398 }} --> Volante
{{#invoke: PokémonData | getType2 | 65 }} --> Psico
{{#invoke: PokémonData | getType2 | 479L }} --> Acqua
{{#invoke: PokémonData | getType2 | 082 | gen = 1 }} --> Elettro
--]]
b.getType2 = function(frame)
return getType(frame.args[1]
end
--]]
b.ifTwoTypes = function(frame)
local poke =
local isDualType = poke.type1 == poke.type2
return isDualType and string.trim(frame.args[2]) or string.trim(frame.args[3])
--[[
Returns the link to an alternative form. The Pokémon name (first parameter) can
be both a name or a ndex followed by the abbr, the second argument is a flag
to get black or normal link.
The ndex may be the base form's one. If the ndex doesn't correspond to a
Pokémon with alternative forms, it returns an empty string.
Ex:
{{#invoke: PokémonData | getLink | 487 }}
{{#invoke: PokémonData | getLink | 487O }}
{{#invoke: PokémonData | getLink | 028A }}
{{#invoke: PokémonData | getLink | 028 }}
{{#invoke: PokémonData | getLink | 774R }}
{{#invoke: PokémonData | getLink | 398 }}
--]]
b.getLink = function(frame)
local name, black = string.trim(frame.args[1]), string.trim(frame.args[2])
-- Links also to UselessForms
formlib.loadUseless(true)
return formlib.getLink(name, black)
end
|