Class: Gamefic::Scene::MultipleChoice

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

Overview

Provide a list of options and process the selection in the scene’s finish block. After the scene is finished, the :active scene will be cued unless some other scene has already been prepared or cued.

The finish block’s input parameter receives a MultipleChoice::Input object instead of a String.

Direct Known Subclasses

MultipleScene

Instance Method Summary collapse

Methods inherited from Custom

#initialize, #on_finish, #on_start, #prompt_for

Methods inherited from Base

#prompt_for, #type

Constructor Details

This class inherits a constructor from Gamefic::Scene::Custom

Instance Method Details

#data_classObject



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

def data_class
  SceneData::MultipleChoice
end

#finish(actor, input) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gamefic/scene/multiple_choice.rb', line 22

def finish actor, input
  data = finish_data_for(actor, input)
  get_choice data
  if data.selection.nil?
    actor.tell data.invalid_message
    tell_options actor, data
  else
    do_finish_block actor, data
  end
  data
end

#start(actor) ⇒ Object



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

def start actor
  data = start_data_for(actor)
  data.options.clear
  do_start_block actor, data
  tell_options actor, data
end