Class: Room

Inherits:
Thing
  • Object
show all
Defined in:
lib/gamefic-standard/entities/room.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#explicit_exits=(value) ⇒ Object (writeonly)

Sets the attribute explicit_exits

Parameters:

  • value

    the value to set the attribute explicit_exits to.



4
5
6
# File 'lib/gamefic-standard/entities/room.rb', line 4

def explicit_exits=(value)
  @explicit_exits = value
end

Class Method Details

.explicit_exits=(bool) ⇒ Object



42
43
44
# File 'lib/gamefic-standard/entities/room.rb', line 42

def explicit_exits=(bool)
  set_default explicit_exits: bool
end

.explicit_exits?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/gamefic-standard/entities/room.rb', line 38

def explicit_exits?
  default_attributes[:explicit_exits]
end

Instance Method Details

#connect(destination, direction: nil, type: Portal, two_way: true) ⇒ Portal+

Parameters:

  • destination (Room)
  • direction (Direction, String, nil) (defaults to: nil)
  • type (Class<Portal>) (defaults to: Portal)
  • two_way (Boolean) (defaults to: true)

Returns:



26
27
28
29
30
31
32
33
34
35
# File 'lib/gamefic-standard/entities/room.rb', line 26

def connect destination, direction: nil, type: Portal, two_way: true
  direction = Direction.find(direction)
  here = type.new(parent: self,
                    destination: destination,
                    direction: Direction.find(direction))
  return here unless two_way

  there = type.new(parent: destination, destination: self, direction: direction&.reverse)
  [here, there]
end

#explicit_exits?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/gamefic-standard/entities/room.rb', line 8

def explicit_exits?
  @explicit_exits
end

#portalsArray<Portal>

Returns:



17
18
19
# File 'lib/gamefic-standard/entities/room.rb', line 17

def portals
  children.that_are(Portal)
end

#tell(message) ⇒ Object



12
13
14
# File 'lib/gamefic-standard/entities/room.rb', line 12

def tell(message)
  children.each { |c| c.tell message }
end