Class: Oakdex::Battle::ValidActionService

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/oakdex/battle/valid_action_service.rb

Overview

Generates all valid actions within the battle

Instance Method Summary collapse

Constructor Details

#initialize(battle) ⇒ ValidActionService



11
12
13
# File 'lib/oakdex/battle/valid_action_service.rb', line 11

def initialize(battle)
  @battle = battle
end

Instance Method Details

#valid_actions_for(trainer) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/oakdex/battle/valid_action_service.rb', line 15

def valid_actions_for(trainer)
  return [] if no_actions_for?(trainer)
  growth_events = growth_event_actions(trainer)
  return growth_events unless growth_events.empty?
  valid_move_actions_for(trainer) +
    valid_recall_actions_for(trainer) +
    valid_item_actions_for(trainer)
end