class Gamefic::Subplot
Subplots are disposable plots that run inside a parent plot. They can be started and concluded at any time during the parent plot’s runtime.
Attributes
@return [Hash]
@return [Plot]
Public Class Methods
Source
# File lib/gamefic/subplot.rb, line 19 def initialize plot, introduce: [], **config @plot = plot @config = config configure @config.freeze super() @concluded = false [introduce].flatten.each { |plyr| self.introduce plyr } end
@param plot [Gamefic::Plot] @param introduce [Gamefic::Actor, Array
<Gamefic::Actor>, nil] @param config [Hash]
Calls superclass method
Gamefic::Narrative::new
Source
# File lib/gamefic/subplot.rb, line 37 def self.persistent? @persistent ||= false end
Public Instance Methods
Source
# File lib/gamefic/subplot.rb, line 64 def branch subplot_class = Gamefic::Subplot, introduce: [], **config plot.branch subplot_class, introduce: introduce, **config end
Start a new subplot based on the provided class.
@note A subplot’s host is always the base plot, regardless of whether
it was branched from another subplot.
@param subplot_class [Class<Gamefic::Subplot>] The Subplot
class @param introduce [Gamefic::Actor, Array
<Gamefic::Actor>, nil] Players to introduce @param config [Hash] Subplot
configuration @return [Gamefic::Subplot]
Source
# File lib/gamefic/subplot.rb, line 45 def conclude conclude_blocks.each(&:call) players.each do |plyr| player_conclude_blocks.each { |blk| blk[plyr] } uncast plyr end entities.each { |ent| destroy ent } @concluded = true end
Source
# File lib/gamefic/subplot.rb, line 73 def concluding? return super unless persistent? @concluded end
Calls superclass method
Gamefic::Narrative#concluding?
Source
# File lib/gamefic/subplot.rb, line 71 def configure; end
Subclasses can override this method to handle additional configuration options.
Source
# File lib/gamefic/subplot.rb, line 79 def introduce(player) @concluded ? player : super end
Calls superclass method
Gamefic::Narrative#introduce
Source
# File lib/gamefic/subplot.rb, line 41 def persistent? self.class.persistent? end
Source
# File lib/gamefic/subplot.rb, line 83 def prepare(...) super || plot.prepare(...) end
Calls superclass method
Source
# File lib/gamefic/subplot.rb, line 29 def seeds super - plot.seeds end
Calls superclass method