mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-08 13:44:59 +00:00
Fixed bug with trainer data, tidied evolution-checking code
This commit is contained in:
@@ -62,7 +62,7 @@ module GameData
|
|||||||
# @param tr_name [String]
|
# @param tr_name [String]
|
||||||
# @param tr_version [Integer, nil]
|
# @param tr_version [Integer, nil]
|
||||||
# @return [self, nil]
|
# @return [self, nil]
|
||||||
def try_get(tr_type, tr_name, tr_version = 0)
|
def self.try_get(tr_type, tr_name, tr_version = 0)
|
||||||
validate tr_type => [Symbol, String]
|
validate tr_type => [Symbol, String]
|
||||||
validate tr_name => [String]
|
validate tr_name => [String]
|
||||||
key = [tr_type.to_sym, tr_name, tr_version]
|
key = [tr_type.to_sym, tr_name, tr_version]
|
||||||
|
|||||||
@@ -605,7 +605,7 @@ def pbEvolutionCheck(currentLevels)
|
|||||||
pkmn = $Trainer.party[i]
|
pkmn = $Trainer.party[i]
|
||||||
next if !pkmn || (pkmn.hp==0 && !Settings::CHECK_EVOLUTION_FOR_FAINTED_POKEMON)
|
next if !pkmn || (pkmn.hp==0 && !Settings::CHECK_EVOLUTION_FOR_FAINTED_POKEMON)
|
||||||
next if currentLevels[i] && pkmn.level==currentLevels[i]
|
next if currentLevels[i] && pkmn.level==currentLevels[i]
|
||||||
newSpecies = EvolutionCheck.check(pkmn)
|
newSpecies = EvolutionCheck.check_level_up_methods(pkmn)
|
||||||
next if !newSpecies
|
next if !newSpecies
|
||||||
evo = PokemonEvolutionScene.new
|
evo = PokemonEvolutionScene.new
|
||||||
evo.pbStartScreen(pkmn,newSpecies)
|
evo.pbStartScreen(pkmn,newSpecies)
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ def pbChangeLevel(pkmn,newlevel,scene)
|
|||||||
pbLearnMove(pkmn,i[1],true) { scene.pbUpdate }
|
pbLearnMove(pkmn,i[1],true) { scene.pbUpdate }
|
||||||
end
|
end
|
||||||
# Check for evolution
|
# Check for evolution
|
||||||
newspecies = EvolutionCheck.check(pkmn)
|
newspecies = EvolutionCheck.check_level_up_methods(pkmn)
|
||||||
if newspecies
|
if newspecies
|
||||||
pbFadeOutInWithMusic {
|
pbFadeOutInWithMusic {
|
||||||
evo = PokemonEvolutionScene.new
|
evo = PokemonEvolutionScene.new
|
||||||
@@ -490,7 +490,7 @@ def pbUseItem(bag,item,bagscene=nil)
|
|||||||
if itm.is_evolution_stone?
|
if itm.is_evolution_stone?
|
||||||
annot = []
|
annot = []
|
||||||
for pkmn in $Trainer.party
|
for pkmn in $Trainer.party
|
||||||
elig = EvolutionCheck.check(pkmn, item)
|
elig = EvolutionCheck.check_item_methods(pkmn, item)
|
||||||
annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
|
annot.push((elig) ? _INTL("ABLE") : _INTL("NOT ABLE"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ ItemHandlers::UseOnPokemon.addIf(proc { |item| GameData::Item.get(item).is_evolu
|
|||||||
scene.pbDisplay(_INTL("It won't have any effect."))
|
scene.pbDisplay(_INTL("It won't have any effect."))
|
||||||
next false
|
next false
|
||||||
end
|
end
|
||||||
newspecies = EvolutionCheck.check(pkmn,item)
|
newspecies = EvolutionCheck.check_item_methods(pkmn, item)
|
||||||
if newspecies
|
if newspecies
|
||||||
pbFadeOutInWithMusic {
|
pbFadeOutInWithMusic {
|
||||||
evo = PokemonEvolutionScene.new
|
evo = PokemonEvolutionScene.new
|
||||||
@@ -356,7 +356,7 @@ ItemHandlers::UseOnPokemon.addIf(proc { |item| GameData::Item.get(item).is_evolu
|
|||||||
evo.pbEvolution(false)
|
evo.pbEvolution(false)
|
||||||
evo.pbEndScreen
|
evo.pbEndScreen
|
||||||
if scene.is_a?(PokemonPartyScreen)
|
if scene.is_a?(PokemonPartyScreen)
|
||||||
scene.pbRefreshAnnotations(proc { |p| !EvolutionCheck.check(p, item).nil? })
|
scene.pbRefreshAnnotations(proc { |p| !EvolutionCheck.check_item_methods(p, item).nil? })
|
||||||
scene.pbRefresh
|
scene.pbRefresh
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,46 +257,32 @@ end
|
|||||||
# Evolution checks
|
# Evolution checks
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
module EvolutionCheck
|
module EvolutionCheck
|
||||||
# The core method that performs evolution checks. Needs a block given to it,
|
module_function
|
||||||
# which will provide either a GameData::Species ID (the species to evolve
|
|
||||||
# into) or nil (keep checking).
|
|
||||||
# @param pkmn [Pokemon] the Pokémon trying to evolve
|
|
||||||
def self.check_ex(pkmn)
|
|
||||||
return nil if !pkmn.species || pokemon.egg? || pokemon.shadowPokemon?
|
|
||||||
return nil if pkmn.hasItem?(:EVERSTONE)
|
|
||||||
return nil if pkmn.hasAbility?(:BATTLEBOND)
|
|
||||||
ret = nil
|
|
||||||
pkmn.species_data.evolutions.each do |evo| # [new_species, method, parameter, boolean]
|
|
||||||
next if evo[3] # Prevolution
|
|
||||||
ret = yield pkmn, evo[1], evo[2], evo[0] # pkmn, method, parameter, new_species
|
|
||||||
break if ret
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end
|
|
||||||
|
|
||||||
# Checks whether a Pokemon can evolve because of levelling up. If the item
|
# Checks whether a Pokemon can evolve because of levelling up.
|
||||||
# parameter is not nil, instead checks whether a Pokémon can evolve because of
|
|
||||||
# using the item on it.
|
|
||||||
# @param pkmn [Pokemon] the Pokémon trying to evolve
|
# @param pkmn [Pokemon] the Pokémon trying to evolve
|
||||||
# @param item [Symbol, GameData::Item, nil] the item being used
|
def check_level_up_methods(pkmn)
|
||||||
def self.check(pkmn, item = nil)
|
return check_ex(pkmn) { |pkmn, method, parameter, new_species|
|
||||||
if item
|
|
||||||
return self.check_ex(pkmn) { |pkmn, method, parameter, new_species|
|
|
||||||
success = PBEvolution.call("itemCheck", method, pkmn, parameter, item)
|
|
||||||
return (success) ? new_species : nil
|
|
||||||
}
|
|
||||||
end
|
|
||||||
return self.check_ex(pkmn) { |pkmn, method, parameter, new_species|
|
|
||||||
success = PBEvolution.call("levelUpCheck", method, pkmn, parameter)
|
success = PBEvolution.call("levelUpCheck", method, pkmn, parameter)
|
||||||
next (success) ? new_species : nil
|
next (success) ? new_species : nil
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Checks whether a Pokemon can evolve because of using an item on it.
|
||||||
|
# @param pkmn [Pokemon] the Pokémon trying to evolve
|
||||||
|
# @param item [Symbol, GameData::Item, nil] the item being used
|
||||||
|
def check_item_methods(pkmn, item)
|
||||||
|
return check_ex(pkmn) { |pkmn, method, parameter, new_species|
|
||||||
|
success = PBEvolution.call("itemCheck", method, pkmn, parameter, item)
|
||||||
|
return (success) ? new_species : nil
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# Checks whether a Pokemon can evolve because of being traded.
|
# Checks whether a Pokemon can evolve because of being traded.
|
||||||
# @param pkmn [Pokemon] the Pokémon trying to evolve
|
# @param pkmn [Pokemon] the Pokémon trying to evolve
|
||||||
# @param other_pkmn [Pokemon] the other Pokémon involved in the trade
|
# @param other_pkmn [Pokemon] the other Pokémon involved in the trade
|
||||||
def self.check_trade_methods(pkmn, other_pkmn)
|
def check_trade_methods(pkmn, other_pkmn)
|
||||||
return self.check_ex(pkmn) { |pkmn, method, parameter, new_species|
|
return check_ex(pkmn) { |pkmn, method, parameter, new_species|
|
||||||
success = PBEvolution.call("tradeCheck", method, pkmn, parameter, other_pkmn)
|
success = PBEvolution.call("tradeCheck", method, pkmn, parameter, other_pkmn)
|
||||||
next (success) ? new_species : nil
|
next (success) ? new_species : nil
|
||||||
}
|
}
|
||||||
@@ -306,12 +292,31 @@ module EvolutionCheck
|
|||||||
# required it to have a held item) or duplicate the Pokémon (Shedinja only).
|
# required it to have a held item) or duplicate the Pokémon (Shedinja only).
|
||||||
# @param pkmn [Pokemon] the Pokémon trying to evolve
|
# @param pkmn [Pokemon] the Pokémon trying to evolve
|
||||||
# @param evolved_species [Pokemon] the species that the Pokémon evolved into
|
# @param evolved_species [Pokemon] the species that the Pokémon evolved into
|
||||||
def self.check_after_evolution(pkmn, evolved_species)
|
def check_after_evolution(pkmn, evolved_species)
|
||||||
pkmn.species_data.evolutions.each do |evo| # [new_species, method, parameter, boolean]
|
pkmn.species_data.evolutions.each do |evo| # [new_species, method, parameter, boolean]
|
||||||
next if evo[3] # Prevolution
|
next if evo[3] # Prevolution
|
||||||
break if PBEvolution.call("afterEvolution", evo[1], pkmn, evo[0], evo[2], evolved_species)
|
break if PBEvolution.call("afterEvolution", evo[1], pkmn, evo[0], evo[2], evolved_species)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
# The core method that performs evolution checks. Needs a block given to it,
|
||||||
|
# which will provide either a GameData::Species ID (the species to evolve
|
||||||
|
# into) or nil (keep checking).
|
||||||
|
# @param pkmn [Pokemon] the Pokémon trying to evolve
|
||||||
|
def self.check_ex(pkmn)
|
||||||
|
return nil if !pkmn.species || pkmn.egg? || pkmn.shadowPokemon?
|
||||||
|
return nil if pkmn.hasItem?(:EVERSTONE)
|
||||||
|
return nil if pkmn.hasAbility?(:BATTLEBOND)
|
||||||
|
ret = nil
|
||||||
|
pkmn.species_data.evolutions.each do |evo| # [new_species, method, parameter, boolean]
|
||||||
|
next if evo[3] # Prevolution
|
||||||
|
ret = yield pkmn, evo[1], evo[2], evo[0] # pkmn, method, parameter, new_species
|
||||||
|
break if ret
|
||||||
|
end
|
||||||
|
return ret
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user