Sha256: c199dc6d2d971a81db3de34154992f3a02f9224ee71388049e113a1b06961103

Contents?: true

Size: 945 Bytes

Versions: 2

Compression:

Stored size: 945 Bytes

Contents

# frozen_string_literal: true

module Gamefic
  module Standard
    module Actions
      module Lock
        extend Gamefic::Scriptable

        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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gamefic-standard-4.0.0 lib/gamefic/standard/actions/lock.rb
gamefic-standard-3.3.0 lib/gamefic-standard/actions/lock.rb