Class: Gamefic::Scene::MultipleChoice

Inherits:
Base
  • Object
show all
Defined in:
lib/gamefic/scene/multiple_choice.rb

Overview

A scene that presents a list of choices. If the input does not match any of the choices, the scene gets recued.

Direct Known Subclasses

ActiveChoice, YesOrNo

Instance Attribute Summary

Attributes inherited from Base

#actor, #context, #name, #narrative, #props

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

finish_blocks, inherited, on_finish, on_start, props_class, #rename, rename, start_blocks, #to_hash, #type

Constructor Details

#initializeMultipleChoice

Returns a new instance of MultipleChoice.



11
12
13
14
# File 'lib/gamefic/scene/multiple_choice.rb', line 11

def initialize(...)
  super
  props.options.concat(context[:options] || [])
end

Class Method Details

.typeObject



29
30
31
# File 'lib/gamefic/scene/multiple_choice.rb', line 29

def self.type
  'MultipleChoice'
end

Instance Method Details

#finishObject



22
23
24
25
26
27
# File 'lib/gamefic/scene/multiple_choice.rb', line 22

def finish
  return super if props.selected?

  actor.tell format(props.invalid_message, input: props.input)
  actor.recue
end

#startObject



16
17
18
19
20
# File 'lib/gamefic/scene/multiple_choice.rb', line 16

def start
  super
  props.output[:options] = props.options
  props
end