mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
addIf now need an identifier symbol, fixed clas between using Future Sight and being locked into a move, fixed IV inheritance
This commit is contained in:
@@ -181,13 +181,13 @@ end
|
|||||||
class HandlerHash2
|
class HandlerHash2
|
||||||
def initialize
|
def initialize
|
||||||
@hash = {}
|
@hash = {}
|
||||||
@add_ifs = []
|
@add_ifs = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](sym)
|
def [](sym)
|
||||||
sym = sym.id if !sym.is_a?(Symbol) && sym.respond_to?("id")
|
sym = sym.id if !sym.is_a?(Symbol) && sym.respond_to?("id")
|
||||||
return @hash[sym] if sym && @hash[sym]
|
return @hash[sym] if sym && @hash[sym]
|
||||||
@add_ifs.each do |add_if|
|
@add_ifs.each_value do |add_if|
|
||||||
return add_if[1] if add_if[0].call(sym)
|
return add_if[1] if add_if[0].call(sym)
|
||||||
end
|
end
|
||||||
return nil
|
return nil
|
||||||
@@ -200,11 +200,11 @@ class HandlerHash2
|
|||||||
@hash[sym] = handler || handlerBlock if sym
|
@hash[sym] = handler || handlerBlock if sym
|
||||||
end
|
end
|
||||||
|
|
||||||
def addIf(conditionProc, handler = nil, &handlerBlock)
|
def addIf(sym, conditionProc, handler = nil, &handlerBlock)
|
||||||
if ![Proc, Hash].include?(handler.class) && !block_given?
|
if ![Proc, Hash].include?(handler.class) && !block_given?
|
||||||
raise ArgumentError, "addIf call for #{self.class.name} has no valid handler (#{handler.inspect} was given)"
|
raise ArgumentError, "addIf call for #{sym} in #{self.class.name} has no valid handler (#{handler.inspect} was given)"
|
||||||
end
|
end
|
||||||
@add_ifs.push([conditionProc, handler || handlerBlock])
|
@add_ifs[sym] = [conditionProc, handler || handlerBlock]
|
||||||
end
|
end
|
||||||
|
|
||||||
def copy(src, *dests)
|
def copy(src, *dests)
|
||||||
@@ -234,19 +234,12 @@ end
|
|||||||
#===============================================================================
|
#===============================================================================
|
||||||
class HandlerHashBasic
|
class HandlerHashBasic
|
||||||
def initialize
|
def initialize
|
||||||
@hash = {}
|
@hash = {}
|
||||||
@addIfs = []
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def [](entry)
|
def [](entry)
|
||||||
ret = nil
|
return @hash[entry] if entry && @hash[entry]
|
||||||
ret = @hash[entry] if entry && @hash[entry]
|
return nil
|
||||||
unless ret
|
|
||||||
@addIfs.each do |addif|
|
|
||||||
return addif[1] if addif[0].call(entry)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return ret
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def add(entry, handler = nil, &handlerBlock)
|
def add(entry, handler = nil, &handlerBlock)
|
||||||
@@ -257,13 +250,6 @@ class HandlerHashBasic
|
|||||||
@hash[entry] = handler || handlerBlock
|
@hash[entry] = handler || handlerBlock
|
||||||
end
|
end
|
||||||
|
|
||||||
def addIf(conditionProc, handler = nil, &handlerBlock)
|
|
||||||
if ![Proc, Hash].include?(handler.class) && !block_given?
|
|
||||||
raise ArgumentError, "addIf call for #{self.class.name} has no valid handler (#{handler.inspect} was given)"
|
|
||||||
end
|
|
||||||
@addIfs.push([conditionProc, handler || handlerBlock])
|
|
||||||
end
|
|
||||||
|
|
||||||
def copy(src, *dests)
|
def copy(src, *dests)
|
||||||
handler = self[src]
|
handler = self[src]
|
||||||
return if !handler
|
return if !handler
|
||||||
|
|||||||
@@ -160,17 +160,19 @@ class Battle::Battler
|
|||||||
# Start using the move
|
# Start using the move
|
||||||
pbBeginTurn(choice)
|
pbBeginTurn(choice)
|
||||||
# Force the use of certain moves if they're already being used
|
# Force the use of certain moves if they're already being used
|
||||||
if usingMultiTurnAttack?
|
if !@battle.futureSight
|
||||||
choice[2] = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(@currentMove))
|
if usingMultiTurnAttack?
|
||||||
specialUsage = true
|
choice[2] = Battle::Move.from_pokemon_move(@battle, Pokemon::Move.new(@currentMove))
|
||||||
elsif @effects[PBEffects::Encore] > 0 && choice[1] >= 0 &&
|
specialUsage = true
|
||||||
@battle.pbCanShowCommands?(@index)
|
elsif @effects[PBEffects::Encore] > 0 && choice[1] >= 0 &&
|
||||||
idxEncoredMove = pbEncoredMoveIndex
|
@battle.pbCanShowCommands?(@index)
|
||||||
if idxEncoredMove >= 0 && choice[1] != idxEncoredMove &&
|
idxEncoredMove = pbEncoredMoveIndex
|
||||||
@battle.pbCanChooseMove?(@index, idxEncoredMove, false) # Change move if battler was Encored mid-round
|
if idxEncoredMove >= 0 && choice[1] != idxEncoredMove &&
|
||||||
choice[1] = idxEncoredMove
|
@battle.pbCanChooseMove?(@index, idxEncoredMove, false) # Change move if battler was Encored mid-round
|
||||||
choice[2] = @moves[idxEncoredMove]
|
choice[1] = idxEncoredMove
|
||||||
choice[3] = -1 # No target chosen
|
choice[2] = @moves[idxEncoredMove]
|
||||||
|
choice[3] = -1 # No target chosen
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Labels the move being used as "move"
|
# Labels the move being used as "move"
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ class DayCare
|
|||||||
def inherit_IVs(egg, mother, father)
|
def inherit_IVs(egg, mother, father)
|
||||||
# Get all stats
|
# Get all stats
|
||||||
stats = []
|
stats = []
|
||||||
GameData::Stat.each_main { |s| stats.push(s) }
|
GameData::Stat.each_main { |s| stats.push(s.id) }
|
||||||
# Get the number of stats to inherit
|
# Get the number of stats to inherit
|
||||||
inherit_count = 3
|
inherit_count = 3
|
||||||
if Settings::MECHANICS_GENERATION >= 6
|
if Settings::MECHANICS_GENERATION >= 6
|
||||||
|
|||||||
@@ -64,7 +64,8 @@ ItemHandlers::UseFromBag.add(:TOWNMAP, proc { |item|
|
|||||||
next ($game_temp.fly_destination) ? 2 : 0
|
next ($game_temp.fly_destination) ? 2 : 0
|
||||||
})
|
})
|
||||||
|
|
||||||
ItemHandlers::UseFromBag.addIf(proc { |item| GameData::Item.get(item).is_machine? },
|
ItemHandlers::UseFromBag.addIf(:move_machines,
|
||||||
|
proc { |item| GameData::Item.get(item).is_machine? },
|
||||||
proc { |item|
|
proc { |item|
|
||||||
if $player.pokemon_count == 0
|
if $player.pokemon_count == 0
|
||||||
pbMessage(_INTL("There is no Pokémon."))
|
pbMessage(_INTL("There is no Pokémon."))
|
||||||
@@ -361,7 +362,8 @@ ItemHandlers::UseInField.add(:EXPALLOFF, proc { |item|
|
|||||||
|
|
||||||
# Applies to all items defined as an evolution stone.
|
# Applies to all items defined as an evolution stone.
|
||||||
# No need to add more code for new ones.
|
# No need to add more code for new ones.
|
||||||
ItemHandlers::UseOnPokemon.addIf(proc { |item| GameData::Item.get(item).is_evolution_stone? },
|
ItemHandlers::UseOnPokemon.addIf(:evolution_stones,
|
||||||
|
proc { |item| GameData::Item.get(item).is_evolution_stone? },
|
||||||
proc { |item, qty, pkmn, scene|
|
proc { |item, qty, pkmn, scene|
|
||||||
if pkmn.shadowPokemon?
|
if pkmn.shadowPokemon?
|
||||||
scene.pbDisplay(_INTL("It won't have any effect."))
|
scene.pbDisplay(_INTL("It won't have any effect."))
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ ItemHandlers::CanUseInBattle.add(:POKEDOLL, proc { |item, pokemon, battler, move
|
|||||||
|
|
||||||
ItemHandlers::CanUseInBattle.copy(:POKEDOLL, :FLUFFYTAIL, :POKETOY)
|
ItemHandlers::CanUseInBattle.copy(:POKEDOLL, :FLUFFYTAIL, :POKETOY)
|
||||||
|
|
||||||
ItemHandlers::CanUseInBattle.addIf(proc { |item| GameData::Item.get(item).is_poke_ball? }, # Poké Balls
|
ItemHandlers::CanUseInBattle.addIf(:poke_balls,
|
||||||
|
proc { |item| GameData::Item.get(item).is_poke_ball? },
|
||||||
proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages|
|
proc { |item, pokemon, battler, move, firstAction, battle, scene, showMessages|
|
||||||
if battle.pbPlayer.party_full? && $PokemonStorage.full?
|
if battle.pbPlayer.party_full? && $PokemonStorage.full?
|
||||||
scene.pbDisplay(_INTL("There is no room left in the PC!")) if showMessages
|
scene.pbDisplay(_INTL("There is no room left in the PC!")) if showMessages
|
||||||
@@ -314,7 +315,8 @@ ItemHandlers::UseInBattle.add(:POKEFLUTE, proc { |item, battler, battle|
|
|||||||
battle.pbDisplay(_INTL("All Pokémon were roused by the tune!"))
|
battle.pbDisplay(_INTL("All Pokémon were roused by the tune!"))
|
||||||
})
|
})
|
||||||
|
|
||||||
ItemHandlers::UseInBattle.addIf(proc { |item| GameData::Item.get(item).is_poke_ball? }, # Poké Balls
|
ItemHandlers::UseInBattle.addIf(:poke_balls,
|
||||||
|
proc { |item| GameData::Item.get(item).is_poke_ball? },
|
||||||
proc { |item, battler, battle|
|
proc { |item, battler, battle|
|
||||||
battle.pbThrowPokeBall(battler.index, item)
|
battle.pbThrowPokeBall(battler.index, item)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ module MultipleForms
|
|||||||
@@formSpecies.add(sym, hash)
|
@@formSpecies.add(sym, hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.registerIf(cond, hash)
|
def self.registerIf(sym, cond, hash)
|
||||||
@@formSpecies.addIf(cond, hash)
|
@@formSpecies.addIf(sym, cond, hash)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.hasFunction?(pkmn, func)
|
def self.hasFunction?(pkmn, func)
|
||||||
|
|||||||
Reference in New Issue
Block a user