lib/gamefic/plot.rb in gamefic-3.3.0 vs lib/gamefic/plot.rb in gamefic-3.4.0
- old
+ new
@@ -3,16 +3,30 @@
module Gamefic
# The plot is the central narrative. It provides a script interface with
# methods for creating entities, actions, scenes, and hooks.
#
class Plot < Narrative
+ def seed
+ super
+ chapters.each(&:seed)
+ end
+
+ def script
+ super
+ chapters.each(&:script)
+ rulebook.scenes.with_defaults self
+ end
+
+ def chapters
+ @chapters ||= self.class.appended_chapters.map { |klass| klass.new(self) }
+ end
+
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
def update
@@ -72,9 +86,17 @@
end
def hydrate
super
subplots.each(&:hydrate)
+ end
+
+ def self.append chapter
+ appended_chapters.add chapter
+ end
+
+ def self.appended_chapters
+ @appended_chapters ||= Set.new
end
def self.restore data
Snapshot.restore data
end