Class: Gamefic::Chapter
- Extended by:
- Scriptable::PlotProxies
- Defined in:
- lib/gamefic/chapter.rb
Overview
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.
Instance Attribute Summary collapse
- #plot ⇒ Plot readonly
Instance Method Summary collapse
- #branch ⇒ Object
- #entity_vault ⇒ Object
- #included_blocks ⇒ Object
-
#initialize(plot) ⇒ Chapter
constructor
A new instance of Chapter.
- #player_vault ⇒ Object
- #rulebook ⇒ Object
- #script ⇒ Object
- #subplots ⇒ Object
Methods included from Scriptable::PlotProxies
attr_plot, lazy_plot, plot_pick, plot_pick!
Methods inherited from Narrative
#attach, #cast, #concluding?, #detach, #hydrate, inherited, #introduce, #post_script, #ready, #scenes, #seed, #uncast, #update
Methods included from Scriptable
#attr_seed, #blocks, #lazy_attr, #lazy_ivar, #make_seed, #method_missing, #no_scripts, #pick, #pick!, #proxy, #respond_to_missing?, #seed
Methods included from Scriptable::Scenes
#block, #conclusion, #introduction, #multiple_choice, #pause, #preface, #scene, #scenes, #yes_or_no
Methods included from Scriptable::Events
#on_conclude, #on_player_conclude, #on_player_output, #on_player_ready, #on_player_update, #on_ready, #on_update
Methods included from Scriptable::Actions
#after_action, #before_action, #interpret, #meta, #respond, #synonyms, #syntaxes, #verbs
Methods included from Scriptable::Queries
#abstract, #anywhere, #available, #children, #descendants, #myself, #parent, #plaintext, #siblings
Methods included from Scriptable::Proxies
Methods included from Scriptable::Entities
#destroy, #entities, #find, #make, #pick, #pick!, #players
Methods included from Logging
Constructor Details
#initialize(plot) ⇒ Chapter
Returns a new instance of Chapter.
37 38 39 40 41 |
# File 'lib/gamefic/chapter.rb', line 37 def initialize(plot) @plot = plot # The plot is responsible for hydrating chapters super(hydrate: false) end |
Instance Attribute Details
Instance Method Details
#branch ⇒ Object
67 68 69 |
# File 'lib/gamefic/chapter.rb', line 67 def branch(...) plot.branch(...) end |
#entity_vault ⇒ Object
55 56 57 |
# File 'lib/gamefic/chapter.rb', line 55 def entity_vault plot.entity_vault end |
#included_blocks ⇒ Object
47 48 49 |
# File 'lib/gamefic/chapter.rb', line 47 def included_blocks self.class.included_blocks - plot.included_blocks end |
#player_vault ⇒ Object
59 60 61 |
# File 'lib/gamefic/chapter.rb', line 59 def player_vault plot.player_vault end |
#rulebook ⇒ Object
51 52 53 |
# File 'lib/gamefic/chapter.rb', line 51 def rulebook plot.rulebook end |
#script ⇒ Object
43 44 45 |
# File 'lib/gamefic/chapter.rb', line 43 def script included_blocks.select(&:script?).each { |blk| Stage.run self, &blk.code } end |
#subplots ⇒ Object
63 64 65 |
# File 'lib/gamefic/chapter.rb', line 63 def subplots plot.subplots end |