Class: Gamefic::Plot
Overview
The plot is the central narrative. It provides a script interface with methods for creating entities, actions, scenes, and hooks.
Instance Attribute Summary
Attributes inherited from Narrative
Class Method Summary collapse
Instance Method Summary collapse
- #attach(cache) ⇒ Object
-
#branch(subplot_class = Gamefic::Subplot, introduce: [], **config) ⇒ Gamefic::Subplot
Start a new subplot based on the provided class.
- #detach ⇒ Object
- #hydrate ⇒ Object
- #inspect ⇒ Object
- #ready ⇒ Object
- #save ⇒ Object
-
#subplots ⇒ Array<Subplot>
Get an array of all the current subplots.
-
#uncast(actor) ⇒ Actor
Remove an actor from the game.
- #update ⇒ Object
Methods inherited from Narrative
#cast, #concluding?, inherited, #initialize, #introduce, #scenes
Methods included from Scriptable
#attr_seed, #blocks, #included_blocks, #make_seed, #method_missing, #no_scripts, #respond_to_missing?, #script, #seed
Methods included from Scriptable::Scenes
#block, #conclusion, #introduction, #multiple_choice, #pause, #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
#anywhere, #available, #children, #myself, #parent, #plaintext, #siblings
Methods included from Scriptable::Proxy
Methods included from Scriptable::Entities
#destroy, #entities, #entity_vault, #make, #pick, #pick!, #player_vault, #players
Methods included from Logging
Constructor Details
This class inherits a constructor from Gamefic::Narrative
Class Method Details
Instance Method Details
#attach(cache) ⇒ Object
67 68 69 70 |
# File 'lib/gamefic/plot.rb', line 67 def attach(cache) super(cache.shift) subplots.each { |subplot| subplot.attach cache.shift } end |
#branch(subplot_class = Gamefic::Subplot, introduce: [], **config) ⇒ Gamefic::Subplot
Start a new subplot based on the provided class.
47 48 49 50 |
# File 'lib/gamefic/plot.rb', line 47 def branch subplot_class = Gamefic::Subplot, introduce: [], **config subplot_class.new(self, introduce: introduce, **config) .tap { |sub| subplots.push sub } end |
#detach ⇒ Object
60 61 62 63 64 65 |
# File 'lib/gamefic/plot.rb', line 60 def detach cache = [@rulebook] @rulebook = nil cache.concat subplots.map(&:detach) cache end |
#hydrate ⇒ Object
72 73 74 75 |
# File 'lib/gamefic/plot.rb', line 72 def hydrate super subplots.each(&:hydrate) end |
#inspect ⇒ Object
56 57 58 |
# File 'lib/gamefic/plot.rb', line 56 def inspect "#<#{self.class}>" end |
#ready ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/gamefic/plot.rb', line 8 def ready super subplots.each(&:ready) players.each(&:start_take) subplots.delete_if(&:concluding?) players.select(&:concluding?).each { |plyr| rulebook.run_player_conclude_blocks plyr } end |
#subplots ⇒ Array<Subplot>
Get an array of all the current subplots.
37 38 39 |
# File 'lib/gamefic/plot.rb', line 37 def subplots @subplots ||= [] end |
#uncast(actor) ⇒ Actor
Remove an actor from the game.
Calling ‘uncast` on the plot will also remove the actor from its subplots.
29 30 31 32 |
# File 'lib/gamefic/plot.rb', line 29 def uncast actor subplots.each { |sp| sp.uncast actor } super end |
#update ⇒ Object
16 17 18 19 20 |
# File 'lib/gamefic/plot.rb', line 16 def update players.each(&:finish_take) super subplots.each(&:update) end |