require "Command.rb"
require "Commands.rb"

require "Room.rb"

module RubyMud

class Describe < Command
	
	def words
		return ["describe","desc"]
	end	

	def canUse?(object)
		return true if object.getFlagByClass(Admin)	!= nil or object.getFlagByClass(Builder) != nil
		return false
	end
	
	def initialize()
		super()
	end
	
	def execute(clientConnection,string)
		tokens = string.split(' ')

		# Check the parameters		
		if (tokens.length < 3)
			clientConnection.send("describe objectname description\r\n")	
			return true
		end

		# Get the current room
		currentRoom = clientConnection.player.parent

		# find the object
		obj = currentRoom.getObjectByName(tokens[1])
		if obj == nil
			clientConnection.send("Could not find that object\r\n")	
			return true
		end

		tokens.delete_at(0)
		tokens.delete_at(0)
	
		# Set the description
		obj.description = tokens.join(" ")
		
		# send to client
		clientConnection.send("Description set\r\n")
		return true		
	end
		
end

# Create the instance, it adds itself to the commands list
Describe.new()

end # module