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

require "Room.rb"

module RubyMud

class ShowFlags < Command
	
	def words
		return ["showflags"]
	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 < 2)
			clientConnection.send("showflags objectname\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

		clientConnection.send("<bright white>Flags on #{obj.name}:\r\n")	

		# Send all the flags on the object to the client
		for flag in obj.flags
			clientConnection.send("*#{flag.class.name}\r\n")	
		end

		return true		
	end
		
end

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

end # module