Class: Gamefic::Active::Take

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(actor, cue, props = nil) ⇒ Take

Returns a new instance of Take.

Parameters:



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

#actorActive (readonly)

Returns:



9
10
11
# File 'lib/gamefic/active/take.rb', line 9

def actor
  @actor
end

#cueActive::Cue (readonly)

Returns:



12
13
14
# File 'lib/gamefic/active/take.rb', line 12

def cue
  @cue
end

#sceneScene::Default (readonly)

Returns:



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.

Parameters:



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

Parameters:

Returns:



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

#finishvoid

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

#propsProps::Default

Returns:



28
29
30
# File 'lib/gamefic/active/take.rb', line 28

def props
  @props ||= @scene.new_props(**cue.context)
end

#startProps::Default

Returns:



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.messages,
                        queue: actor.queue
                      })
  props
end