Class: Gamefic::Standard::Room

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

Overview

An entity that represents a location in the game world that other entities can occupy.

Instance Attribute Summary collapse

Attributes included from Standardized

#itemized, #locale_description, #portable

Instance Method Summary collapse

Methods included from Standardized

#attached=, #attached?, #itemized?, #parent=, #portable?, #room

Instance Attribute Details

#explicit_exits=(value) ⇒ Object (writeonly)

Sets the attribute explicit_exits

Parameters:

  • value

    the value to set the attribute explicit_exits to.



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

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:



31
32
33
34
35
36
37
38
# File 'lib/gamefic/standard/entities/room.rb', line 31

def connect(destination, direction: nil, type: Portal, two_way: true, **opts)
  direction = Direction.find(direction)
  here = type.new parent: self, destination: destination, direction: 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)


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

def explicit_exits?
  @explicit_exits
end

#portalsArray<Portal>

Returns:



22
23
24
# File 'lib/gamefic/standard/entities/room.rb', line 22

def portals
  children.that_are(Portal)
end

#tell(message) ⇒ Object



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

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