Revamped classes Pokemon, PBMove and PokemonMail

This commit is contained in:
Maruno17
2021-01-21 23:04:51 +00:00
parent 94ce80c183
commit 8a89ef1220
40 changed files with 1016 additions and 1038 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,43 +0,0 @@
#===============================================================================
# Move objects known by Pokémon.
#===============================================================================
class PBMove
attr_reader :id # This move's ID
attr_accessor :pp # The amount of PP remaining for this move
attr_accessor :ppup # The number of PP Ups used on this move
# Initializes this object to the specified move ID.
def initialize(move_id)
@id = GameData::Move.get(move_id).id
@ppup = 0
@pp = total_pp
end
# Changes this move's ID, and caps the PP amount if it is now greater than the
# new move's total PP.
def id=(value)
old_id = @id
@id = GameData::Move.get(value).id
@pp = [@pp, total_pp].min
end
# Gets the maximum PP for this move.
def total_pp
max_pp = GameData::Move.get(@id).total_pp
return max_pp + max_pp * @ppup / 5
end
alias totalpp total_pp
def function_code; return GameData::Move.get(@id).function_code; end
def base_damage; return GameData::Move.get(@id).base_damage; end
def type; return GameData::Move.get(@id).type; end
def category; return GameData::Move.get(@id).category; end
def accuracy; return GameData::Move.get(@id).accuracy; end
def effect_chance; return GameData::Move.get(@id).effect_chance; end
def target; return GameData::Move.get(@id).target; end
def priority; return GameData::Move.get(@id).priority; end
def flags; return GameData::Move.get(@id).flags; end
def name; return GameData::Move.get(@id).name; end
def description; return GameData::Move.get(@id).description; end
def hidden_move?; return GameData::Move.get(@id).hidden_move?; end
end

View File

@@ -0,0 +1,77 @@
#===============================================================================
# Move objects known by Pokémon.
#===============================================================================
class Pokemon
class Move
# This move's ID.
attr_reader :id
# The amount of PP remaining for this move.
attr_reader :pp
# The number of PP Ups used on this move (each one adds 20% to the total PP).
attr_reader :ppup
# Creates a new Move object.
# @param move_id [Symbol, String, Integer] move ID
def initialize(move_id)
@id = GameData::Move.get(move_id).id
@ppup = 0
@pp = total_pp
end
# Sets this move's ID, and caps the PP amount if it is now greater than this
# move's total PP.
# @param value [Symbol, String, Integer] the new move ID
def id=(value)
@id = GameData::Move.get(value).id
@pp = @pp.clamp(0, total_pp)
end
# Sets this move's PP, capping it at this move's total PP.
# @param value [Integer] the new PP amount
def pp=(value)
@pp = value.clamp(0, total_pp)
end
# Sets this move's PP Up count, and caps the PP if necessary.
# @param value [Integer] the new PP Up value
def ppup=(value)
@ppup = value
@pp = @pp.clamp(0, total_pp)
end
# Returns the total PP of this move, taking PP Ups into account.
# @return [Integer] total PP
def total_pp
max_pp = GameData::Move.get(@id).total_pp
return max_pp + max_pp * @ppup / 5
end
alias totalpp total_pp
def function_code; return GameData::Move.get(@id).function_code; end
def base_damage; return GameData::Move.get(@id).base_damage; end
def type; return GameData::Move.get(@id).type; end
def category; return GameData::Move.get(@id).category; end
def accuracy; return GameData::Move.get(@id).accuracy; end
def effect_chance; return GameData::Move.get(@id).effect_chance; end
def target; return GameData::Move.get(@id).target; end
def priority; return GameData::Move.get(@id).priority; end
def flags; return GameData::Move.get(@id).flags; end
def name; return GameData::Move.get(@id).name; end
def description; return GameData::Move.get(@id).description; end
def hidden_move?; return GameData::Move.get(@id).hidden_move?; end
end
end
#===============================================================================
# Move objects known by Pokémon.
#===============================================================================
class PBMove
attr_reader :id, :pp, :ppup
def self.copy(move)
ret = Pokemon::Move.new(move.id)
ret.ppup = move.ppup
ret.pp = move.pp
return ret
end
end

View File

