Class: Gamefic::Active::Narratives

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/gamefic/active/narratives.rb

Overview

A narrative container for active entities.

Instance Method Summary collapse

Instance Method Details

#add(narrative) ⇒ self

Parameters:

Returns:

  • (self)


12
13
14
15
# File 'lib/gamefic/active/narratives.rb', line 12

def add(narrative)
  narrative_set.add(narrative)
  self
end

#after_commandsArray<Binding>

Returns:



65
66
67
# File 'lib/gamefic/active/narratives.rb', line 65

def after_commands
  narrative_set.flat_map(&:after_commands)
end

#before_commandsArray<Binding>

Returns:



60
61
62
# File 'lib/gamefic/active/narratives.rb', line 60

def before_commands
  narrative_set.flat_map(&:before_commands)
end

#delete(narrative) ⇒ self

Parameters:

Returns:

  • (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

Returns:

  • (Boolean)


24
25
26
# File 'lib/gamefic/active/narratives.rb', line 24

def empty?
  narrative_set.empty?
end

#entitiesArray<Entity>

Returns:



86
87
88
# File 'lib/gamefic/active/narratives.rb', line 86

def entities
  narrative_set.flat_map(&:entities)
end

#lengthInteger

Returns:

  • (Integer)


29
30
31
# File 'lib/gamefic/active/narratives.rb', line 29

def length
  narrative_set.length
end

#one?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/gamefic/active/narratives.rb', line 33

def one?
  narrative_set.one?
end

#player_output_blocksArray<Binding>

Returns:



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

#responsesArray<Response>

Returns:



38
39
40
# File 'lib/gamefic/active/narratives.rb', line 38

def responses
  narrative_set.flat_map(&:responses)
end

#responses_for(*verbs) ⇒ Array<Response>

Returns:



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

#syntaxesArray<Syntax>

Returns:



48
49
50
# File 'lib/gamefic/active/narratives.rb', line 48

def syntaxes
  narrative_set.flat_map(&:syntaxes)
end

#that_are(*args) ⇒ Array<Narrative>

Returns:



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>

Returns:



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.

Parameters:

Returns:

  • (Boolean)


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