Class: Gamefic::Standard::Room

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

Instance Attribute 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.



6
7
8
# File 'lib/gamefic/standard/entities/room.rb', line 6

def explicit_exits=(value)
  @explicit_exits = value
end

Instance Method Details

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

Parameters:

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

Returns:



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

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

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

#explicit_exits?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/gamefic/standard/entities/room.rb', line 10

def explicit_exits?
  @explicit_exits
end

#portalsArray<Portal>

Returns:



19
20
21
# File 'lib/gamefic/standard/entities/room.rb', line 19

def portals
  children.that_are(Portal)
end

#tell(message) ⇒ Object



14
15
16
# File 'lib/gamefic/standard/entities/room.rb', line 14

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