mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-07 13:15:01 +00:00
Added documentation to most of PokeBattle_Pokemon
This commit is contained in:
@@ -403,11 +403,11 @@ class PokeBattle_Pokemon
|
|||||||
|
|
||||||
# Returns the Pokérus infection stage for this Pokémon.
|
# Returns the Pokérus infection stage for this Pokémon.
|
||||||
# @return [0, 1, 2] Pokérus infection stage
|
# @return [0, 1, 2] Pokérus infection stage
|
||||||
# (0 = not infected, 1 = cured, 2 = infected)
|
# (0 = not infected, 1 = infected, 2 = cured)
|
||||||
def pokerusStage
|
def pokerusStage
|
||||||
return 0 if !@pokerus || @pokerus==0 # Not infected
|
return 0 if !@pokerus || @pokerus==0
|
||||||
return 2 if @pokerus>0 && (@pokerus%16)==0 # Cured
|
return 2 if @pokerus > 0 && (@pokerus % 16) == 0
|
||||||
return 1 # Infected
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
# Gives this Pokémon Pokérus (either the specified strain or a random one).
|
# Gives this Pokémon Pokérus (either the specified strain or a random one).
|
||||||
@@ -595,6 +595,7 @@ class PokeBattle_Pokemon
|
|||||||
@firstmoves.delete(move) if move > 0
|
@firstmoves.delete(move) if move > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Clears this Pokémon's first moves.
|
||||||
def pbClearFirstMoves
|
def pbClearFirstMoves
|
||||||
@firstmoves = []
|
@firstmoves = []
|
||||||
end
|
end
|
||||||
@@ -608,19 +609,32 @@ class PokeBattle_Pokemon
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Contest attributes, ribbons
|
# Contest attributes, ribbons
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|
||||||
|
# @return [Integer] this Pokémon's cool contest attribute
|
||||||
def cool; return @cool || 0; end
|
def cool; return @cool || 0; end
|
||||||
|
|
||||||
|
# @return [Integer] this Pokémon's beauty contest attribute
|
||||||
def beauty; return @beauty || 0; end
|
def beauty; return @beauty || 0; end
|
||||||
|
|
||||||
|
# @return [Integer] this Pokémon's cute contest attribute
|
||||||
def cute; return @cute || 0; end
|
def cute; return @cute || 0; end
|
||||||
|
|
||||||
|
# @return [Integer] this Pokémon's smart contest attribute
|
||||||
def smart; return @smart || 0; end
|
def smart; return @smart || 0; end
|
||||||
|
|
||||||
|
# @return [Integer] this Pokémon's tough contest attribute
|
||||||
def tough; return @tough || 0; end
|
def tough; return @tough || 0; end
|
||||||
|
|
||||||
|
# @return [Integer] this Pokémon's sheen contest attribute
|
||||||
def sheen; return @sheen || 0; end
|
def sheen; return @sheen || 0; end
|
||||||
|
|
||||||
# Returns the number of ribbons this Pokémon has.
|
# @return [Integer] the number of ribbons this Pokémon has
|
||||||
def ribbonCount
|
def ribbonCount
|
||||||
return (@ribbons) ? @ribbons.length : 0
|
return (@ribbons) ? @ribbons.length : 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns whether this Pokémon has the specified ribbon.
|
# @param ribbon [Integer, Symbol, String] ribbon id to check
|
||||||
|
# @return [Boolean] whether this Pokémon has the specified ribbon
|
||||||
def hasRibbon?(ribbon)
|
def hasRibbon?(ribbon)
|
||||||
return false if !@ribbons
|
return false if !@ribbons
|
||||||
ribbon = getID(PBRibbons,ribbon)
|
ribbon = getID(PBRibbons,ribbon)
|
||||||
@@ -628,7 +642,7 @@ class PokeBattle_Pokemon
|
|||||||
return @ribbons.include?(ribbon)
|
return @ribbons.include?(ribbon)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Gives this Pokémon the specified ribbon.
|
# @param ribbon [Integer, Symbol, String] id of the ribbon to give
|
||||||
def giveRibbon(ribbon)
|
def giveRibbon(ribbon)
|
||||||
@ribbons = [] if !@ribbons
|
@ribbons = [] if !@ribbons
|
||||||
ribbon = getID(PBRibbons,ribbon)
|
ribbon = getID(PBRibbons,ribbon)
|
||||||
@@ -636,6 +650,7 @@ class PokeBattle_Pokemon
|
|||||||
@ribbons.push(ribbon) if !@ribbons.include?(ribbon)
|
@ribbons.push(ribbon) if !@ribbons.include?(ribbon)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO Figure out a good way to document this
|
||||||
# Replaces one ribbon with the next one along, if possible.
|
# Replaces one ribbon with the next one along, if possible.
|
||||||
def upgradeRibbon(*arg)
|
def upgradeRibbon(*arg)
|
||||||
@ribbons = [] if !@ribbons
|
@ribbons = [] if !@ribbons
|
||||||
@@ -657,7 +672,7 @@ class PokeBattle_Pokemon
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# Removes the specified ribbon from this Pokémon.
|
# @param ribbon [Integer, Symbol, String] id of the ribbon to remove
|
||||||
def takeRibbon(ribbon)
|
def takeRibbon(ribbon)
|
||||||
return if !@ribbons
|
return if !@ribbons
|
||||||
ribbon = getID(PBRibbons,ribbon)
|
ribbon = getID(PBRibbons,ribbon)
|
||||||
@@ -678,20 +693,24 @@ class PokeBattle_Pokemon
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Items
|
# Items
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|
||||||
# Returns whether this Pokémon is holding an item. If an item id is passed,
|
# Returns whether this Pokémon is holding an item. If an item id is passed,
|
||||||
# returns whether the Pokémon is holding that item.
|
# returns whether the Pokémon is holding that item.
|
||||||
|
# @param item_id [Integer, Symbol, String] id of the item to check
|
||||||
|
# @return [Boolean] whether the Pokémon is holding the specified item or
|
||||||
|
# an item at all
|
||||||
def hasItem?(item_id = 0)
|
def hasItem?(item_id = 0)
|
||||||
held_item = self.item
|
held_item = self.item
|
||||||
return held_item > 0 if item_id == 0
|
return held_item > 0 if item_id == 0
|
||||||
return held_item == getID(PBItems,item_id)
|
return held_item == getID(PBItems,item_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets this Pokémon's item. Accepts symbols.
|
# @param item_id [Integer, Symbol, String] id of the item to give to this Pokémon
|
||||||
def setItem(value)
|
def setItem(item_id)
|
||||||
self.item = getID(PBItems,value)
|
self.item = getID(PBItems,item_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the items this species can be found holding in the wild.
|
# @return [Array<Integer>] the items this species can be found holding in the wild
|
||||||
def wildHoldItems
|
def wildHoldItems
|
||||||
ret = []
|
ret = []
|
||||||
ret.push(pbGetSpeciesData(@species,formSimple,SpeciesWildItemCommon))
|
ret.push(pbGetSpeciesData(@species,formSimple,SpeciesWildItemCommon))
|
||||||
@@ -718,40 +737,47 @@ class PokeBattle_Pokemon
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Other
|
# Other
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
def species=(value)
|
|
||||||
|
# Changes the Pokémon's species and re-calculates its statistics.
|
||||||
|
# @param species_id [Integer] id of the species to change this Pokémon to
|
||||||
|
def species=(species_id)
|
||||||
hasNickname = nicknamed?
|
hasNickname = nicknamed?
|
||||||
@species = value
|
@species = species_id
|
||||||
@name = PBSpecies.getName(@species) unless hasNickname
|
@name = PBSpecies.getName(@species) unless hasNickname
|
||||||
@level = nil # In case growth rate is different for the new species
|
@level = nil # In case growth rate is different for the new species
|
||||||
@forcedForm = nil
|
@forcedForm = nil
|
||||||
calcStats
|
calcStats
|
||||||
end
|
end
|
||||||
|
|
||||||
def isSpecies?(s)
|
# @param species [Integer, Symbol, String] id of the species to check for
|
||||||
s = getID(PBSpecies,s)
|
# @return [Boolean] whether this Pokémon is of the specified species
|
||||||
return s && @species==s
|
def isSpecies?(species)
|
||||||
|
species = getID(PBSpecies,species)
|
||||||
|
return species && @species == species
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the species name of this Pokémon.
|
# @return [String] the species name of this Pokémon
|
||||||
def speciesName
|
def speciesName
|
||||||
return PBSpecies.getName(@species)
|
return PBSpecies.getName(@species)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [Boolean] whether this Pokémon has been nicknamed
|
||||||
def nicknamed?
|
def nicknamed?
|
||||||
return @name != self.speciesName
|
return @name != self.speciesName
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns this Pokémon's language.
|
# @return [Integer] this Pokémon's language
|
||||||
def language; return @language || 0; end
|
def language; return @language || 0; end
|
||||||
|
|
||||||
# Returns the markings this Pokémon has.
|
# @return [Integer] the markings this Pokémon has
|
||||||
def markings; return @markings || 0; end
|
def markings; return @markings || 0; end
|
||||||
|
|
||||||
# Returns a string stating the Unown form of this Pokémon.
|
# @return [String] a string stating the Unown form of this Pokémon
|
||||||
def unownShape
|
def unownShape
|
||||||
return "ABCDEFGHIJKLMNOPQRSTUVWXYZ?!"[@form,1]
|
return "ABCDEFGHIJKLMNOPQRSTUVWXYZ?!"[@form,1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO Check whether #height and #weight always return an integer
|
||||||
# Returns the height of this Pokémon.
|
# Returns the height of this Pokémon.
|
||||||
def height
|
def height
|
||||||
return pbGetSpeciesData(@species,formSimple,SpeciesHeight)
|
return pbGetSpeciesData(@species,formSimple,SpeciesHeight)
|
||||||
@@ -794,11 +820,13 @@ class PokeBattle_Pokemon
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [Boolean] whether the Pokémon is not fainted and not an egg
|
||||||
def able?
|
def able?
|
||||||
return !egg? && @hp>0
|
return !egg? && @hp>0
|
||||||
end
|
end
|
||||||
alias isAble? able?
|
alias isAble? able?
|
||||||
|
|
||||||
|
# @return [Boolean] whether the Pokémon is fainted
|
||||||
def fainted?
|
def fainted?
|
||||||
return !egg? && @hp<=0
|
return !egg? && @hp<=0
|
||||||
end
|
end
|
||||||
@@ -817,11 +845,14 @@ class PokeBattle_Pokemon
|
|||||||
@statusCount = 0
|
@statusCount = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# Heals all PP of this Pokémon.
|
# Heals all PP of this Pokémon. If a move index is given, heals the PP
|
||||||
def healPP(index=-1)
|
# of the move in that index.
|
||||||
|
# @param move_index [Integer] index of the move to heal (-1 if all moves
|
||||||
|
# should be healed)
|
||||||
|
def healPP(move_index = -1)
|
||||||
return if egg?
|
return if egg?
|
||||||
if index>=0
|
if move_index >= 0
|
||||||
@moves[index].pp = @moves[index].totalpp
|
@moves[move_index].pp = @moves[move_index].totalpp
|
||||||
else
|
else
|
||||||
@moves.each { |m| m.pp = m.totalpp }
|
@moves.each { |m| m.pp = m.totalpp }
|
||||||
end
|
end
|
||||||
@@ -836,6 +867,7 @@ class PokeBattle_Pokemon
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Changes the happiness of this Pokémon depending on what happened to change it.
|
# Changes the happiness of this Pokémon depending on what happened to change it.
|
||||||
|
# @param method [String] the happiness changing method (e.g. 'walking')
|
||||||
def changeHappiness(method)
|
def changeHappiness(method)
|
||||||
gain = 0
|
gain = 0
|
||||||
case method
|
case method
|
||||||
@@ -896,19 +928,20 @@ class PokeBattle_Pokemon
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Stat calculations, Pokémon creation
|
# Stat calculations, Pokémon creation
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Returns this Pokémon's base stats. An array of six values.
|
|
||||||
|
# @return [Array<Integer>] this Pokémon's base stats, an array of six values
|
||||||
def baseStats
|
def baseStats
|
||||||
ret = pbGetSpeciesData(@species,formSimple,SpeciesBaseStats)
|
ret = pbGetSpeciesData(@species,formSimple,SpeciesBaseStats)
|
||||||
return ret.clone
|
return ret.clone
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the maximum HP of this Pokémon.
|
# @return [Integer] the maximum HP of this Pokémon
|
||||||
def calcHP(base,level,iv,ev)
|
def calcHP(base,level,iv,ev)
|
||||||
return 1 if base == 1 # For Shedinja
|
return 1 if base == 1 # For Shedinja
|
||||||
return ((base * 2 + iv + (ev >> 2)) * level / 100).floor + level + 10
|
return ((base * 2 + iv + (ev >> 2)) * level / 100).floor + level + 10
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the specified stat of this Pokémon (not used for total HP).
|
# @return [Integer] the specified stat of this Pokémon (not used for total HP)
|
||||||
def calcStat(base,level,iv,ev,pv)
|
def calcStat(base,level,iv,ev,pv)
|
||||||
return ((((base*2+iv+(ev>>2))*level/100).floor+5)*pv/100).floor
|
return ((((base*2+iv+(ev>>2))*level/100).floor+5)*pv/100).floor
|
||||||
end
|
end
|
||||||
@@ -939,6 +972,7 @@ class PokeBattle_Pokemon
|
|||||||
@speed = stats[PBStats::SPEED]
|
@speed = stats[PBStats::SPEED]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @return [PokeBattle_Pokemon] a copy of this Pokémon
|
||||||
def clone
|
def clone
|
||||||
ret = super
|
ret = super
|
||||||
ret.iv = @iv.clone
|
ret.iv = @iv.clone
|
||||||
@@ -951,10 +985,10 @@ class PokeBattle_Pokemon
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Creates a new Pokémon object.
|
# Creates a new Pokémon object.
|
||||||
# species - Pokémon species.
|
# @param species [Integer, Symbol, String] Pokémon species
|
||||||
# level - Pokémon level.
|
# @param level [Integer] Pokémon level
|
||||||
# player - PokeBattle_Trainer object for the original trainer.
|
# @param player [PokeBattle_Trainer] object for the original trainer
|
||||||
# withMoves - If false, this Pokémon has no moves.
|
# @param withMoves [Boolean] whether the Pokémon should have moves
|
||||||
def initialize(species,level,player=nil,withMoves=true)
|
def initialize(species,level,player=nil,withMoves=true)
|
||||||
ospecies = species.to_s
|
ospecies = species.to_s
|
||||||
species = getID(PBSpecies,species)
|
species = getID(PBSpecies,species)
|
||||||
@@ -1018,8 +1052,7 @@ class PokeBattle_Pokemon
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# (see PokeBattle_Pokemon#initialize)
|
||||||
|
|
||||||
def pbNewPkmn(species,level,owner=nil,withMoves=true)
|
def pbNewPkmn(species,level,owner=nil,withMoves=true)
|
||||||
owner = $Trainer if !owner
|
owner = $Trainer if !owner
|
||||||
return PokeBattle_Pokemon.new(species,level,owner,withMoves)
|
return PokeBattle_Pokemon.new(species,level,owner,withMoves)
|
||||||
|
|||||||
Reference in New Issue
Block a user