Sha256: e279ba8e6bf33adec91e6a80a597cacecf6b14f65d8e432e9eff51f167072943

Contents?: true

Size: 805 Bytes

Versions: 7

Compression:

Stored size: 805 Bytes

Contents

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

      respond :lock, available(Lockable, proc(&:has_lock_key?)), children do |actor, thing, key|
        if thing.lock_key == key
          thing.locked = true
          actor.tell "You lock ##{the thing} with #{the key}."
        else
          actor.tell "You can't lock #{the thing} with #{the key}."
        end
      end

      respond :lock, available(Lockable, proc(&:has_lock_key?)), available do |actor, thing, key|
        actor.execute :take, key if key.parent != actor
        actor.proceed if key.parent == actor
      end

      interpret "lock :container with :key", "lock :container :key"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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