-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroom.rb
More file actions
70 lines (59 loc) · 1.19 KB
/
Copy pathroom.rb
File metadata and controls
70 lines (59 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class Room
attr_accessor :title,:is_teleport_room
def initialize(title, north, east, south, west ,is_teleport_room)
@title=title
@paths = [north,east,south,west]
if(is_teleport_room=="0")
@is_teleport_room = false
else
@is_teleport_room = true
end
end
# Accessor Methods for Paths
def north
@paths[0]
end
def east
@paths[1]
end
def south
@paths[2]
end
def west
@paths[3]
end
def return_title(string)
case string
when "north"
@paths[0]
when "east"
@paths[1]
when "south"
@paths[2]
when "west"
@paths[3]
end
end
##############################
def return_adjacent_rooms
returnArray =Array.new
counter =0
if(@paths[0]!="0")
returnArray[counter]="north"
counter = counter +1
end
if(@paths[1]!="0")
returnArray[counter]="east"
counter = counter +1
end
if(@paths[2]!="0")
returnArray[counter]="south"
counter = counter +1
end
if(@paths[3]!="0")
returnArray[counter]="west"
counter = counter +1
end
return returnArray
end
end