class Gamefic::Active::Narratives
A narrative container for active entities.
Public Instance Methods
Source
# File lib/gamefic/active/narratives.rb, line 12 def add(narrative) narrative_set.add(narrative) self end
@param narrative [Narrative] @return [self]
Source
# File lib/gamefic/active/narratives.rb, line 65 def after_commands narrative_set.flat_map(&:after_commands) end
@return [Array<Binding>]
Source
# File lib/gamefic/active/narratives.rb, line 60 def before_commands narrative_set.flat_map(&:before_commands) end
@return [Array<Binding>]
Source
# File lib/gamefic/active/narratives.rb, line 19 def delete(narrative) narrative_set.delete(narrative) self end
@param narrative [Narrative] @return [self]
Source
# File lib/gamefic/active/narratives.rb, line 71 def each(&block) narrative_set.each(&block) end
@sg-ignore Type checker has trouble reconciling return type of ‘Set#each`
with unresolved `generic<R>` of `Enumerable#each`
Source
# File lib/gamefic/active/narratives.rb, line 24 def empty? narrative_set.empty? end
Source
# File lib/gamefic/active/narratives.rb, line 86 def entities narrative_set.flat_map(&:entities) end
@return [Array<Entity>]
Source
# File lib/gamefic/active/narratives.rb, line 29 def length narrative_set.length end
@return [Integer]
Source
# File lib/gamefic/active/narratives.rb, line 91 def player_output_blocks narrative_set.flat_map(&:player_output_blocks).uniq(&:code) end
@return [Array<Binding>]
Source
# File lib/gamefic/active/narratives.rb, line 38 def responses narrative_set.flat_map(&:responses) end
@return [Array<Response>]
Source
# File lib/gamefic/active/narratives.rb, line 43 def responses_for(*verbs) narrative_set.flat_map { |narr| narr.responses_for(*verbs) } end
@return [Array<Response>]
Source
# File lib/gamefic/active/narratives.rb, line 48 def syntaxes narrative_set.flat_map(&:syntaxes) end
@return [Array<Syntax>]
Source
# File lib/gamefic/active/narratives.rb, line 76 def that_are(*args) narrative_set.to_a.that_are(*args) end
@return [Array<Narrative>]
Source
# File lib/gamefic/active/narratives.rb, line 81 def that_are_not(*args) narrative_set.to_a.that_are_not(*args) end
@return [Array<Narrative>]
Source
# File lib/gamefic/active/narratives.rb, line 55 def understand?(verb) verb ? narrative_set.flat_map(&:synonyms).include?(verb.to_sym) : false end
True if the specified verb is understood by any of the narratives.
@param verb [String, Symbol]
Private Instance Methods
Source
# File lib/gamefic/active/narratives.rb, line 98 def narrative_set @narrative_set ||= Set.new end
@return [Set<Narrative>]