znmud-0.0.1/benchmark/
znmud-0.0.1/cmd/
znmud-0.0.1/cmd/emotes/
znmud-0.0.1/cmd/objects/
znmud-0.0.1/cmd/tiny/
znmud-0.0.1/doc/
znmud-0.0.1/farts/
znmud-0.0.1/lib/
znmud-0.0.1/lib/combat/
znmud-0.0.1/lib/core/bodytypes/
znmud-0.0.1/lib/engine/
znmud-0.0.1/lib/farts/
znmud-0.0.1/logs/
#
# file::    cmd_get.rb

# author::  Jon A. Lambert
# version:: 2.2.0
# date::    08/29/2005

# Additional Contributor: Craig Smith
require 'gettext'
#
# This source code copyright (C) 2005 by Jon A. Lambert
# All rights reserved.
#
# Released under the terms of the TeensyMUD Public License
# See LICENSE file for additional information.
#
module Cmd
  include GetText
  bindtextdomain("cmd")

  # gets all objects in the room into your inventory
  def cmd_get(args)
    from_keyword = _("from")
    all_keyword = _("all")
    case args
    when nil, ""
        sendto _("Get what?")
    when /(.*)\s+#{from_keyword}\s+(.*)/i
    	what = $1
	from = $2
	fromobj = nil
	objs = find_inv(from)
	case objs.size
	when 0
		objs = get_object(location).find_objects(from)
		case objs.size
		when 0
			sendto _("Unable to find %{item}." % {:item => from})
		when 1
			fromobj = objs[0]
		else
			sendto _("Which one?")
		end
	when 1
		fromobj = objs[0]
	else
		sendto _("Which one?")
	end
	if fromobj
		if fromobj.kind_of? Container
			if what == all_keyword
				if fromobj.contents.size < 1
					sendto _("It is empty.")
					return
				end
				fromobj.contents.each do |oid|
					add_event(id,oid,:get)
				end
			else
				objs = fromobj.find(what)
				if objs.size > 0
					objs.each do |o|
						add_event(id, o.id, :get)
					end
				else
					sendto _("You do not see that in the %{container}" % {:container => fromobj.name})
				end
			end
		elsif fromobj.kind_of? BodyPart
			items = fromobj.wearing
			items << fromobj.wield if fromobj.wield
			fromobj.worn.clear
			fromobj.wield = nil
			fromobj.tail.each do |tid|
				part = get_object(tid)
				items.concat(part.wearing)
				items << part.wield if part.wield
				part.worn.clear
				part.wield = nil
			end
			items.each do |oid|
				obj = get_object(oid)
				obj.location = id
				add_contents(oid)
				msg = _("You get %{obj} from the %{part}." % {:obj => obj.shortname, :part => fromobj.name})
				add_event(obj.id, id, :show, msg)
				msg = Msg.new _("^p1 gets ^o1 from a %{part}." % {:part => fromobj.name})
				msg.p1 = name
				msg.o1 = obj.shortname
				sendroom(msg)
			end
		else
			sendto _("You can not do that.")
		end
	end
    when all_keyword		# Get everything
        get_object(location).objects.each do |q|
           add_event(id,q.id,:get)
        end
    else
	objs = get_object(location).find_objects(args)
	if objs.size > 0
		objs.each do |obj|
			add_event(id,obj.id,:get)
		end
	else
		sendto _("Couldn't find %{args}" % {:args => args})
	end
     end
  end

end