Module: Gamefic::Plot::Host

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

Overview

Methods for hosting and managing subplots.

Instance Method Summary collapse

Instance Method Details

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

Start a new subplot based on the provided class.

Parameters:

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

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

Returns:



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

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

#in_subplot?(player) ⇒ Boolean

Determine whether the player is involved in a subplot.

Returns:

  • (Boolean)


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

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

#subplotsArray<Subplot>

Get an array of all the current subplots.

Returns:



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

def subplots
  @subplots ||= []
end

#subplots_featuring(player) ⇒ Array<Subplot>

Get the player’s current subplots.

Returns:



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

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