Class: Battle::Actions::Switch
- Defined in:
- scripts/01600 Alpha 25 Battle Engine/03000 Actions/00005 Switch.rb
Overview
Class describing the usage of switching out a Pokemon
Instance Attribute Summary collapse
-
#who ⇒ PFM::PokemonBattler
readonly
Get the Pokemon who's being switched.
-
#with ⇒ PFM::PokemonBattler
readonly
Get the Pokemon with the Pokemon is being switched.
Instance Method Summary collapse
-
#<=>(other) ⇒ Integer
Compare this action with another.
-
#execute
Execute the action.
-
#initialize(scene, who, with) ⇒ Switch
constructor
Create a new switch action.
Methods inherited from Base
Constructor Details
#initialize(scene, who, with) ⇒ Switch
Create a new switch action
15 16 17 18 19 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00005 Switch.rb', line 15 def initialize(scene, who, with) super(scene) @who = who @with = with end |
Instance Attribute Details
#who ⇒ PFM::PokemonBattler (readonly)
Get the Pokemon who's being switched
7 8 9 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00005 Switch.rb', line 7 def who @who end |
#with ⇒ PFM::PokemonBattler (readonly)
Get the Pokemon with the Pokemon is being switched
10 11 12 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00005 Switch.rb', line 10 def with @with end |
Instance Method Details
#<=>(other) ⇒ Integer
Compare this action with another
24 25 26 27 28 29 30 31 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00005 Switch.rb', line 24 def <=>(other) return 1 if other.is_a?(HighPriorityItem) return 1 if other.is_a?(Attack) && Attack.from(other).pursuit_enabled return 1 if other.is_a?(Item) return Switch.from(other).who.spd <=> @who.spd if other.is_a?(Switch) return -1 end |
#execute
Execute the action
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00005 Switch.rb', line 34 def execute return if !@who.position || !@who.position.between?(0, $game_temp.vs_type - 1) visual = @scene.visual # @type [BattleUI::PokemonSprite] sprite = visual.battler_sprite(@who.bank, @who.position) if @who.alive? sprite.go_out visual.(@who) unless forced_switch?(who) wait_for(sprite, visual) end # Logically switching the Pokemon @scene.logic.switch_battlers(@who, @with) # Switching the sprite sprite.pokemon = @with sprite.visible = false # Ensure there's no glitch with animation (the animation sets visible :)) sprite.go_in visual.(@with) unless forced_switch?(who) wait_for(sprite, visual) @scene.logic.switch_handler.execute_switch_events(@who, @with) @scene.logic.request_switch(@with, nil) if @with.dead? @who.reset_states end |