Class: Radventure::Room

Inherits:
Object
  • Object
show all
Defined in:
lib/radventure/room.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description, is_lit: true) ⇒ Room

Constructor method

Parameters:

  • name (String)

    The name of the room

  • description (String)

    The description of the room

  • is_lit (Boolean) (defaults to: true)

    Whether or not the room has light, defaults to ‘true`



15
16
17
18
19
20
# File 'lib/radventure/room.rb', line 15

def initialize(name, description, is_lit: true)
  @name        = name.strip
  @description = description.strip
  @is_lit      = is_lit ? true : false
  @items       = []
end

Instance Attribute Details

#downObject

Returns the value of attribute down.



6
7
8
# File 'lib/radventure/room.rb', line 6

def down
  @down
end

#eastObject

Returns the value of attribute east.



6
7
8
# File 'lib/radventure/room.rb', line 6

def east
  @east
end

#insideObject

Returns the value of attribute inside.



6
7
8
# File 'lib/radventure/room.rb', line 6

def inside
  @inside
end

#is_litObject (readonly)

Returns the value of attribute is_lit.



5
6
7
# File 'lib/radventure/room.rb', line 5

def is_lit
  @is_lit
end

#itemsObject (readonly)

Returns the value of attribute items.



5
6
7
# File 'lib/radventure/room.rb', line 5

def items
  @items
end

#northObject

Returns the value of attribute north.



6
7
8
# File 'lib/radventure/room.rb', line 6

def north
  @north
end

#northeastObject

Returns the value of attribute northeast.



6
7
8
# File 'lib/radventure/room.rb', line 6

def northeast
  @northeast
end

#northwestObject

Returns the value of attribute northwest.



6
7
8
# File 'lib/radventure/room.rb', line 6

def northwest
  @northwest
end

#outsideObject

Returns the value of attribute outside.



6
7
8
# File 'lib/radventure/room.rb', line 6

def outside
  @outside
end

#southObject

Returns the value of attribute south.



6
7
8
# File 'lib/radventure/room.rb', line 6

def south
  @south
end

#southeastObject

Returns the value of attribute southeast.



6
7
8
# File 'lib/radventure/room.rb', line 6

def southeast
  @southeast
end

#southwestObject

Returns the value of attribute southwest.



6
7
8
# File 'lib/radventure/room.rb', line 6

def southwest
  @southwest
end

#upObject

Returns the value of attribute up.



6
7
8
# File 'lib/radventure/room.rb', line 6

def up
  @up
end

#westObject

Returns the value of attribute west.



6
7
8
# File 'lib/radventure/room.rb', line 6

def west
  @west
end

Instance Method Details

#description(darkvision: false) ⇒ String

The description of the room

Returns:

  • (String)

    The description of the room



36
37
38
39
40
41
42
# File 'lib/radventure/room.rb', line 36

def description(darkvision: false)
  if @is_lit || darkvision
    @description
  else
    'The room is in total darkness and you cannot see a thing.'
  end
end

#name(darkvision: false) ⇒ String

The name of the room

Returns:

  • (String)

    The name of the room



25
26
27
28
29
30
31
# File 'lib/radventure/room.rb', line 25

def name(darkvision: false)
  if @is_lit || darkvision
    @name
  else
    'Darkness'
  end
end