-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgame.rb
More file actions
86 lines (72 loc) · 1.92 KB
/
game.rb
File metadata and controls
86 lines (72 loc) · 1.92 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
def prompt()
print "> "
end
def gold_room()
puts "This room is full of gold. How much do you take?"
prompt; next_move = gets.chomp
unless next_move =~ /\D/
how_much = next_move.to_i()
else
dead("Man, learn to type a number.")
end
if how_much < 50
puts "Nice, you're not greedy, you win!"
Process.exit(0)
else
dead("You greedy bastard!")
end
end
def bear_room()
puts "There is a bear here."
puts "The bear has a bunch of honey."
puts "The fat bear is in front of another door."
puts "How are you going to move the bear?"
puts '"take honey" or "taunt bear"?'
bear_moved = false
while true
prompt; next_move = gets.chomp
if next_move == "take honey"
dead ("The bear looks at you then slaps your face off.")
elsif next_move == "taunt bear" and not bear_moved
puts 'The bear has moved from the door. You can go trough it now. "open door"'
bear_moved = true
elsif next_move == "taunt bear" and bear_moved
dead("The baear gets pissed off and chews your leg off.")
elsif next_move == "open door" and bear_moved
gold_room()
else
puts "I got no idea what that means."
end
end
end
def cthulu_room()
puts "Here you see the great evil Cthulu."
puts "He, it, whatever stares at you and you go insane."
puts "Do you flee for you life or eat your head?"
prompt; next_move = gets.chomp
if next_move.include? "flee"
start()
elsif next_move.include? "head"
dead("Well that was tasty!")
else
cthulu_room()
end
end
def dead(why)
puts "#{why} Good job!"
Process.exit(0)
end
def start()
puts "You are in a dark room."
puts "There is a door to your right and left."
puts "Which one do you take?"
prompt; next_move = gets.chomp
if next_move == "left"
bear_room()
elsif next_move == "right"
cthulu_room()
else
dead ("You stuble around the room until you starve.")
end
end
start()