Class: Gamefic::Active::Take
- Inherits:
-
Object
- Object
- Gamefic::Active::Take
- Defined in:
- lib/gamefic/active/take.rb
Overview
The combination of an actor and a scene to be performed in a plot turn.
Instance Attribute Summary collapse
- #actor ⇒ Active readonly
- #cue ⇒ Active::Cue readonly
- #scene ⇒ Scene::Default readonly
Class Method Summary collapse
Instance Method Summary collapse
- #finish ⇒ void
-
#initialize(actor, cue, props = nil) ⇒ Take
constructor
A new instance of Take.
- #props ⇒ Props::Default
- #start ⇒ Props::Default
Constructor Details
#initialize(actor, cue, props = nil) ⇒ Take
Returns a new instance of Take.
20 21 22 23 24 25 |
# File 'lib/gamefic/active/take.rb', line 20 def initialize actor, cue, props = nil @actor = actor @cue = cue @scene = actor.epic.select_scene(cue.scene) @props = props end |
Instance Attribute Details
#cue ⇒ Active::Cue (readonly)
12 13 14 |
# File 'lib/gamefic/active/take.rb', line 12 def cue @cue end |
#scene ⇒ Scene::Default (readonly)
15 16 17 |
# File 'lib/gamefic/active/take.rb', line 15 def scene @scene end |
Class Method Details
.finish(actor, cue, props) ⇒ void
This method returns an undefined value.
64 65 66 |
# File 'lib/gamefic/active/take.rb', line 64 def self.finish actor, cue, props Take.new(actor, cue, props).finish end |
.start(actor, cue) ⇒ Props::Default
57 58 59 |
# File 'lib/gamefic/active/take.rb', line 57 def self.start actor, cue Take.new(actor, cue).start end |
Instance Method Details
#finish ⇒ void
This method returns an undefined value.
47 48 49 50 51 52 |
# File 'lib/gamefic/active/take.rb', line 47 def finish actor.flush scene.finish(actor, props) actor.output.replace(last_prompt: props.prompt, last_input: props.input) scene.run_finish_blocks actor, props end |
#props ⇒ Props::Default
28 29 30 |
# File 'lib/gamefic/active/take.rb', line 28 def props @props ||= @scene.new_props(**cue.context) end |
#start ⇒ Props::Default
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/gamefic/active/take.rb', line 33 def start actor.output[:scene] = scene.to_hash scene.run_start_blocks actor, props scene.start actor, props # @todo See if this can be handled better actor.epic.rulebooks.each { |rlbk| rlbk.run_player_output_blocks actor, actor.output } actor.output.merge!({ messages: actor., queue: actor.queue }) props end |