mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-10 06:34:59 +00:00
Tidying
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
# This class stores data on each Pokémon. Refer to $Trainer.party for an array
|
#===============================================================================
|
||||||
# of each Pokémon in the Trainer's current party.
|
# Instances of this class are individual Pokémon.
|
||||||
|
# The player's party Pokémon are stored in the array $Trainer.party.
|
||||||
|
#===============================================================================
|
||||||
class PokeBattle_Pokemon
|
class PokeBattle_Pokemon
|
||||||
# @return [String] the nickname of this Pokémon
|
# @return [String] the nickname of this Pokémon
|
||||||
attr_accessor :name
|
attr_accessor :name
|
||||||
@@ -15,18 +17,18 @@ class PokeBattle_Pokemon
|
|||||||
attr_reader :attack
|
attr_reader :attack
|
||||||
# @return [Integer] the current Defense stat
|
# @return [Integer] the current Defense stat
|
||||||
attr_reader :defense
|
attr_reader :defense
|
||||||
# @return [Integer] the current Speed stat
|
|
||||||
attr_reader :speed
|
|
||||||
# @return [Integer] the current Special Attack stat
|
# @return [Integer] the current Special Attack stat
|
||||||
attr_reader :spatk
|
attr_reader :spatk
|
||||||
# @return [Integer] the current Special Defense stat
|
# @return [Integer] the current Special Defense stat
|
||||||
attr_reader :spdef
|
attr_reader :spdef
|
||||||
|
# @return [Integer] the current Speed stat
|
||||||
|
attr_reader :speed
|
||||||
# If defined, forces the Pokémon's ability to be the first natural (0),
|
# If defined, forces the Pokémon's ability to be the first natural (0),
|
||||||
# second natural (1) or hidden (2) ability available to its species.
|
# second natural (1) or a hidden (2-5) ability available to its species.
|
||||||
# It is not possible to give the Pokémon any ability other than those
|
# It is not possible to give the Pokémon any ability other than those
|
||||||
# defined in the PBS file "pokemon.txt" for its species
|
# defined in the PBS file "pokemon.txt" for its species
|
||||||
# (or "pokemonforms.txt" for its species and form).
|
# (or "pokemonforms.txt" for its species and form).
|
||||||
# @return [0, 1, 2, nil] forced ability index (nil if none is set)
|
# @return [0, 1, 2, 3, 4, 5, nil] forced ability index (nil if none is set)
|
||||||
attr_accessor :abilityflag
|
attr_accessor :abilityflag
|
||||||
# If defined, forces this Pokémon to be male (0) or female (1).
|
# If defined, forces this Pokémon to be male (0) or female (1).
|
||||||
# @return [0, 1, nil] gender to force: male (0) or female (1) (nil if undefined)
|
# @return [0, 1, nil] gender to force: male (0) or female (1) (nil if undefined)
|
||||||
@@ -46,6 +48,11 @@ class PokeBattle_Pokemon
|
|||||||
attr_accessor :firstmoves
|
attr_accessor :firstmoves
|
||||||
# @return [Integer] the ID of the item held by this Pokémon (0 = no held item)
|
# @return [Integer] the ID of the item held by this Pokémon (0 = no held item)
|
||||||
attr_accessor :item
|
attr_accessor :item
|
||||||
|
# @return [Integer] this Pokémon's current status (from PBStatuses)
|
||||||
|
attr_reader :status
|
||||||
|
# @return [Integer] sleep count / toxic flag / 0:
|
||||||
|
# sleep (number of rounds before waking up), toxic (0 = regular poison, 1 = toxic)
|
||||||
|
attr_reader :statusCount
|
||||||
# Another Pokémon which has been fused with this Pokémon (or nil if there is none).
|
# Another Pokémon which has been fused with this Pokémon (or nil if there is none).
|
||||||
# Currently only used by Kyurem, to record a fused Reshiram or Zekrom.
|
# Currently only used by Kyurem, to record a fused Reshiram or Zekrom.
|
||||||
# @return [PokeBattle_Pokemon, nil] the Pokémon fused into this one (nil if there is none)
|
# @return [PokeBattle_Pokemon, nil] the Pokémon fused into this one (nil if there is none)
|
||||||
@@ -209,12 +216,12 @@ class PokeBattle_Pokemon
|
|||||||
# @return [Float] a number between 0 and 1 indicating how much of the current level's
|
# @return [Float] a number between 0 and 1 indicating how much of the current level's
|
||||||
# Exp this Pokémon has
|
# Exp this Pokémon has
|
||||||
def expFraction
|
def expFraction
|
||||||
l = self.level
|
lvl = self.level
|
||||||
return 0.0 if l >= PBExperience.maxLevel
|
return 0.0 if lvl >= PBExperience.maxLevel
|
||||||
gr = self.growthrate
|
growth_rate = self.growthrate
|
||||||
startexp = PBExperience.pbGetStartExperience(l, gr)
|
start_exp = PBExperience.pbGetStartExperience(lvl, growth_rate)
|
||||||
endexp = PBExperience.pbGetStartExperience(l + 1, gr)
|
end_exp = PBExperience.pbGetStartExperience(lvl + 1, growth_rate)
|
||||||
return 1.0 * (@exp - startexp) / (endexp - startexp)
|
return 1.0 * (@exp - start_exp) / (end_exp - start_exp)
|
||||||
end
|
end
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
@@ -224,24 +231,24 @@ class PokeBattle_Pokemon
|
|||||||
# @return [0, 1, 2] this Pokémon's gender (0 = male, 1 = female, 2 = genderless)
|
# @return [0, 1, 2] this Pokémon's gender (0 = male, 1 = female, 2 = genderless)
|
||||||
def gender
|
def gender
|
||||||
# Return sole gender option for all male/all female/genderless species
|
# Return sole gender option for all male/all female/genderless species
|
||||||
genderRate = pbGetSpeciesData(@species,formSimple,SpeciesGenderRate)
|
gender_rate = pbGetSpeciesData(@species, formSimple, SpeciesGenderRate)
|
||||||
case genderRate
|
case gender_rate
|
||||||
when PBGenderRates::AlwaysMale; return 0
|
when PBGenderRates::AlwaysMale; return 0
|
||||||
when PBGenderRates::AlwaysFemale; return 1
|
when PBGenderRates::AlwaysFemale; return 1
|
||||||
when PBGenderRates::Genderless; return 2
|
when PBGenderRates::Genderless; return 2
|
||||||
end
|
end
|
||||||
# Return gender for species that can be male or female
|
# Return gender for species that can be male or female
|
||||||
return @genderflag if @genderflag && (@genderflag == 0 || @genderflag == 1)
|
return @genderflag if @genderflag && (@genderflag == 0 || @genderflag == 1)
|
||||||
return ((@personalID & 0xFF) < PBGenderRates.genderByte(genderRate)) ? 1 : 0
|
return ((@personalID & 0xFF) < PBGenderRates.genderByte(gender_rate)) ? 1 : 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Boolean] whether this Pokémon species is restricted to only ever being one
|
# @return [Boolean] whether this Pokémon species is restricted to only ever being one
|
||||||
# gender (or genderless)
|
# gender (or genderless)
|
||||||
def singleGendered?
|
def singleGendered?
|
||||||
genderRate = pbGetSpeciesData(@species,formSimple,SpeciesGenderRate)
|
gender_rate = pbGetSpeciesData(@species, formSimple, SpeciesGenderRate)
|
||||||
return genderRate == PBGenderRates::AlwaysMale ||
|
return gender_rate == PBGenderRates::AlwaysMale ||
|
||||||
genderRate == PBGenderRates::AlwaysFemale ||
|
gender_rate == PBGenderRates::AlwaysFemale ||
|
||||||
genderRate == PBGenderRates::Genderless
|
gender_rate == PBGenderRates::Genderless
|
||||||
end
|
end
|
||||||
alias isSingleGendered? singleGendered?
|
alias isSingleGendered? singleGendered?
|
||||||
|
|
||||||
@@ -629,22 +636,34 @@ class PokeBattle_Pokemon
|
|||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|
||||||
# @return [Integer] this Pokémon's cool contest attribute
|
# @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
|
# @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
|
# @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
|
# @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
|
# @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
|
# @return [Integer] this Pokémon's sheen contest attribute
|
||||||
def sheen; return @sheen || 0; end
|
def sheen
|
||||||
|
return @sheen || 0
|
||||||
|
end
|
||||||
|
|
||||||
# @return [Integer] the number of ribbons this Pokémon has
|
# @return [Integer] the number of ribbons this Pokémon has
|
||||||
def ribbonCount
|
def ribbonCount
|
||||||
@@ -727,7 +746,7 @@ class PokeBattle_Pokemon
|
|||||||
# Gives an item to this Pokémon. Passing 0 as the argument removes the held item.
|
# Gives an item to this Pokémon. Passing 0 as the argument removes the held item.
|
||||||
# @param item_id [Integer, Symbol, String] id of the item to give to this Pokémon (0 removes held item)
|
# @param item_id [Integer, Symbol, String] id of the item to give to this Pokémon (0 removes held item)
|
||||||
def setItem(item_id)
|
def setItem(item_id)
|
||||||
self.item = item_id.is_a?(Integer) ? item_id : getID(PBItems,item_id)
|
self.item = getID(PBItems, item_id) || 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Array<Integer>] 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
|
||||||
@@ -760,39 +779,14 @@ class PokeBattle_Pokemon
|
|||||||
# Status
|
# Status
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|
||||||
# Returns the current status of this Pokémon. See {PBStatuses} for all possible
|
|
||||||
# status effects.
|
|
||||||
# @return [Integer] current status (from PBStatuses)
|
|
||||||
def status
|
|
||||||
return @status
|
|
||||||
end
|
|
||||||
|
|
||||||
# Sets this Pokémon's status. See {PBStatuses} for all possible status effects.
|
# Sets this Pokémon's status. See {PBStatuses} for all possible status effects.
|
||||||
# @param new_status [Integer, Symbol, String] status to set (from PBStatuses)
|
# @param new_status [Integer, Symbol, String] status to set (from PBStatuses)
|
||||||
def status=(new_status)
|
def status=(value)
|
||||||
if new_status.is_a?(Integer)
|
new_status = getID(PBStatuses, value)
|
||||||
|
if !new_status
|
||||||
|
raise ArgumentError, _INTL('Attempted to set {1} as Pokémon status', value.class.name)
|
||||||
|
end
|
||||||
@status = new_status
|
@status = new_status
|
||||||
else
|
|
||||||
if !new_status.is_a?(Symbol) && !new_status.is_a?(String)
|
|
||||||
raise ArgumentError, _INTL('Attempted to set a {1} as Pokémon status',new_status.class.name)
|
|
||||||
end
|
|
||||||
@status = getID(PBStatuses,new_status)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Is 0, except if the Pokémon is:
|
|
||||||
#
|
|
||||||
# - Asleep: Is the number of rounds the Pokémon will remain asleep.
|
|
||||||
# This number is set when the Pokémon is made to fall asleep.
|
|
||||||
#
|
|
||||||
# - Badly poisoned: If the Pokémon is Poisoned and this is "1", the
|
|
||||||
# Pokémon is badly poisoned instead (which affects how much poison
|
|
||||||
# damage it takes in battle). When the Pokémon leaves battle while
|
|
||||||
# badly poisoned, this value is set to 0 and it becomes regular Poisoned
|
|
||||||
# (even in later battles).
|
|
||||||
# @return [Integer] sleep count / toxic flag
|
|
||||||
def statusCount
|
|
||||||
return @statusCount
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sets a new status count. See {#statusCount} for more information.
|
# Sets a new status count. See {#statusCount} for more information.
|
||||||
@@ -826,7 +820,7 @@ class PokeBattle_Pokemon
|
|||||||
@statusCount = 0
|
@statusCount = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
# Heals all PP of this Pokémon. If a move index is given, heals the PP
|
# Restores all PP of this Pokémon. If a move index is given, restores the PP
|
||||||
# of the move in that index.
|
# of the move in that index.
|
||||||
# @param move_index [Integer] index of the move to heal (-1 if all moves
|
# @param move_index [Integer] index of the move to heal (-1 if all moves
|
||||||
# should be healed)
|
# should be healed)
|
||||||
@@ -854,9 +848,9 @@ class PokeBattle_Pokemon
|
|||||||
# Changes the Pokémon's species and re-calculates its statistics.
|
# 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
|
# @param species_id [Integer] id of the species to change this Pokémon to
|
||||||
def species=(species_id)
|
def species=(species_id)
|
||||||
hasNickname = nicknamed?
|
has_nickname = nicknamed?
|
||||||
@species = species_id
|
@species = species_id
|
||||||
@name = PBSpecies.getName(@species) unless hasNickname
|
@name = PBSpecies.getName(@species) unless has_nickname
|
||||||
@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
|
||||||
@@ -880,10 +874,14 @@ class PokeBattle_Pokemon
|
|||||||
end
|
end
|
||||||
|
|
||||||
# @return [Integer] this Pokémon's language
|
# @return [Integer] this Pokémon's language
|
||||||
def language; return @language || 0; end
|
def language
|
||||||
|
return @language || 0
|
||||||
|
end
|
||||||
|
|
||||||
# @return [Integer] 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
|
||||||
|
|
||||||
# @return [String] 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
|
||||||
@@ -895,14 +893,14 @@ class PokeBattle_Pokemon
|
|||||||
return pbGetSpeciesData(@species, formSimple, SpeciesHeight)
|
return pbGetSpeciesData(@species, formSimple, SpeciesHeight)
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Integer] the weight of this Pokémon in hectograms (0.1 grams)
|
# @return [Integer] the weight of this Pokémon in hectograms (0.1 kilograms)
|
||||||
def weight
|
def weight
|
||||||
return pbGetSpeciesData(@species, formSimple, SpeciesWeight)
|
return pbGetSpeciesData(@species, formSimple, SpeciesWeight)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns an array of booleans indicating whether a stat is made to have
|
# Returns an array of booleans indicating whether a stat is made to have
|
||||||
# maximum IVs (for Hyper Training). Set like @ivMaxed[PBStats::ATTACK] = true
|
# maximum IVs (for Hyper Training). Set like @ivMaxed[PBStats::ATTACK] = true
|
||||||
# @return [Array<Boolean>] array indicating whether a stat has maximum IVs
|
# @return [Array<Boolean>] array indicating whether each stat has maximum IVs
|
||||||
def ivMaxed
|
def ivMaxed
|
||||||
return @ivMaxed || []
|
return @ivMaxed || []
|
||||||
end
|
end
|
||||||
@@ -995,7 +993,7 @@ class PokeBattle_Pokemon
|
|||||||
end
|
end
|
||||||
|
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
# Stat calculations, Pokémon creation
|
# Stat calculations
|
||||||
#=============================================================================
|
#=============================================================================
|
||||||
|
|
||||||
# @return [Array<Integer>] 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
|
||||||
@@ -1007,12 +1005,12 @@ class PokeBattle_Pokemon
|
|||||||
# @return [Integer] 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 / 4)) * level / 100).floor + level + 10
|
||||||
end
|
end
|
||||||
|
|
||||||
# @return [Integer] 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 / 4)) * level / 100).floor + 5) * pv / 100).floor
|
||||||
end
|
end
|
||||||
|
|
||||||
# Recalculates this Pokémon's stats.
|
# Recalculates this Pokémon's stats.
|
||||||
@@ -1041,6 +1039,10 @@ class PokeBattle_Pokemon
|
|||||||
@speed = stats[PBStats::SPEED]
|
@speed = stats[PBStats::SPEED]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Pokémon creation
|
||||||
|
#=============================================================================
|
||||||
|
|
||||||
# Creates a copy of this Pokémon and returns it.
|
# Creates a copy of this Pokémon and returns it.
|
||||||
# @return [PokeBattle_Pokemon] a copy of this Pokémon
|
# @return [PokeBattle_Pokemon] a copy of this Pokémon
|
||||||
def clone
|
def clone
|
||||||
@@ -1069,10 +1071,7 @@ class PokeBattle_Pokemon
|
|||||||
end
|
end
|
||||||
@species = realSpecies
|
@species = realSpecies
|
||||||
@name = PBSpecies.getName(@species)
|
@name = PBSpecies.getName(@species)
|
||||||
@personalID = rand(256)
|
@personalID = rand(2**32)
|
||||||
@personalID |= rand(256)<<8
|
|
||||||
@personalID |= rand(256)<<16
|
|
||||||
@personalID |= rand(256)<<24
|
|
||||||
@hp = 1
|
@hp = 1
|
||||||
@totalhp = 1
|
@totalhp = 1
|
||||||
@iv = []
|
@iv = []
|
||||||
@@ -1122,13 +1121,16 @@ class PokeBattle_Pokemon
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
#===============================================================================
|
||||||
|
|
||||||
# Creates a new Pokémon object.
|
# Creates a new Pokémon object.
|
||||||
# @param species [Integer, Symbol, String] Pokémon species
|
# @param species [Integer, Symbol, String] Pokémon species
|
||||||
# @param level [Integer] Pokémon level
|
# @param level [Integer] Pokémon level
|
||||||
# @param owner [PokeBattle_Trainer] object for the original trainer
|
# @param owner [PokeBattle_Trainer] object for the original trainer
|
||||||
# @param withMoves [Boolean] whether the Pokémon should have moves
|
# @param withMoves [Boolean] whether the Pokémon should have moves
|
||||||
def pbNewPkmn(species,level,owner=nil,withMoves=true)
|
def pbNewPkmn(species, level, owner = $Trainer, withMoves = true)
|
||||||
owner = $Trainer if !owner
|
|
||||||
return PokeBattle_Pokemon.new(species, level, owner, withMoves)
|
return PokeBattle_Pokemon.new(species, level, owner, withMoves)
|
||||||
end
|
end
|
||||||
alias pbGenPkmn pbNewPkmn
|
alias pbGenPkmn pbNewPkmn
|
||||||
|
|||||||
Reference in New Issue
Block a user