generated from learn-academy-2024-alpha/text-based-game
-
Notifications
You must be signed in to change notification settings - Fork 1
/
challenge.rb
108 lines (86 loc) · 4.12 KB
/
challenge.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
# Text-based Game Challenge
# CODE
puts 'Enter name'
user_name = gets.chomp
# TEXT
blink = "blink....\n"
eyes_opening = "Your eyes slowly open as the room comes into focus.\nYou've awakened on an operating table in a run down bunker medical bay, unsure of where or who you are.\n"
first_look = "You feel dizzy and your head is throbbing, the surgical light above you is flickering, you look around and see a medical tool station with bloody surgical tools,\n behind you is another medical bed with a person on it groaning.\n You slowly swing your legs off the table to stand up.\n"
first_choice = "What should I do first:\n 1. Check the other persons condition?\n 2. Check to see if the door is unlocked?\n Please enter input here: "
fc_option_one = "shake.. shake..
\n #{user_name}: 'Hey buddy, wake up!'\n *Nothing Happens*\n I need to find something to wake them up.\n Looking around I see a bed side table with two drawers, and a rusty medicine cabinet.\n\n What should I do:\n 1. Look in the bed side table?\n 2. Check out the rusty medicine cabinet?\n"
fc_o1_c1 = "1. Open the top drawer?\n"
fc_o1_c2 = "2. Open the bottom drawer?\n"
bed_side = "\n I move closer to the bed side table.\n Which drawer should I open first?\n #{fc_o1_c1} #{fc_o1_c2}"
medicine_cabinet = "\nI move closer to the rusty medicine cabinet\n I try to open the medicine cabinet"
fc_o2_c1 = "The medical cabinet is rusted shut, I need to find something to pry it open. Maybe I should check the bed side table.\n"
fc_o2_c2 = "The medical cabinet is rusted shut, but I can pry it open with the scalpel I found!\n POP!\n The medicine cabinets rusted metal door swung open revealing a glass jar labeled smelling salts with only one pouch left in it."
# - check door (locked)
# - check people (need to find medical)
# METHODS
def char_print_speed string, seconds
string.each_char do |char|
putc char
sleep(seconds)
end
end
# char_print_speed( ,0.1)
# sleep (0.5)
char_print_speed(blink, 0.1)
sleep (0.5)
char_print_speed(blink, 0.1)
sleep (0.5)
char_print_speed(eyes_opening, 0.09)
sleep (0.5)
char_print_speed(first_look, 0.09)
sleep (0.5)
loop do
char_print_speed(first_choice, 0.1)
first_choice_input = gets.chomp
if first_choice_input.include?('door') || first_choice_input.include?('2')
puts 'You reach for the handle and shake it and see that the door is locked'
break
elsif first_choice_input.include?('person') || first_choice_input.include?('1')
sleep(1)
puts "\n"
puts 'You walk up to the closest medical bed, and pull back the curtain to find a person unconscious'
break
else
puts 'Thats not a valid option, please choose from the provided options'
sleep(2)
end
end
loop do
puts 'here'
char_print_speed(fc_option_one, 0.1)
fc_option_one_input = gets.chomp
if fc_option_one_input.include?('table') || fc_option_one_input.include?('1')
"#{bed_side}"
loop do
char_print_speed(bed_side, 0.1)
which_drawer = gets.chomp
if which_drawer.include?('top') || which_drawer.include?('1')
char_print_speed("\n I pull open the top drawer, it sticks a little.\n Inside I find: a musty Bible, expired pills, and used bandages.\n Nothing in here is useful. I close the drawer.\n", 0.1)
sleep(1)
elsif which_drawer.include?('bottom') || which_drawer.include?('2')
char_print_speed("\nWith some effort I pull open the bottom drawer, inside I see:\n a scalpel and new bandages. Lets take the scapel and new bandages, they might be useful.\n", 0.1)
break
else
puts 'Thats not a valid option, please choose from the provided options'
sleep(2)
end
end
elsif fc_option_one_input.include?('medicine') || fc_option_one_input.include?('cabinet') || fc_option_one_input.include?('2')
"#{medicine_cabinet}"
loop do
char_print_speed(fc_option_one, 0.1)
if fc_option_one_input.include?('table') || fc_option_one_input.include?('1')
"#{fc_o2_c2}"
break
else
"#{fc_o2_c1}"
speed(2)
end
end
end
end