Class: Gamefic::Active::Narratives
- Inherits:
-
Object
- Object
- Gamefic::Active::Narratives
- Includes:
- Enumerable
- Defined in:
- lib/gamefic/active/narratives.rb
Overview
A narrative container for active entities.
Instance Method Summary collapse
- #add(narrative) ⇒ self
- #after_commands ⇒ Array<Binding>
- #before_commands ⇒ Array<Binding>
- #delete(narrative) ⇒ self
-
#each(&block) ⇒ Object
@sg-ignore Type checker has trouble reconciling return type of ‘Set#each` with unresolved `generic<R>` of `Enumerable#each`.
- #empty? ⇒ Boolean
- #entities ⇒ Array<Entity>
- #length ⇒ Integer
- #one? ⇒ Boolean
- #player_output_blocks ⇒ Array<Binding>
- #responses ⇒ Array<Response>
- #responses_for(*verbs) ⇒ Array<Response>
- #syntaxes ⇒ Array<Syntax>
- #that_are(*args) ⇒ Array<Narrative>
- #that_are_not(*args) ⇒ Array<Narrative>
-
#understand?(verb) ⇒ Boolean
True if the specified verb is understood by any of the narratives.
Instance Method Details
#add(narrative) ⇒ self
12 13 14 15 |
# File 'lib/gamefic/active/narratives.rb', line 12 def add(narrative) narrative_set.add(narrative) self end |
#after_commands ⇒ Array<Binding>
65 66 67 |
# File 'lib/gamefic/active/narratives.rb', line 65 def after_commands narrative_set.flat_map(&:after_commands) end |
#before_commands ⇒ Array<Binding>
60 61 62 |
# File 'lib/gamefic/active/narratives.rb', line 60 def before_commands narrative_set.flat_map(&:before_commands) end |
#delete(narrative) ⇒ self
19 20 21 22 |
# File 'lib/gamefic/active/narratives.rb', line 19 def delete(narrative) narrative_set.delete(narrative) self end |
#each(&block) ⇒ Object
@sg-ignore Type checker has trouble reconciling return type of ‘Set#each`
with unresolved `generic<R>` of `Enumerable#each`
71 72 73 |
# File 'lib/gamefic/active/narratives.rb', line 71 def each(&block) narrative_set.each(&block) end |
#empty? ⇒ Boolean
24 25 26 |
# File 'lib/gamefic/active/narratives.rb', line 24 def empty? narrative_set.empty? end |
#entities ⇒ Array<Entity>
86 87 88 |
# File 'lib/gamefic/active/narratives.rb', line 86 def entities narrative_set.flat_map(&:entities) end |
#length ⇒ Integer
29 30 31 |
# File 'lib/gamefic/active/narratives.rb', line 29 def length narrative_set.length end |
#one? ⇒ Boolean
33 34 35 |
# File 'lib/gamefic/active/narratives.rb', line 33 def one? narrative_set.one? end |
#player_output_blocks ⇒ Array<Binding>
91 92 93 |
# File 'lib/gamefic/active/narratives.rb', line 91 def player_output_blocks narrative_set.flat_map(&:player_output_blocks).uniq(&:code) end |
#responses ⇒ Array<Response>
38 39 40 |
# File 'lib/gamefic/active/narratives.rb', line 38 def responses narrative_set.flat_map(&:responses) end |
#responses_for(*verbs) ⇒ Array<Response>
43 44 45 |
# File 'lib/gamefic/active/narratives.rb', line 43 def responses_for(*verbs) narrative_set.flat_map { |narr| narr.responses_for(*verbs) } end |
#syntaxes ⇒ Array<Syntax>
48 49 50 |
# File 'lib/gamefic/active/narratives.rb', line 48 def syntaxes narrative_set.flat_map(&:syntaxes) end |
#that_are(*args) ⇒ Array<Narrative>
76 77 78 |
# File 'lib/gamefic/active/narratives.rb', line 76 def that_are(*args) narrative_set.to_a.that_are(*args) end |
#that_are_not(*args) ⇒ Array<Narrative>
81 82 83 |
# File 'lib/gamefic/active/narratives.rb', line 81 def that_are_not(*args) narrative_set.to_a.that_are_not(*args) end |
#understand?(verb) ⇒ Boolean
True if the specified verb is understood by any of the narratives.
55 56 57 |
# File 'lib/gamefic/active/narratives.rb', line 55 def understand?(verb) verb ? narrative_set.flat_map(&:synonyms).include?(verb.to_sym) : false end |