Class: Degica::Door
- Inherits:
-
Object
- Object
- Degica::Door
- Includes:
- Actionable, Collectable
- Defined in:
- lib/degica/door.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
Attributes included from Collectable
Instance Method Summary collapse
- #actions ⇒ Object
- #describe ⇒ Object
- #enter ⇒ Object
-
#initialize(room1, room2) ⇒ Door
constructor
A new instance of Door.
- #open ⇒ Object
- #prompt ⇒ Object
Methods included from Actionable
Constructor Details
#initialize(room1, room2) ⇒ Door
Returns a new instance of Door.
8 9 10 11 12 13 14 15 |
# File 'lib/degica/door.rb', line 8 def initialize(room1, room2) @description = DoorNameGenerator.sample @rooms = [room1, room2] # connect rooms room1.doors << self room2.doors << self end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/degica/door.rb', line 6 def description @description end |
Instance Method Details
#actions ⇒ Object
17 18 19 |
# File 'lib/degica/door.rb', line 17 def actions [Action.new(:enter, self), Action.new(:open, self)] end |
#describe ⇒ Object
33 34 35 |
# File 'lib/degica/door.rb', line 33 def describe @description end |
#enter ⇒ Object
26 27 28 29 30 31 |
# File 'lib/degica/door.rb', line 26 def enter next_room = (@rooms - [Game.objects.actor.location])[0] Game.objects.actor.location = next_room next_room.generate! next_room end |
#open ⇒ Object
21 22 23 24 |
# File 'lib/degica/door.rb', line 21 def open Game.objects.actor.focus = self "You opened the door. Try to (enter) it.".highlight end |
#prompt ⇒ Object
37 38 39 |
# File 'lib/degica/door.rb', line 37 def prompt "door" end |