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

module RubyMud

class Inv < Command
	
	def words
		return ["inv"]
	end	
	
	def initialize()
		super()
	end
	
	def execute(clientConnection,string)
		tokens = string.split(' ')

		# Check that there is only one command on the line
		if (tokens.length != 1)
			clientConnection.Send("<inv>")
			return
		end
		
		container = clientConnection.player.container
		
		items = []		
		
		if (container.length > 0)
			for i in 0...container.length
				if (container[i].is_a?(Item))
					items.push(container[i])
				end				
			end
		end
		
		itemString = ""
		for i in 0...items.length
			itemString += items[i].name+"\r\n"
		end
		
		clientConnection.send("You currently carry the following items:\r\n")
		clientConnection.send(itemString)
		
	end
		
end

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

end #module