class Gamefic::Chapter
Chapters are plot extensions that manage their own namespaces. Authors can use them to encapsulate related content in a separate object instead of adding the required instance variables, methods, and attributes to the plot.
Chapters are similar to subplots with three important exceptions:
-
Chapters normally persist for the duration of a plot.
-
Players do not need to be introduced to a chapter.
-
Chapters share their plot’s entities, players, and rulebook.
@example
class MyChapter < Gamefic::Chapter def thing @thing ||= make Gamefic::Entity, name: 'chapter thing' end end class MyPlot < Gamefic::Plot append MyChapter end plot = MyPlot.new plot.entities #=> [<#Gamefic::Entity a chapter thing>] plot.thing # raises NoMethodError plot.chapters.first.thing #=> <#Gamefic::Entity a chapter thing>
Attributes
plot[R]
@return [Plot]
Public Class Methods
new(plot)
click to toggle source
@param plot [Plot]
Calls superclass method
# File lib/gamefic/chapter.rb, line 37 def initialize(plot) @plot = plot # The plot is responsible for hydrating chapters super(hydrate: false) end
Public Instance Methods
branch(...)
click to toggle source
# File lib/gamefic/chapter.rb, line 67 def branch(...) plot.branch(...) end
entity_vault()
click to toggle source
# File lib/gamefic/chapter.rb, line 55 def entity_vault plot.entity_vault end
included_blocks()
click to toggle source
# File lib/gamefic/chapter.rb, line 47 def included_blocks self.class.included_blocks - plot.included_blocks end
player_vault()
click to toggle source
# File lib/gamefic/chapter.rb, line 59 def player_vault plot.player_vault end
rulebook()
click to toggle source
# File lib/gamefic/chapter.rb, line 51 def rulebook plot.rulebook end
script()
click to toggle source
# File lib/gamefic/chapter.rb, line 43 def script included_blocks.select(&:script?).each { |blk| Stage.run self, &blk.code } end
subplots()
click to toggle source
# File lib/gamefic/chapter.rb, line 63 def subplots plot.subplots end