Class: Oakdex::Pokemon::GrowthEvents::LevelUp

Inherits:
Base
  • Object
show all
Defined in:
lib/oakdex/pokemon/growth_events/level_up.rb

Overview

When pokemon reached the next level

Instance Method Summary collapse

Methods inherited from Base

#initialize, #possible_actions, #read_only?, #to_h

Constructor Details

This class inherits a constructor from Oakdex::Pokemon::GrowthEvents::Base

Instance Method Details

#executeObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/oakdex/pokemon/growth_events/level_up.rb', line 11

def execute
  last_evt = self
  available_moves.each do |move_id|
    last_evt = @pokemon.add_growth_event(GrowthEvents::LearnMove,
                                         move_id: move_id,
                                         after: last_evt)
  end
  if available_evolution
    @pokemon.add_growth_event(GrowthEvents::Evolution,
                              evolution: available_evolution,
                              after: last_evt)
  end
  remove_event
end

#messageObject



7
8
9
# File 'lib/oakdex/pokemon/growth_events/level_up.rb', line 7

def message
  "#{@pokemon.name} reached Level #{@options[:new_level]}."
end