require 'drb'

module RubyMud	
	
	
	class MapRoom
		include DRbUndumped
		def Room
			return @room
		end		
		
		def Color=(color)
			@color = color
		end		
		def Color
			@color
		end		
		def SizeX=(sizex)
			@sizex = sizex
		end		
		def SizeX
			@sizex
		end				
		def SizeY=(sizey)
			@sizey = sizey
		end		
		def SizeY
			@sizey
		end						
		
		
		def X=(x)
			@x = x
		end
		def X
			@x
		end						
		
		def Y=(y)
			@y = y
		end		
		def Y
			@y
		end								
		
		def initialize(room)
			@room = room
			@x = 0
			@y = 0
			@sizex = 20
			@sizey = 20
			@color = [0,0,0]
		end
	end

	class MappingService
	    
		def GetRoom(num)
			room = @rooms[num]
			
			# Room isnt in the mapping service
			if room == nil
				# Check if there is such a room
				baseRoom = BaseObject.FindObject(num)
		
				# It exists in the world, add it to the service
				if baseRoom != nil and baseRoom.is_a?(Room)
					room = MapRoom.new(baseRoom)
					@rooms[num] = room
				end
				
			end
			
			if room == nil
				return nil
			end	
			
			return room
		end	  
				
		def initialize()
			@rooms = {}
		end
	  
	end

aServerObject = MappingService.new
DRb.start_service('druby://localhost:9000', aServerObject)
#DRb.thread.join # Don't exit just yet!

end # module