Sha256: 76ecd2a1437d26f61dfbe236020d774c57d0339052bacafc56948e0d93c58c9b

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

module Gamefic
  module Standard
    module Actions
      module Search
        extend Gamefic::Scriptable

        respond :search, available(Thing) do |actor, thing|
          actor.execute :look, thing
        end

        respond :search, available(Receptacle) do |actor, thing|
          if thing.accessible?
            itemized = thing.children.that_are_not(proc(&:attached?)).that_are(proc(&:itemized?))
            if itemized.empty?
              actor.tell "There's nothing inside #{the thing}."
            else
              actor.tell "You see #{itemized.join_and} in #{the thing}." unless itemized.empty?
            end
          else
            actor.tell "You can't see inside #{the thing}."
          end
        end

        respond :search, available(Container, proc(&:closed?)) do |actor, container|
          actor.execute :open, container
          actor.proceed if container.open?
        end

        interpret 'look inside :thing', 'search :thing'
        interpret 'look in :thing', 'search :thing'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gamefic-standard-3.3.0 lib/gamefic-standard/actions/search.rb