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

require "Room.rb"

module RubyMud

class ShowStats < Command
	
	def words
		return ["showstats"]
	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("showstats 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>Stats on #{obj.name}:\r\n")	
		# Send all the stats on the object to the client
		for stat in obj.stats
			clientConnection.send("*#{stat.class.name}->#{stat.value}\r\n")	
		end

		return true		
	end
		
end

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

end # module