Class: Gamefic::Order

Inherits:
Object
  • Object
show all
Defined in:
lib/gamefic/order.rb

Overview

Build actions from explicit verbs and arguments.

The Active#execute method uses Order to bypass the parser while generating actions to be executed in the Dispatcher.

Instance Method Summary collapse

Constructor Details

#initialize(actor, verb, arguments) ⇒ Order



13
14
15
16
17
# File 'lib/gamefic/order.rb', line 13

def initialize(actor, verb, arguments)
  @actor = actor
  @verb = verb
  @arguments = arguments
end

Instance Method Details

#to_actionsArray<Action>



20
21
22
23
24
25
26
27
# File 'lib/gamefic/order.rb', line 20

def to_actions
  Action.sort(
    actor.narratives
        .responses_for(verb)
        .map { |response| match_arguments(response) }
        .compact
  )
end