Class: Gamefic::What::AskForWhat

Inherits:
Scene::Base
  • Object
show all
Defined in:
lib/gamefic/what.rb

Overview

Perform a command based on the player’s answer for what an object of the previous command should be.

Examples:

class MyPlot < Gamefic::Plot
  include Gamefic::What

  construct :room, Gamefic::Entity, name: 'room'
  construct :thing, Gamefic::Entity, name: 'thing', parent: room

  introduction do |actor|
    actor.parent = room
  end

  respond :take, Gamefic::Entity do |actor, thing|
    thing.parent = actor
    actor.tell "You take it."
  end

  respond :take do |actor|
    actor.tell 'What do you want to take?'
    actor.cue AskForWhat, template: 'take __what__'
  end
end

Instance Method Summary collapse

Instance Method Details

#finishObject



35
36
37
38
39
40
41
42
# File 'lib/gamefic/what.rb', line 35

def finish
  if command_with_answer_actions.empty? && actor.can?(props.input.keywords.first)
    actor.perform(props.input)
  else
    actor.perform command_with_answer
  end
  super
end