Class: Gamefic::Standard::Room
- 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
-
#explicit_exits ⇒ Object
writeonly
Sets the attribute explicit_exits.
Attributes included from Standardized
#itemized, #locale_description, #portable
Instance Method Summary collapse
- #connect(destination, direction: nil, type: Portal, two_way: true, **opts) ⇒ Portal+
- #explicit_exits? ⇒ Boolean
- #portals ⇒ Array<Portal>
- #tell(message) ⇒ Object
Methods included from Standardized
#attached=, #attached?, #itemized?, #parent=, #portable?, #room
Instance Attribute Details
#explicit_exits=(value) ⇒ Object (writeonly)
Sets the attribute explicit_exits
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+
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
13 14 15 |
# File 'lib/gamefic/standard/entities/room.rb', line 13 def explicit_exits? @explicit_exits end |
#portals ⇒ Array<Portal>
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() children.each { |c| c.tell } end |