Sha256: 7ddfb08833b91ea07a4e0bdb3d7123a42d67b34e29136c7b4253d3d4b6ad1d6d

Contents?: true

Size: 1.11 KB

Versions: 2

Compression:

Stored size: 1.11 KB

Contents

# frozen_string_literal: true

module Gamefic
  module Standard
    module Actions
      module Unlock
        extend Gamefic::Scriptable

        respond :unlock, available(Lockable) do |actor, thing|
          if thing.has_lock_key? && actor.children.include?(thing.lock_key)
            actor.execute :unlock, thing, thing.lock_key
          else
            actor.tell "You can't unlock #{the thing}."
          end
        end

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

        respond :unlock, 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 'unlock :container with :key', 'unlock :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/unlock.rb
gamefic-standard-3.3.0 lib/gamefic-standard/actions/unlock.rb