class Room

The Room class is the mother of all rooms.

Public Class Methods

new(name, owner) click to toggle source

Create a new Room object

name

The displayed name of the room

owner

The owner id of this room

return

A handle to the new Room.

# File lib/core/room.rb, line 28
def initialize(name, owner)
  super(name, owner)
  self.exits=[]               # The list of exits for this room.
end

Public Instance Methods

arrive(e) click to toggle source

Event :arrive

e

The event

return

Undefined

# File lib/core/room.rb, line 71
def arrive(e)
  ch = get_object(e.msg)
  # add character
  add_contents(ch.id)
  ch.location = id
  characters(e.msg).each do |x|
    add_event(id,x.id,:show, ch.name+" has arrived.") if x.account
  end
  ch.parse('look')
end
describe(e) click to toggle source

Event :describe

e

The event

return

Undefined

# File lib/core/room.rb, line 36
def describe(e)
  msg = "[COLOR Green](#{id.to_s}) #{name}[/COLOR]\n#{desc}\n"
  add_event(id,e.from,:show,msg)
end
describe_exits(e) click to toggle source

Event :#describe_exits

e

The event

return

Undefined

# File lib/core/room.rb, line 44
def describe_exits(e)
  msg = "[COLOR Red]Exits:\n"
  s = exits.size
  if s == 0
    msg << "None.[/COLOR]"
  else
    i = 0
    exits.each do |exid|
      ex = get_object(exid)
      key = ex.name.split(%r;/).first
      msg << key
      i += 1
      case s - i
      when 1 then s > 2 ? msg << ", and " : msg << " and "
      when 0 then msg << "."
      else
        msg << ", "
      end
    end
    msg << "[/COLOR]"
  end
  add_event(id,e.from,:show,msg)
end