Class: Battle::Actions::Mega

Inherits:
Base show all
Defined in:
scripts/01600 Alpha 25 Battle Engine/03000 Actions/00003 Mega.rb

Overview

Class describing the Mega Evolution action

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#valid?

Constructor Details

#initialize(scene, user) ⇒ Mega

Create a new mega evolution action

Parameters:



11
12
13
14
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00003 Mega.rb', line 11

def initialize(scene, user)
  super(scene)
  @user = user
end

Instance Attribute Details

#userPFM::PokemonBattler (readonly)

Get the user of this action

Returns:



7
8
9
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00003 Mega.rb', line 7

def user
  @user
end

Instance Method Details

#<=>(other) ⇒ Integer

Compare this action with another

Parameters:

  • other (Base)

    other action

Returns:



19
20
21
22
23
24
25
26
27
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00003 Mega.rb', line 19

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 1 if other.is_a?(Switch)
  return Mega.from(other).user.spd <=> @user.spd if other.is_a?(Mega)

  return -1
end

#execute

Execute the action



30
31
32
33
34
35
36
37
# File 'scripts/01600 Alpha 25 Battle Engine/03000 Actions/00003 Mega.rb', line 30

def execute
  @scene.logic.mega_evolve.mark_as_mega_evolved(@user)
  @scene.display_message_and_wait(message)
  @user.mega_evolve
  @scene.visual.show_switch_form_animation(@user)
  @user.ability_effect.on_switch_event(@scene.logic.switch_handler, @user, @user)
  # TODO!
end