class Gamefic::Narrator
A narrative controller.
Attributes
@return [Plot]
Public Class Methods
Source
# File lib/gamefic/narrator.rb, line 10 def initialize(plot) @plot = plot last_cues end
Public Instance Methods
Source
# File lib/gamefic/narrator.rb, line 19 def cast(character = plot.introduce) plot.cast character end
Cast a player character in the plot.
@param character [Actor, Active] @return [Actor, Active]
Source
# File lib/gamefic/narrator.rb, line 48 def finish cues.each(&:finish) cues.clear plot.update_blocks.each(&:call) end
Finish a turn.
@return [void]
Source
# File lib/gamefic/narrator.rb, line 38 def start next_cues plot.ready_blocks.each(&:call) plot.turn cues.each(&:prepare) end
Start a turn.
@return [void]
Source
# File lib/gamefic/narrator.rb, line 27 def uncast(character) plot.uncast character end
Uncast a player character from the plot.
@param character [Actor, Active] @return [Actor, Active]
Private Instance Methods
Source
# File lib/gamefic/narrator.rb, line 61 def cues @cues ||= [] end
@return [Array<Active::Cue>]
Source
# File lib/gamefic/narrator.rb, line 66 def last_cues cues.replace(plot.players.map(&:last_cue)) .compact end
@return [void]
Source
# File lib/gamefic/narrator.rb, line 72 def next_cues cues.replace(plot.players.map { |player| player.next_cue || player.cue(plot.default_scene) }) .each(&:start) end
@return [void]