Class: Gamefic::Dispatcher
- Inherits:
-
Object
- Object
- Gamefic::Dispatcher
- Defined in:
- lib/gamefic/dispatcher.rb
Overview
The action executor for character commands.
Instance Method Summary collapse
-
#execute ⇒ Command?
Start executing actions in the dispatcher.
-
#initialize(actionable) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
-
#proceed ⇒ Action?
Execute the next available action.
Constructor Details
#initialize(actionable) ⇒ Dispatcher
Returns a new instance of Dispatcher.
8 9 10 |
# File 'lib/gamefic/dispatcher.rb', line 8 def initialize(actionable) @actions = actionable.to_actions end |
Instance Method Details
#execute ⇒ Command?
Start executing actions in the dispatcher.
15 16 17 18 19 20 21 22 |
# File 'lib/gamefic/dispatcher.rb', line 15 def execute return if action || actions.empty? @action = actions.shift Gamefic.logger.info "Dispatching #{actor.inspect} #{command.inspect}" run_hooks_and_response command end |
#proceed ⇒ Action?
Execute the next available action.
Actors should run #execute first.
29 30 31 32 33 |
# File 'lib/gamefic/dispatcher.rb', line 29 def proceed return if !action || command.cancelled? actions.shift&.execute end |