Differenze tra le versioni di "Modulo:PokémonData"

Vai alla navigazione Vai alla ricerca
Quick fix *** sovrascritto il testo esistente ***
(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
 
-- Parse the input data when it's a Pokémon name.
--[[
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 name, abbrp = formlib.getnameabbr(txtwlib.trimtrimAll(frame.args[1]))
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 "",
or "",
tonumber(gen)
)
 
Returns a Pokémon's type (specified by the second parameter) given its name or
ndex. TheOptional optionalparameters thirdare parametergen, isto specify the generation., and form, to
specify the form abbr.
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
lower case.
 
--]]
local function getType(nameframe, typeNumber, gen)
local pokes = mw.loadData('Modulo:Poké/data')
local p = wlib.trimAll(frame.args)
return txt.fu(
multigen.getGenValue(
pokes[parseName(namep[1], p.form)]["type" .. typeNumber],
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.args[1], "1", frame.args.gen)
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.args[1], "2", frame.args.gen)
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. TheAn optional third'gen' parameter isspecifies the generation. If the Pokémon
If the Pokémon doesn't have the stat (i.e: stat "spec" of a non gen 1 Pokémon) return an empty
return 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:
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 = getTypeb.getType1(frame.args[1], "1", frame.args.gen):lower()
local type2 = getTypeb.getType2(frame.args[1], "2", frame.args.gen):lower()
 
return cc.forModGradBgLua(type1, type2)
79 548

contributi

Menu di navigazione