require "BaseObject.rb" module RubyMud class Room < BaseObject # Say something to all mobiles in the room # mobile can be nil, when not nil it will # echo 'string' to all the mobiles except 'mobile' def roomTalk(mobile,string) for m in @container m.onRoomTalk(mobile,string) if (m.is_a?(Mobile)) end end def roomTalkFromMobile(mobile,string) for m in @container m.onMobileSaidSomethingInRoom(mobile,string) if m.is_a?(Mobile) end end def dropItem(mobile,item) @container.push(item) if (@container.length == 0) return end # Notify all mobiles that there was an item droped in the room for i in @container i.onItemDroppedInRoom(mobile,item) if i.is_a?(Mobile) end end def descriptionOfMobilesInRoom(mobile) return "" if (@container.length == 0) ret = "" for m in @container if (m.is_a?(Mobile)) # Do not include the calling mobile ret += m.name+" is here\r\n" if mobile != m end end return ret end def descriptionOfItemsInRoom() if (@container.length == 0) return "" end ret = "" for i in @container ret += "a " + i.name+" is lying on the ground\r\n" if i.is_a?(Item) end return ret end def exits @exits end def exitString ret = "" exitCount = 0 for exit in @exits next if exit.rooms[self][0] == nil ret += "," if (exitCount > 0) ret += exit.rooms[self][0] exitCount +=1 end return ret end def initialize(name,description) super(nil,name,description) @exits = [] end end end # module