Module: Gamefic::Plot::Host

Included in:
Gamefic::Plot
Defined in:
lib/gamefic/plot/host.rb

Instance Method Summary collapse

Instance Method Details

#branch(subplot_class = Gamefic::Subplot, introduce: nil, next_cue: nil) ⇒ Subplot

Start a new subplot based on the provided class.

Parameters:

  • subplot_class (Class) (defaults to: Gamefic::Subplot)

    The class of the subplot to be created (Subplot by default)

Returns:



17
18
19
20
21
# File 'lib/gamefic/plot/host.rb', line 17

def branch subplot_class = Gamefic::Subplot, introduce: nil, next_cue: nil
  subplot = subplot_class.new(self, introduce: introduce, next_cue: next_cue)
  p_subplots.push subplot
  subplot
end

#in_subplot?(player) ⇒ Boolean

Determine whether the player is involved in a subplot.

Returns:

  • (Boolean)


37
38
39
# File 'lib/gamefic/plot/host.rb', line 37

def in_subplot? player
  !subplots_featuring(player).empty?
end

#subplotsArray<Subplot>

Get an array of all the current subplots.

Returns:



9
10
11
# File 'lib/gamefic/plot/host.rb', line 9

def subplots
  p_subplots.clone
end

#subplots_featuring(player) ⇒ Array<Subplot>

Get the player’s current subplots.

Returns:



26
27
28
29
30
31
32
# File 'lib/gamefic/plot/host.rb', line 26

def subplots_featuring player
  result = []
  subplots.each { |s|
    result.push s if s.players.include?(player)
  }
  result
end