class Gamefic::Plot
The plot is the central narrative. It provides a script interface with methods for creating entities, actions, scenes, and hooks.
Public Class Methods
append(chapter)
click to toggle source
# File lib/gamefic/plot.rb, line 98 def self.append chapter appended_chapters.add chapter end
appended_chapters()
click to toggle source
# File lib/gamefic/plot.rb, line 102 def self.appended_chapters @appended_chapters ||= Set.new end
restore(data)
click to toggle source
# File lib/gamefic/plot.rb, line 106 def self.restore data Snapshot.restore data end
Public Instance Methods
attach(cache)
click to toggle source
Calls superclass method
Gamefic::Narrative#attach
# File lib/gamefic/plot.rb, line 88 def attach(cache) super(cache.shift) subplots.each { |subplot| subplot.attach cache.shift } end
branch(subplot_class = Gamefic::Subplot, introduce: [], **config)
click to toggle source
Start a new subplot based on the provided class.
@param subplot_class [Class<Gamefic::Subplot>] The Subplot
class @param introduce [Gamefic::Actor, Array
<Gamefic::Actor>] Players to introduce @param config [Hash] Subplot
configuration @return [Gamefic::Subplot]
# File lib/gamefic/plot.rb, line 68 def branch subplot_class = Gamefic::Subplot, introduce: [], **config subplot_class.new(self, introduce: introduce, **config) .tap { |sub| subplots.push sub } end
chapters()
click to toggle source
# File lib/gamefic/plot.rb, line 24 def chapters @chapters ||= self.class.appended_chapters.map { |klass| klass.new(self) } end
detach()
click to toggle source
# File lib/gamefic/plot.rb, line 81 def detach cache = [@rulebook] @rulebook = nil cache.concat subplots.map(&:detach) cache end
hydrate()
click to toggle source
Calls superclass method
Gamefic::Narrative#hydrate
# File lib/gamefic/plot.rb, line 93 def hydrate super subplots.each(&:hydrate) end
inspect()
click to toggle source
# File lib/gamefic/plot.rb, line 77 def inspect "#<#{self.class}>" end
post_script()
click to toggle source
Calls superclass method
Gamefic::Narrative#post_script
# File lib/gamefic/plot.rb, line 19 def post_script super chapters.freeze end
ready()
click to toggle source
Calls superclass method
Gamefic::Narrative#ready
# File lib/gamefic/plot.rb, line 28 def ready super subplots.each(&:ready) players.each(&:start_take) subplots.each(&:conclude) if concluding? players.select(&:concluding?).each { |plyr| rulebook.run_player_conclude_blocks plyr } subplots.delete_if(&:concluding?) end
save()
click to toggle source
# File lib/gamefic/plot.rb, line 73 def save Snapshot.save self end
script()
click to toggle source
Calls superclass method
Gamefic::Narrative#script
# File lib/gamefic/plot.rb, line 13 def script super chapters.each(&:script) rulebook.scenes.with_defaults self end
seed()
click to toggle source
Calls superclass method
Gamefic::Narrative#seed
# File lib/gamefic/plot.rb, line 8 def seed super chapters.each(&:seed) end
subplots()
click to toggle source
Get an array of all the current subplots.
@return [Array<Subplot>]
# File lib/gamefic/plot.rb, line 58 def subplots @subplots ||= [] end
uncast(actor)
click to toggle source
Remove an actor from the game.
Calling ‘uncast` on the plot will also remove the actor from its subplots.
@param actor [Actor] @return [Actor]
Calls superclass method
Gamefic::Narrative#uncast
# File lib/gamefic/plot.rb, line 50 def uncast actor subplots.each { |sp| sp.uncast actor } super end
update()
click to toggle source
Calls superclass method
Gamefic::Narrative#update
# File lib/gamefic/plot.rb, line 37 def update players.each(&:finish_take) super subplots.each(&:update) end