class Gamefic::Plot
The plot is the central narrative. It provides a script interface with methods for creating entities, actions, scenes, and hooks.
Attributes
@return [Array<Chapter>]
Public Class Methods
Source
# File lib/gamefic/plot.rb, line 43 def self.append(chapter, **config) Gamefic.logger.warn "Overwriting existing chapter #{chapter}" if appended_chapter_map.key?(chapter) appended_chapter_map[chapter] = config end
Source
# File lib/gamefic/plot.rb, line 49 def self.appended_chapter_map @appended_chapter_map ||= {} end
Source
# File lib/gamefic/plot.rb, line 11 def initialize super @chapters = self.class.appended_chapter_map.map { |chap, config| chap.new(self, **unproxy(config)) } end
Calls superclass method
Gamefic::Narrative::new
Public Instance Methods
Source
# File lib/gamefic/plot.rb, line 34 def branch subplot_class = Gamefic::Subplot, introduce: [], **config subplot_class.new(self, introduce: introduce, **config) .tap { |sub| subplots.push sub } end
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]
Source
# File lib/gamefic/plot.rb, line 90 def find_and_bind(symbol) super + chapters.flat_map { |chap| chap.find_and_bind(symbol) } end
Calls superclass method
Gamefic::Scripting#find_and_bind
Source
# File lib/gamefic/plot.rb, line 74 def player_output_blocks super + subplots.flat_map(&:player_output_blocks) end
Calls superclass method
Source
# File lib/gamefic/plot.rb, line 66 def ready_blocks super + subplots.flat_map(&:ready_blocks) end
Calls superclass method
Source
# File lib/gamefic/plot.rb, line 78 def responses super + chapters.flat_map(&:responses) end
Calls superclass method
Source
# File lib/gamefic/plot.rb, line 82 def responses_for(*verbs) super + chapters.flat_map { |chap| chap.responses_for(*verbs) } end
Calls superclass method
Source
# File lib/gamefic/plot.rb, line 24 def subplots @subplots ||= [] end
Get an array of all the current subplots.
@return [Array<Subplot>]
Source
# File lib/gamefic/plot.rb, line 86 def syntaxes super + chapters.flat_map(&:syntaxes) end
Calls superclass method
Source
# File lib/gamefic/plot.rb, line 59 def turn super subplots.each(&:conclude) if concluding? chapters.delete_if(&:concluding?) subplots.delete_if(&:concluding?) end
Complete a game turn.
In addition to running its own applicable conclude blocks, the Plot
class will also handle conclude blocks for its chapters and subplots.
@return [void]
Calls superclass method
Gamefic::Narrative#turn
Source
# File lib/gamefic/plot.rb, line 16 def uncast(actor) subplots.each { |sp| sp.uncast actor } super end
Calls superclass method
Gamefic::Narrative#uncast
Source
# File lib/gamefic/plot.rb, line 70 def update_blocks super + subplots.flat_map(&:update_blocks) end
Calls superclass method