79 548
contributi
(Changed formlib.nameToDataindex interface *** sovrascritto il testo esistente ***) |
(Quick fix *** sovrascritto il testo esistente ***) |
||
local formlib = require('Modulo:Wikilib/forms')
local multigen = require('Modulo:Wikilib/multigen')
local wlib = require('Modulo:Wikilib')
local cc = require('Modulo:ChooseColor')
-- stylua: ignore end
local function parseName(name, abbr)▼
local abbr = abbr and txt.trim(abbr)
▲Parse the input data when it's a Pokémon name.
return formlib.nameToDataindex(mw.text.decode(name), abbr)▼
▲local function parseName(name)
▲ return formlib.nameToDataindex(mw.text.decode(name))
end
--[[
Returns the ndex given the name. Note that this is the plain (ingame) ndex even
for alternative forms.
Ex:
{{#invoke: PokémonData | getNdex | Staraptor }} --> 0398
{{#invoke: PokémonData | getNdex | alakazam }} --> 0065
{{#invoke: PokémonData | getNdex | giratina | form = O }} --> 0487
--]]
b.getNdex = function(frame)
local pokes = mw.loadData('Modulo:Poké/data')
return txt.ff(pokes[parseName(frame.args[1], frame.args.form)].ndex)
end
b.get_ndex = b.getNdex
b.getName = function(frame)
local pokes = mw.loadData('Modulo:Poké/data')
return pokes[parseName(frame.args[1], frame.args.form)].name
end
b.get_name = b.getName
b.getFormName = function(frame)
local forms = formlib.allFormsData()
local
local name, abbr = formlib.getndexabbr(p[1], p.form)
return forms[name] and forms[name].names[formlib.toBase(abbr)] or ""
end
local abils = mw.loadData('Modulo:PokéAbil/data')
return multigen.getGenValue(
abils[parseName(frame.args[1], frame.args.form)]["ability" .. abilityNumber]
or "",
tonumber(gen)
)
Returns a Pokémon's type (specified by the second parameter) given its name or
ndex.
specify the form abbr.
--]]
local function getType(
local pokes = mw.loadData('Modulo:Poké/data')
local p = wlib.trimAll(frame.args)
return txt.fu(
multigen.getGenValue(
pokes[parseName(
tonumber(p.gen)
)
)
Returns a Pokémon's first type given its name or ndex. An optional 'gen'
parameter specifies the generation.
The form abbr can be included in the ndex, but not in the Pokémon name; in the
latter case, use the optional parameter 'form' to specify it.
Ex:
{{#invoke: PokémonData | getType1 | Staraptor }} --> Normale
{{#invoke: PokémonData | getType1 | 493Fu }} --> Fuoco
{{#invoke: PokémonData | getType1 | Aegislash | form = S }} --> Spettro
--]]
b.getType1 = function(frame)
return getType(frame
end
b.get_type_1 = b.getType1
only one type, it returns the first type instead. An optional 'gen' parameter
specifies the generation.
The form abbr can be included in the ndex, but not in the Pokémon name; in the
latter case, use the optional parameter 'form' to specify it.
Ex:
{{#invoke: PokémonData | getType2 | 479L }} --> Acqua
{{#invoke: PokémonData | getType2 | 082 | gen = 1 }} --> Elettro
{{#invoke: PokémonData | getType2 | Giratina | form = O }} --> Drago
--]]
b.getType2 = function(frame)
return getType(frame
end
b.get_type_2 = b.getType2
used as CSS gradient classes. An optional 'gen' parameter specifies the
generation.
The form abbr can be included in the ndex, but not in the Pokémon name; in the
latter case, use the optional parameter 'form' to specify it.
Ex:
Returns a Pokémon's stats (specified by the second parameter) given its name or
ndex.
The form abbr can be included in the ndex, but not in the Pokémon name; in the
latter case, use the optional parameter 'form' to specify it.
Ex:
local stat = txt.trim(frame.args[2])
return multigen.getGenValue(
stats[parseName(frame.args[1], frame.args.form)][stat],
tonumber(frame.args.gen)
)
This function is meant to replace an #if parser function to check whether a
Pokémon has two types or not.
The form abbr can be included in the ndex, but not in the Pokémon name; in the
latter case, use the optional parameter 'form' to specify it.
--]]
b.ifTwoTypes = function(frame)
local pokes = mw.loadData('Modulo:Poké/data')
local poke = pokes[parseName(frame.args[1], frame.args.form)]
local isDualType = poke.type1 == poke.type2
return isDualType and txt.trim(frame.args[2]) or txt.trim(frame.args[3])
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.
The form abbr can be included in the ndex, but not in the Pokémon name; in the
latter case, use the optional parameter 'form' to specify it.
Ex:
b.getLink = function(frame)
local name = txt.trim(frame.args[1])
local abbr = frame.args.form and txt.trim(frame.args.form)
local black = txt.trim(frame.args[2] or "")
-- Links also to UselessForms
formlib.loadUseless(true)
return formlib.getLink(name, black, abbr)
end
b.getlink = b.getLink
optional 'gen' parameter specifies the generation. The result is one of the two
css classes "white-text" and "black-text".
The form abbr can be included in the ndex, but not in the Pokémon name; in the
latter case, use the optional parameter 'form' to specify it.
Ex:
{{#invoke: PokémonData | getPokeTextColor | 398 }} --> black-text
{{#invoke: PokémonData | getPokeTextColor | Staraptor }} --> black-text
{{#invoke: PokémonData | getPokeTextColor | 498O }} --> white-text
{{#invoke: PokémonData | getPokeTextColor | 082 | gen = 1 }} --> black-text
{{#invoke: PokémonData | getPokeTextColor | Rotom | form = L }} --> black-text
--]]
b.getPokeTextColor = function(frame)
local type1 =
local type2 =
return cc.forModGradBgLua(type1, type2)
|