Sha256: cf04915767e2b845c085779d7003229125eec9dca5c2cc19d0b7dd5a28cfb082

Contents?: true

Size: 780 Bytes

Versions: 7

Compression:

Stored size: 780 Bytes

Contents

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

  respond :open, 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, available(Lockable) do |actor, thing|
    if thing.locked?
      actor.tell "#{The thing} is locked."
    else
      actor.proceed
    end
  end

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gamefic-standard-3.2.4 lib/gamefic-standard/actions/open.rb
gamefic-standard-3.2.3 lib/gamefic-standard/actions/open.rb
gamefic-standard-3.2.2 lib/gamefic-standard/actions/open.rb
gamefic-standard-3.2.1 lib/gamefic-standard/actions/open.rb
gamefic-standard-3.2.0 lib/gamefic-standard/actions/open.rb
gamefic-standard-3.1.0 lib/gamefic-standard/actions/open.rb
gamefic-standard-3.0.0 lib/gamefic-standard/actions/open.rb