@@ -36,9 +36,9 @@ def pbPurify(pokemon,scene)
end
pokemon.savedev = nil
end
newexp = PBExperience.pbAddExperience(pokemon.exp,pokemon.savedexp||0,pokemon.growthrate)
newexp = PBExperience.pbAddExperience(pokemon.exp,pokemon.savedexp||0,pokemon.growth_rate)
pokemon.savedexp = nil
newlevel = PBExperience.pbGetLevelFromExperience(newexp,pokemon.growthrate)
newlevel = PBExperience.pbGetLevelFromExperience(newexp,pokemon.growth_rate)
curlevel = pokemon.level
if newexp!=pokemon.exp
scene.pbDisplay(_INTL("{1} regained {2} Exp. Points!",pokemon.name,newexp-pokemon.exp))
@@ -53,7 +53,7 @@ def pbPurify(pokemon,scene)
if scene.pbConfirm(_INTL("Would you like to give a nickname to {1}?", pokemon.speciesName))
newname = pbEnterPokemonName(_INTL("{1}'s nickname?", pokemon.speciesName),
0, Pokemon::MAX_NAME_SIZE, "", pokemon)
pokemon.name = newname if newname!=""
pokemon.name = newname
end
end

View File

@@ -529,7 +529,7 @@ PBEvolution.register(:HappinessHoldItem, {
},
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
pkmn.setItem(nil) # Item is now consumed
pkmn.item = nil # Item is now consumed
next true
}
})
@@ -557,7 +557,7 @@ PBEvolution.register(:HoldItem, {
},
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
pkmn.setItem(nil) # Item is now consumed
pkmn.item = nil # Item is now consumed
next true
}
})
@@ -570,7 +570,7 @@ PBEvolution.register(:HoldItemMale, {
},
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
pkmn.setItem(nil) # Item is now consumed
pkmn.item = nil # Item is now consumed
next true
}
})
@@ -583,7 +583,7 @@ PBEvolution.register(:HoldItemFemale, {
},
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
pkmn.setItem(nil) # Item is now consumed
pkmn.item = nil # Item is now consumed
next true
}
})
@@ -596,7 +596,7 @@ PBEvolution.register(:DayHoldItem, {
},
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
pkmn.setItem(nil) # Item is now consumed
pkmn.item = nil # Item is now consumed
next true
}
})
@@ -609,7 +609,7 @@ PBEvolution.register(:NightHoldItem, {
},
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
pkmn.setItem(nil) # Item is now consumed
pkmn.item = nil # Item is now consumed
next true
}
})
@@ -622,7 +622,7 @@ PBEvolution.register(:HoldItemHappiness, {
},
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
pkmn.setItem(nil) # Item is now consumed
pkmn.item = nil # Item is now consumed
next true
}
})
@@ -757,7 +757,7 @@ PBEvolution.register(:TradeItem, {
},
"afterEvolution" => proc { |pkmn, new_species, parameter, evo_species|
next false if evo_species != new_species || !pkmn.hasItem?(parameter)
pkmn.setItem(nil) # Item is now consumed
pkmn.item = nil # Item is now consumed
next true
}
})

View File

