Class: Room
- Inherits:
-
Object
- Object
- Room
- Defined in:
- lib/room.rb
Instance Attribute Summary collapse
-
#denarii ⇒ Object
Returns the value of attribute denarii.
-
#direction ⇒ Object
Returns the value of attribute direction.
-
#e ⇒ Object
Returns the value of attribute e.
-
#item ⇒ Object
Returns the value of attribute item.
-
#n ⇒ Object
Returns the value of attribute n.
-
#name ⇒ Object
Returns the value of attribute name.
-
#npc ⇒ Object
Returns the value of attribute npc.
-
#s ⇒ Object
Returns the value of attribute s.
-
#w ⇒ Object
Returns the value of attribute w.
Instance Method Summary collapse
-
#initialize(name, n, s, e, w, npc, denarii, item) ⇒ Room
constructor
A new instance of Room.
- #look ⇒ Object
- #search ⇒ Object
Constructor Details
#initialize(name, n, s, e, w, npc, denarii, item) ⇒ Room
Returns a new instance of Room.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/room.rb', line 3 def initialize(name, n, s, e, w, npc, denarii, item) @name = name @n = n @s = s @e = e @w = w @npc = npc @denarii = denarii @item = item end |
Instance Attribute Details
#denarii ⇒ Object
Returns the value of attribute denarii.
2 3 4 |
# File 'lib/room.rb', line 2 def denarii @denarii end |
#direction ⇒ Object
Returns the value of attribute direction.
2 3 4 |
# File 'lib/room.rb', line 2 def direction @direction end |
#e ⇒ Object
Returns the value of attribute e.
2 3 4 |
# File 'lib/room.rb', line 2 def e @e end |
#item ⇒ Object
Returns the value of attribute item.
2 3 4 |
# File 'lib/room.rb', line 2 def item @item end |
#n ⇒ Object
Returns the value of attribute n.
2 3 4 |
# File 'lib/room.rb', line 2 def n @n end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/room.rb', line 2 def name @name end |
#npc ⇒ Object
Returns the value of attribute npc.
2 3 4 |
# File 'lib/room.rb', line 2 def npc @npc end |
#s ⇒ Object
Returns the value of attribute s.
2 3 4 |
# File 'lib/room.rb', line 2 def s @s end |
#w ⇒ Object
Returns the value of attribute w.
2 3 4 |
# File 'lib/room.rb', line 2 def w @w end |
Instance Method Details
#look ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/room.rb', line 14 def look puts 'You are in ' + $player.location.name + '.' unless $player.location.npc.nil? puts 'There is a ' + $player.location.npc.name + ' in the room.' end unless $player.location.item.nil? puts 'It contains a ' + $player.location.item.to_s + '.' end end |
#search ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/room.rb', line 24 def search if $player.location.denarii > 0 $player.gain puts 'You find ' + $player.location.denarii.to_s + ' denarii in the room. You now have ' + $player.denarii.to_s + ' denarii.' $player.location.denarii = 0 else puts 'There is no money in this room.' end end |