Class: Battle::Logic::SwitchHandler

Inherits:
ChangeHandlerBase show all
Includes:
Hooks
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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Hooks

#exec_hooks, #force_return, included, register, remove, remove_without_name

Methods inherited from ChangeHandlerBase

#initialize, #prevent_change, #process_prevention_reason, #reset_prevention_reason

Constructor Details

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

Class Method Details

.register_pre_switch_event_hook(reason) {|handler, who, with| ... }

Register a pre switch event

Parameters:

  • reason (String)

    reason of the pre_switch_event hook

Yield Parameters:



1298
1299
# File 'docs/5_Battle_04_Logic.rb', line 1298

def register_pre_switch_event_hook(reason)
end

.register_switch_event_hook(reason) {|handler, who, with| ... }

Register a switch event

Parameters:

  • reason (String)

    reason of the switch_event hook

Yield Parameters:



1305
1306
# File 'docs/5_Battle_04_Logic.rb', line 1305

def register_switch_event_hook(reason)
end

.register_switch_passthrough_hook(reason) {|handler, pokemon, skill, reason| ... }

Register a switch passthrough. If the block returns :passthrough, it will say that Pokemon can switch in can_switch?

Parameters:

  • reason (String)

    reason of the switch_passthrough hook

Yield Parameters:

Yield Returns:

  • (:passthrough, nil)

    if :passthrough, can_switch? will return true without checking switch_prevention



1282
1283
# File 'docs/5_Battle_04_Logic.rb', line 1282

def register_switch_passthrough_hook(reason)
end

.register_switch_prevention_hook(reason) {|handler, pokemon, skill, reason| ... }

Register a switch prevention hook. If the block returns :prevent, it will say that Pokemon cannot switch in can_switch?

Parameters:

  • reason (String)

    reason of the switch_prevention hook

Yield Parameters:

Yield Returns:

  • (:prevent, nil)

    if :prevent, can_switch? will return false



1291
1292
# File 'docs/5_Battle_04_Logic.rb', line 1291

def register_switch_prevention_hook(reason)
end

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



1260
1261
# File 'docs/5_Battle_04_Logic.rb', line 1260

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:



1266
1267
# File 'docs/5_Battle_04_Logic.rb', line 1266

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:



1272
1273
# File 'docs/5_Battle_04_Logic.rb', line 1272

def execute_switch_events(who, with)
end