class Gamefic::Subplot

Attributes

plot[R]

@return [Gamefic::Plot]

Public Class Methods

new(plot, introduce: nil, next_cue: nil, **more) click to toggle source

@param plot [Gamefic::Plot] @param introduce [Gamefic::Actor, nil] @param next_cue [Class<Gamefic::Scene::Base>, nil] @param more [Hash]

# File lib/gamefic/subplot.rb, line 17
def initialize plot, introduce: nil, next_cue: nil, **more
  @plot = plot
  @next_cue = next_cue
  @concluded = false
  @more = more
  configure more
  run_scripts
  playbook.freeze
  self.introduce introduce unless introduce.nil?
  @static = [self] + scene_classes + entities
end

Public Instance Methods

cast(cls, args = {}) click to toggle source
Calls superclass method
# File lib/gamefic/subplot.rb, line 53
def cast cls, args = {}, &block
  ent = super
  ent.playbooks.push plot.playbook unless ent.playbooks.include?(plot.playbook)
  ent
end
conclude() click to toggle source
# File lib/gamefic/subplot.rb, line 66
def conclude
  @concluded = true
  # Players needed to exit first in case any player_conclude procs need to
  # interact with the subplot's entities.
  players.each { |p| exeunt p }
  # @todo I'm not sure why rejecting nils is necessary here. It's only an
  #   issue in Opal.
  entities.reject(&:nil?).each { |e| destroy e }
  # plot.static.remove(scene_classes + entities)
end
concluded?() click to toggle source
# File lib/gamefic/subplot.rb, line 77
def concluded?
  @concluded
end
configure(more) click to toggle source

Subclasses can override this method to handle additional configuration options.

# File lib/gamefic/subplot.rb, line 100
def configure more
end
default_conclusion() click to toggle source
# File lib/gamefic/subplot.rb, line 45
def default_conclusion
  plot.default_conclusion
end
default_scene() click to toggle source
# File lib/gamefic/subplot.rb, line 41
def default_scene
  plot.default_scene
end
exeunt(player) click to toggle source
# File lib/gamefic/subplot.rb, line 59
def exeunt player
  player_conclude_procs.each { |block| block.call player }
  player.playbooks.delete playbook
  player.cue (@next_cue || default_scene)
  players.delete player
end
playbook() click to toggle source
# File lib/gamefic/subplot.rb, line 49
def playbook
  @playbook ||= Gamefic::Plot::Playbook.new
end
players() click to toggle source
# File lib/gamefic/subplot.rb, line 33
def players
  @players ||= []
end
ready() click to toggle source
# File lib/gamefic/subplot.rb, line 81
def ready
  # @todo We might not want to conclude subplots without players. There
  #   might be cases where a subplot gets created with the intention of
  #   introducing players in a later turn.
  conclude if players.empty?
  return if concluded?
  playbook.freeze
  call_ready
  call_player_ready
end
static() click to toggle source
# File lib/gamefic/subplot.rb, line 29
def static
  plot.static
end
subplot() click to toggle source
# File lib/gamefic/subplot.rb, line 37
def subplot
  self
end
update() click to toggle source
# File lib/gamefic/subplot.rb, line 92
def update
  call_player_update
  call_update
end