-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMUD.rb
143 lines (105 loc) · 1.65 KB
/
MUD.rb
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
class Player
attr_accessor :actual_location
def initialize
@actual_location = ""
prison
end
def exit
end
def search
if @actual_location == "prison"
puts "Key!"
prison
else
puts "Nothing"
end
end
def prison
@actual_location = "prison"
puts "prison E"
direction = gets.chomp
if direction == "E"
hall
elsif direction == "exit"
exit
elsif direction == "search"
search
prison
else
puts "Wrong direction"
prison
end
end
def hall
@actual_location = "hall"
puts "Hall N S W E"
direction = gets.chomp
if direction == "N"
garden
elsif direction == "S"
dead_end
elsif direction == "W"
prison
elsif direction == "E"
gallery
elsif direction == "exit"
exit
elsif direction == "search"
search
hall
else
puts "wrong direction"
hall
end
end
def garden
@actual_location = "garden"
puts"garden S"
direction = gets.chomp
if direction == "S"
hall
elsif direction == "exit"
exit
elsif direction == "search"
search
garden
else
puts "wrong direction"
garden
end
end
def gallery
@actual_location = "gallery"
puts"gallery N"
direction = gets.chomp
if direction == "N"
garden
elsif direction == "search"
search
gallery
elsif direction == "exit"
exit
else
gallery
end
end
def dead_end
@actual_position = "dead end"
puts "dead end N"
direction = gets.chomp
if direction == "N"
hall
elsif direction == "exit"
exit
elsif direction == "search"
search
dead_end
else
dead_end
end
end
def exit
puts "game over"
end
end
Player.new