@@ -28,49 +28,50 @@ class PokeBattle_Pokemon
def self.copy(pkmn)
owner = Pokemon::Owner.new(pkmn.trainerID, pkmn.ot, pkmn.otgender, pkmn.language)
ret = Pokemon.new(pkmn.species, pkmn.level, owner, false)
ret.name = pkmn.name
ret.exp = pkmn.exp
ret.forcedForm = pkmn.forcedForm if pkmn.forcedForm
ret.formTime = pkmn.formTime
ret.forcedForm = pkmn.forcedForm
ret.hp = pkmn.hp
ret.abilityflag = pkmn.abilityflag
ret.genderflag = pkmn.genderflag
ret.natureflag = pkmn.natureflag
ret.natureOverride = pkmn.natureOverride
ret.shinyflag = pkmn.shinyflag
ret.item_id = pkmn.item
ret.mail = pkmn.mail
ret.moves = pkmn.moves
ret.firstmoves = pkmn.firstmoves.clone
ret.exp = pkmn.exp
ret.eggsteps = pkmn.eggsteps
ret.status = pkmn.status
ret.statusCount = pkmn.statusCount
ret.iv = pkmn.iv.clone
ret.ev = pkmn.ev.clone
ret.ivMaxed = pkmn.ivMaxed if pkmn.ivMaxed
ret.happiness = pkmn.happiness
ret.ballused = pkmn.ballused
ret.eggsteps = pkmn.eggsteps
ret.markings = pkmn.markings if pkmn.markings
ret.ribbons = pkmn.ribbons.clone
ret.pokerus = pkmn.pokerus
ret.personalID = pkmn.personalID
ret.obtainMode = pkmn.obtainMode
ret.obtainMap = pkmn.obtainMap
ret.obtainText = pkmn.obtainText
ret.obtainLevel = pkmn.obtainLevel if pkmn.obtainLevel
ret.hatchedMap = pkmn.hatchedMap
ret.timeReceived = pkmn.timeReceived
ret.timeEggHatched = pkmn.timeEggHatched
ret.gender = pkmn.genderflag
ret.shiny = pkmn.shinyflag
ret.ability_index = pkmn.abilityflag
ret.nature = pkmn.natureflag
ret.nature_for_stats = pkmn.natureOverride
ret.item = pkmn.item
ret.mail = PokemonMail.copy(pkmn.mail) if pkmn.mail
pkmn.moves.each { |m| ret.moves.push(PBMove.copy(m)) if m && m.id > 0 }
pkmn.firstmoves.each { |m| ret.pbAddFirstMove(m) }
ret.ribbons = pkmn.ribbons.clone if pkmn.ribbons
ret.cool = pkmn.cool if pkmn.cool
ret.beauty = pkmn.beauty if pkmn.beauty
ret.cute = pkmn.cute if pkmn.cute
ret.smart = pkmn.smart if pkmn.smart
ret.tough = pkmn.tough if pkmn.tough
ret.sheen = pkmn.sheen if pkmn.sheen
ret.pokerus = pkmn.pokerus if pkmn.pokerus
ret.name = pkmn.name
ret.happiness = pkmn.happiness
ret.ballused = pkmn.ballused
ret.markings = pkmn.markings if pkmn.markings
ret.iv = pkmn.iv.clone
ret.ivMaxed = pkmn.ivMaxed.clone if pkmn.ivMaxed
ret.ev = pkmn.ev.clone
ret.obtain_method = pkmn.obtainMode
ret.obtainMap = pkmn.obtainMap
ret.obtainText = pkmn.obtainText
ret.obtainLevel = pkmn.obtainLevel if pkmn.obtainLevel
ret.hatchedMap = pkmn.hatchedMap
ret.timeReceived = pkmn.timeReceived
ret.timeEggHatched = pkmn.timeEggHatched
if pkmn.fused
ret.fused = PokeBattle_Pokemon.copy(pkmn.fused) if pkmn.fused.is_a?(PokeBattle_Pokemon)
ret.fused = pkmn.fused if pkmn.fused.is_a?(Pokemon)
end
ret.personalID = pkmn.personalID
ret.hp = pkmn.hp
ret.shadow = pkmn.shadow
ret.heartgauge = pkmn.heartgauge
ret.savedexp = pkmn.savedexp
@@ -79,7 +80,8 @@ class PokeBattle_Pokemon
ret.shadowmoves = pkmn.shadowmoves.clone
ret.shadowmovenum = pkmn.shadowmovenum
# NOTE: Intentionally set last, as it recalculates stats.
ret.formSimple = pkmn.form
ret.formSimple = pkmn.form || 0
return ret
end
end
@@ -140,6 +142,42 @@ class Pokemon
Deprecation.warn_method('Pokemon#language=', 'v20', 'Pokemon::Owner#language=')
@owner.language = value
end
# @deprecated Use {Pokemon#gender=} instead. This alias is slated to be removed in v20.
def setGender(value)
Deprecation.warn_method('Pokemon#setGender', 'v20', 'Pokemon#gender=')
self.gender = value
end
# @deprecated Use {Pokemon#shiny=} instead. This alias is slated to be removed in v20.
def makeShiny
Deprecation.warn_method('Pokemon#makeShiny', 'v20', 'Pokemon#shiny=true')
self.shiny = true
end
# @deprecated Use {Pokemon#shiny=} instead. This alias is slated to be removed in v20.
def makeNotShiny
Deprecation.warn_method('Pokemon#makeNotShiny', 'v20', 'Pokemon#shiny=false')
self.shiny = false
end
# @deprecated Use {Pokemon#ability_index=} instead. This alias is slated to be removed in v20.
def setAbility(value)
Deprecation.warn_method('Pokemon#setAbility', 'v20', 'Pokemon#ability_index=')
self.ability_index = value
end
# @deprecated Use {Pokemon#nature=} instead. This alias is slated to be removed in v20.
def setNature(value)
Deprecation.warn_method('Pokemon#setNature', 'v20', 'Pokemon#nature=')
self.nature = value
end
# @deprecated Use {Pokemon#item=} instead. This alias is slated to be removed in v20.
def setItem(value)
Deprecation.warn_method('Pokemon#setItem', 'v20', 'Pokemon#item=')
self.item = value
end
end
# (see Pokemon#initialize)