Class: Oakdex::Pokemon::GrowthEvents::LearnMove
- Defined in:
- lib/oakdex/pokemon/growth_events/learn_move.rb
Overview
When pokemon could learn move
Instance Method Summary collapse
Methods inherited from Base
#initialize, #read_only?, #to_h
Constructor Details
This class inherits a constructor from Oakdex::Pokemon::GrowthEvents::Base
Instance Method Details
#execute(action = nil) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/oakdex/pokemon/growth_events/learn_move.rb', line 20 def execute(action = nil) if move_slot_left? @pokemon.learn_new_move(@options[:move_id]) if available_evolution @pokemon.add_growth_event(GrowthEvents::Evolution, evolution: available_evolution, after: self) end else if action == not_learn_action @pokemon.add_growth_event(GrowthEvents::DidNotLearnMove, move_id: @options[:move_id], after: self) else move_id = unlearn_moves[action] @pokemon.learn_new_move(@options[:move_id], move_id) @pokemon.add_growth_event(GrowthEvents::ForgotAndLearnedMove, move_id: @options[:move_id], forgot_move_id: move_id, after: self) end end remove_event end |
#message ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/oakdex/pokemon/growth_events/learn_move.rb', line 7 def if move_slot_left? "#{@pokemon.name} learned #{@options[:move_id]}." else "#{@pokemon.name} wants to learn #{@options[:move_id]} but has already 4 moves." end end |
#possible_actions ⇒ Object
15 16 17 18 |
# File 'lib/oakdex/pokemon/growth_events/learn_move.rb', line 15 def possible_actions return [] if move_slot_left? [not_learn_action] + unlearn_moves.keys end |