Class: Battle::Logic::SwitchHandler

Inherits:
ChangeHandlerBase show all
Defined in:
docs/5_Battle_04_Logic.rb

Overview

Handler responsive of processing switch events that happens during switch

Instance Attribute Summary

Attributes inherited from ChangeHandlerBase

#logic, #pre_checked_effects, #scene

Instance Method Summary collapse

Methods inherited from ChangeHandlerBase

#initialize, #pass_change, #prevent_change, #process_reason, #reset_reason

Constructor Details

This class inherits a constructor from Battle::Logic::ChangeHandlerBase

Instance Method Details

#can_switch?(pokemon, skill = nil, reason: :switch) ⇒ Boolean

Test if the switch is possible

Parameters:

  • pokemon (PFM::PokemonBattler) —

    pokemon to switch

  • skill (Battle::Move, nil) (defaults to: nil) —

    potential move

  • reason (Symbol) (defaults to: :switch) —

    the reason why the SwitchHandler is called (:switch or :flee)

Returns:

  • (Boolean) —

    if it can switch or not



1182
1183
# File 'docs/5_Battle_04_Logic.rb', line 1182

def can_switch?(pokemon, skill = nil, reason: :switch)
end

#execute_pre_switch_events(who, with)

Note:

In the event we're starting the battle who & with should be identic, this help to process effect like Intimidate

Execute the events before the pokemon switch out

Parameters:



1188
1189
# File 'docs/5_Battle_04_Logic.rb', line 1188

def execute_pre_switch_events(who, with)
end

#execute_switch_events(who, with)

Note:

In the event we're starting the battle who & with should be identic, this help to process effect like Intimidate

Perform the switch between two Pokemon

Parameters:



1194
1195
# File 'docs/5_Battle_04_Logic.rb', line 1194

def execute_switch_events(who, with)
end