Module: Gamefic::Plot::Host

Defined in:
lib/gamefic/plot/host.rb

Instance Method Summary collapse

Instance Method Details

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

Start a new subplot based on the provided class.

Parameters:

  • The (Class)

    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
  subplot = subplot_class.new(self, introduce: introduce)
  p_subplots.push subplot
  subplot
end

#subbed?(player) ⇒ Boolean

Determine whether the player is involved in a subplot.

Returns:

  • (Boolean)


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

def subbed? player
  !subplot_for(player).nil?
end

#subplot_for(player) ⇒ Subplot

Get the player’s current subplot or nil if none exists.

Returns:



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

def subplot_for player
  subplots.each { |s|
    return s if s.players.include?(player)
  }
  nil
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