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

Added interfaces, types returned with first uppercase
(Bugfix with alternate forms)
(Added interfaces, types returned with first uppercase)
b.getName = function(frame)
data = loadData(data, 'Poké/data')
returnlocal ndex = data[tonumber(string.trim(frame.args[1] or ''))].name
return data[tonumber(ndex) or ndex].name
end
 
b.get_name = b.getName
 
--[[
 
Return the form name given ndex with abbr. If the ndex is without abbr, returns
the Pokémon name even if it hasn't got alternate forms.
 
--]]
 
b.getLinkgetFormName = function(frame)
forms = loadData(forms, 'WikilibAltForms/formsdata', true)
local name, abbr = form.getnameabbr(string.trim(frame.args[1]))
return forms[name] and forms[name].names[abbr] or b.getName{args={name}}
end
 
--[[
local getType = function(name, typeNumber)
data = loadData(data, 'Poké/data')
return string.fu(data[form.nameToDataindex(name)]['type' .. typeNumber])
end
 
--[[
 
The first parameter is an ndex (maybe with an abbr). Returns the second
Frontend for wikilib/forms.getlink: returns the link
parameter if the Pokémon has two types, otherwise the third. The two last
to an'alternate form from module AltForms/data or
parameters are trimmed.
UselessForms/data.
This function is meant to replace an #if parser function to check whether a
The Pokémon name (first argument) can be both a name
Pokémon has two types or not.
or a ndex followed by the form abbreviation, the second
argument is a flag to get black or normal link
 
--]]
b.ifTwoTypes = function(frame)
data = loadData(data, 'Poké/data')
local poke = data[form.nameToDataindex(frame.args[1])]
local isDualType = poke.type1 == poke.type2
return isDualType and string.trim(frame.args[2]) or string.trim(frame.args[3])
end
 
b.getLink = function(frame)
forms = loadData(forms, 'Wikilib/forms', true)
 
--[[
 
Frontend for wikilib/forms.getlink: returns the link to an'alternate form from
module AltForms/data or UselessForms/data. The Pokémon name (first argument)
may be both a name or a ndex followed by the form abbreviationabbr, the second argument is a
argument is a flag to get black or normal link.
 
--]]
 
b.getLink = function(frame)
local name, black = string.trim(frame.args[1]), string.trim(frame.args[2])
local link = formsform.getLink(name, black)
if link ~= '' then
return link
else
formsform.loadUseless(false)
return formsform.getLink(name, black)
end
end