Class: Location

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/game/location.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, description, north, east, south, west) ⇒ Location

Returns a new instance of Location.



9
10
11
12
13
14
15
16
# File 'lib/minitest/game/location.rb', line 9

def initialize(name, description, north, east, south, west)
  @name = name
  @description = description
  @north = north
  @east = east
  @south = south
  @west = west
end

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/minitest/game/location.rb', line 3

def description
  @description
end

#eastObject

Returns the value of attribute east.



5
6
7
# File 'lib/minitest/game/location.rb', line 5

def east
  @east
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/minitest/game/location.rb', line 2

def name
  @name
end

#northObject

Returns the value of attribute north.



4
5
6
# File 'lib/minitest/game/location.rb', line 4

def north
  @north
end

#southObject

Returns the value of attribute south.



6
7
8
# File 'lib/minitest/game/location.rb', line 6

def south
  @south
end

#westObject

Returns the value of attribute west.



7
8
9
# File 'lib/minitest/game/location.rb', line 7

def west
  @west
end

Class Method Details

.allObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/minitest/game/location.rb', line 20

def all
  locations = []
  sanctuary = Location.new(
    "Sanctuary",
    "A place you feel safe.",
    Place.new("G-Mart", "A shop to buy things. Y'know buy tings."),
    Place.new("Central Park", "A park in the centre of Sanctuary. Nearby is a cafe. Strange, there are 6 friends sitting on a sofa."),
    Place.new("Sanctuary Museum", "A museum that includes the history of Sanctuary. Suprised?"),
    Place.new("The Bench", "A bench on top of a hill where you can see everything. It's pretty so you go there a lot.")
  )
  city_of_the_bc = Location.new(
    "City of the BC",
    "A weird and wonderful city. It hides things because it cares. Not sure if that makes thing right...",
    Place.new("Inside Out", "A club that makes you feel all the emotions."),
    Place.new("Restaurant Name", "A restaurant where the owner could not think of a better name."),
    Place.new("The Forest", "A forest with no goblins."),
    Place.new("The Lake", "A lake with no sword stuck in the middle.")
  )
  locations.push(sanctuary)
  locations.push(city_of_the_bc)
end

Instance Method Details

#placesObject

public instance methods



44
45
46
# File 'lib/minitest/game/location.rb', line 44

def places
  [self.north, self.east, self.south, self.west]
end

#to_sObject



48
49
50
51
52
53
54
55
# File 'lib/minitest/game/location.rb', line 48

def to_s
  puts "You magically spawn to " + self.name + "."
  puts "'You have arrived at " + self.name + ". Hope you have enjoyed your Fast Travel experience!'"
  puts "North of you is " + self.north.name + " - " + self.north.description
  puts "East of you is " + self.east.name + " - " + self.east.description
  puts "South of you is " + self.south.name + " - " + self.south.description
  puts "West of you is " + self.west.name + " - " + self.west.description
end