Sha256: 979284d69ea6d16295a1177472012eb4e7ee521b65110206aab13cfe50546af9

Contents?: true

Size: 783 Bytes

Versions: 2

Compression:

Stored size: 783 Bytes

Contents

Gamefic.script do
  respond :open, Use.available do |actor, thing|
    actor.tell "You can't open #{the thing}."
  end

  respond :open, Use.available(Openable) do |actor, thing|
    if thing.open?
      actor.tell "#{The thing} is already open."
    else
      actor.tell "You open #{the thing}."
      thing.open = true
    end
  end

  respond :open, Use.available(Lockable) do |actor, thing|
    if thing.locked?
      actor.tell "#{The thing} is locked."
    else
      actor.proceed
    end
  end

  respond :open, Use.available(Lockable, :has_lock_key?), Use.available do |actor, thing, key|
    actor.perform :unlock, thing, key
    actor.perform :open, thing if thing.unlocked?
  end

  interpret 'open :thing with :key', 'open :thing :key'
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gamefic-standard-2.3.1 lib/gamefic-standard/actions/open.rb
gamefic-standard-2.3.0 lib/gamefic-standard/actions/open.rb