module Gamefic::Plot::Host

Methods for hosting and managing subplots.

Public Instance Methods

branch(subplot_class = Gamefic::Subplot, introduce: nil, next_cue: nil, **more) click to toggle source

Start a new subplot based on the provided class.

@param subplot_class [Class<Gamefic::Subplot>] The class of the subplot to be created (Subplot by default) @return [Gamefic::Subplot]

# 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) click to toggle source

Determine whether the player is involved in a subplot.

@return [Boolean]

# File lib/gamefic/plot/host.rb, line 38
def in_subplot? player
  !subplots_featuring(player).empty?
end
subplots() click to toggle source

Get an array of all the current subplots.

@return [Array<Subplot>]

# File lib/gamefic/plot/host.rb, line 10
def subplots
  @subplots ||= []
end
subplots_featuring(player) click to toggle source

Get the player's current subplots.

@return [Array<Subplot>]

# 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