class Gamefic::Dispatcher
The action executor for character commands.
def actor
-
(Actor, nil)
-
def actor action.actor end
def command
-
(Command)
-
def command action.command end
def execute
-
(Command, nil)
-
def execute return if action || actions.empty? @action = actions.shift Gamefic.logger.info "Dispatching #{actor.inspect} #{command.inspect}" run_hooks_and_response command end
def initialize(actionable)
-
actionable
(#to_actions
) --
def initialize(actionable) @actions = actionable.to_actions end
def proceed
-
(Action, nil)
-
def proceed return if !action || command.cancelled? actions.shift&.execute end
def run_hooks(list)
def run_hooks(list) list.each do |blk| blk[actor, command] break if command.cancelled? end end
def run_hooks_and_response
def run_hooks_and_response run_hooks actor.narratives.before_commands command.freeze return if command.cancelled? action.execute run_hooks actor.narratives.after_commands end