Class: MonkeyEngine::Engine
- Inherits:
-
Object
- Object
- MonkeyEngine::Engine
- Includes:
- Observable, Singleton
- Defined in:
- lib/MonkeyEngine/monkey_engine.rb
Overview
Assigns, executes and evaluates actions.
Instance Method Summary collapse
-
#action_eval!(action) ⇒ Object
Evaluates whether or not the action is completed.
- #do_action(action) ⇒ Object
- #do_action_type(action) ⇒ Object
-
#new_action(monkey) ⇒ Object
Returns a new action.
Instance Method Details
#action_eval!(action) ⇒ Object
Evaluates whether or not the action is completed.
17 18 19 |
# File 'lib/MonkeyEngine/monkey_engine.rb', line 17 def action_eval!(action) ActionRules.instance.action_eval! action end |
#do_action(action) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/MonkeyEngine/monkey_engine.rb', line 21 def do_action(action) if action.action_completed? raise MonkeyEngine::Exceptions::InvalidOperationException, "The action [#{action.class.name}] for Monkey [#{action.monkey.monkey_symbol}] is already completed" end do_action_type(action) if action.is_a? MonkeyActionType # TODO: Update database for monkey with action detail # TODO: Call observer to notify of action update. # TODO: Set action.action_completed to true if the action is completed. action.action_completed? end |
#do_action_type(action) ⇒ Object
36 37 38 |
# File 'lib/MonkeyEngine/monkey_engine.rb', line 36 def do_action_type(action) action.action_completed = true end |
#new_action(monkey) ⇒ Object
Returns a new action.
41 42 43 44 45 46 47 48 |
# File 'lib/MonkeyEngine/monkey_engine.rb', line 41 def new_action(monkey) unless monkey.action.nil? || monkey.action.action_completed? raise MonkeyEngine::Exceptions::InvalidOperationException, "The action [#{monkey.action.class.name}] for Monkey [#{monkey.monkey_symbol}] must be completed before calling new_action" end ActionRules.instance.get_next_action monkey end |