#!/usr/bin/env ruby
# $Revision: 1.7 $
# $Date: 2003/12/06 18:12:08 $
# $Author: jefus, mikeman2 $

def Commands.do_look(doer, args)
	if args == ""
		doer.puts(doer.location.render)
	else
		target = nil
		# find the object to look at
		# first, check the doer's inventory
		doer.contents.each {|object| 
			target = object if object.name.downcase.include?(args.downcase)
		}

		if target
			doer.puts("&WYou look at #{target.name.downcase}&*")
			doer.location.puts("&W#{doer.name} looks at #{target.name.downcase}&*", doer)
			doer.puts(target.description) if target.description != nil
			doer.puts("You see nothing special about it.") if target.description == nil
		else
			# try finding it in the doer's location, then
			if doer.location
				doer.location.contents.each {|object|
					target = object if object.name.downcase.include?(args.downcase)
				}

				if target
					doer.puts("&WYou look at #{target.name.downcase}&*")
					doer.location.puts("&W#{doer.name} looks at #{target.name.downcase}&*", doer)
					doer.puts(target.description) if target.description != nil
					doer.puts("You see nothing special about them.") if target.description == nil
				else
					# time to give up if we haven't found it yet.
					doer.puts("&WYou don't see &*#{args}&W here&*")
				end
			end
		end
	end
end