Module: Gamefic::Scripting::Responses

Included in:
Gamefic::Scripting
Defined in:
lib/gamefic/scripting/responses.rb

Instance Method Summary collapse

Instance Method Details

#responsesArray<Response>

Returns:



5
6
7
8
# File 'lib/gamefic/scripting/responses.rb', line 5

def responses
  included_scripts.flat_map(&:responses)
                  .map { |response| response.bind(self) }
end

#responses_for(*verbs) ⇒ Array<Response>

Returns:



11
12
13
14
15
16
17
18
# File 'lib/gamefic/scripting/responses.rb', line 11

def responses_for *verbs
  # @todo This double reversal is odd, but Gamefic::Standard fails in

  #   Opal without it.

  included_scripts.reverse
                  .flat_map { |script| script.responses_for(*verbs) }
                  .reverse
                  .map { |response| response.bind(self) }
end