-
Notifications
You must be signed in to change notification settings - Fork 0
/
text_game_guan_jeremy.rb
337 lines (325 loc) · 10.8 KB
/
text_game_guan_jeremy.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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
health = 100
money = 50
inventory = []
system('clear')
# ascii art func
def render_ascii_art(art)
File.readlines("./ascii_samp/#{art}.txt") do |line|
line
end
end
puts render_ascii_art 'title'
puts 'Welcome, what is your name?'
print '=> '
player_name = gets.chomp
puts ' '
# This will repeat until the player picks a skill, with a number choice.
selected = false
while !selected do
puts "Hello, #{player_name} you have the choice of skills, what would you like to pick? Please pick a number."
puts ''
puts '(1) Strength'
puts '(2) Speed'
puts '(3) Charisma'
puts '(4) Luck'
puts ''
skill_choices = ['Strength', 'Speed', 'Charisma', 'Luck']
print '=> '
skill = gets.chomp.to_i
if(skill == 1 || skill == 2 || skill == 3 || skill == 4)
selected = true
end
end
player_skill = skill_choices[skill-1]
puts "Congrats, you are now blessed with the natural advantage of #{player_skill}"
puts ''
print '=> '
puts 'Press enter to continue'
_wait = gets
system('clear')
# ********************************************************************************************#
# Bear Attack sequence
# ********************************************************************************************#
selected = false
while !selected do
puts render_ascii_art('bear')
puts 'You are running around in the forest and faced with a large bear that is very hungry'
puts ''
puts 'What would you like to do?'
puts '(1) Run'
puts '(2) Fight'
puts ''
print '=> '
choice = gets.chomp.to_i
if(choice == 1 || choice == 2)
selected = true
end
end
if(choice == 1 && player_skill == 'Speed')
puts 'You have out ran the bear by running in a zig zag path'
puts ''
elsif(choice == 1)
puts 'You tried to run and the bear scratched your leg, you lost 10hp'
puts ''
health -= 10
puts "#{player_name}'s health is now at #{health}"
puts ''
elsif(choice == 2 && player_skill == 'Strength')
puts 'You gathered all your might, found a strong branch and fought off the bear'
puts ''
elsif(choice == 2)
puts 'Bad choice, the bear is too strong, you lose 15 hp'
puts ''
health -= 15
puts "#{player_name}'s health is now at #{health}"
puts ''
end
puts ''
puts 'Press enter to continue'
print '=> '
_wait = gets
system('clear')
# ********************************************************************************************#
# Town Sequence
# ********************************************************************************************#
# Choice between store or bakery
selected = false
while !selected do
puts render_ascii_art('shops')
puts 'You found the nearest town you see a store, and a bakery'
puts ''
puts 'What would you like to do?'
puts '(1) Go to store'
puts '(2) Find some food at the bakery?'
puts '(3) Leave Town'
puts ''
print '=> '
choice = gets.chomp.to_i
if(choice == 1 || choice == 2 || choice == 3)
selected = true
end
end
selected = false
while !selected do
# If store choosen
if(choice == 1)
puts render_ascii_art('potion')
puts "You have Ɖ#{money} and you buy a (1) Ɖ10 - health potion, (2) Ɖ24 - Steel Plated Armor"
puts ''
print '=> '
choice = gets.chomp.to_i
# if player has Charisma
if(choice == 1 || choice == 2 && player_skill == 'Charisma')
selected = true
puts 'You told the story about the bear attacking you and the merchant felt sorry and is willing to gave you a discount'
puts ''
if(choice == 1)
puts 'You bought the potion for Ɖ8'
puts ''
money -= 8
inventory << "Health Potion(15hp)"
puts ''
puts "You have Ɖ#{money}"
puts ''
puts "Current inventory : #{inventory}"
puts ''
elsif(choice == 2)
puts 'You bought the Steel Plated Armor for Ɖ18'
puts ''
money -= 18
inventory << "Steel Plated Armor"
puts "You have Ɖ#{money}"
puts ''
puts "Current inventory : #{inventory}"
puts ''
end
# if player does not have Charisma
elsif(choice == 1 || choice == 2)
selected = true
if(choice == 1)
puts 'You bought the potion for Ɖ10'
puts ''
money -= 10
inventory << "Health Potion(15hp)"
puts "You have Ɖ#{money}"
puts ''
puts "Current inventory : #{inventory}"
puts ''
elsif(choice == 2)
puts 'You bought the Steel Plated Armor for Ɖ24'
puts ''
money -= 24
inventory << "Steel Plated Armor"
puts "You have Ɖ#{money}"
puts ''
puts "Current inventory : #{inventory}"
puts ''
end
end
# If bakery choosen
elsif(choice == 2)
puts render_ascii_art('burger')
puts "You have Ɖ#{money} and you can buy:"
puts '(1) Ɖ9 - Beef Sandwich'
puts '(2) Ɖ7 - Chicken Sandwich'
puts ''
print '=> '
choice = gets.chomp.to_i
# if player has Luck
if(choice == 1 || choice == 2 && player_skill == 'Luck')
selected = true
puts 'You told the story about the bear attacking you and baker felt sorry and gave you a free meal'
puts ''
if(choice == 1)
puts 'You ate the beef sandwich and restored 8 hp'
puts ''
health = health + 8
puts "You have #{health} health"
puts ''
elsif(choice == 2)
puts 'You ate the chicken sandwich and restored 7 hp'
puts ''
health = health + 7
puts "You have #{health} health"
puts ''
end
# if player does not have Luck
elsif(choice == 1 || choice == 2)
selected = true
if(choice == 1)
puts 'You bought the beef sandwich for Ɖ9'
puts ''
money -= 9
puts 'You ate the beef sandwich and restored 8 hp'
puts ''
health += 8
puts "You have #{health} health"
puts ''
elsif(choice == 2)
puts 'You bought the chicken sandwich for D7'
puts ''
money -= 7
puts 'You ate the chicken sandwich and retored 7 hp'
puts ''
health += 7
puts "You have #{health} health"
puts ''
end
end
elsif(choice == 3)
puts "You are leaving town with #{health} health, #{money} doge, #{inventory} in the inventory"
selected = true
end
end
puts ''
puts 'Press enter to continue'
print '=> '
_wait = gets
system('clear')
# ********************************************************************************************#
# Troll Sequence
# ********************************************************************************************#
selected = false
while !selected do
puts render_ascii_art('troll')
puts 'You are leaving town, and a giant Troll is blocking your path and is asking for Ɖ14'
puts ''
puts '(1) Speak with troll'
puts '(2) Fight Troll'
puts '(3) Run away'
puts ''
print '=> '
choice = gets.chomp.to_i
if(choice == 1 || choice == 2 || choice ==3 )
selected = true
end
end
if(choice == 1 && player_skill == 'Charisma')
puts 'You have out smarted the Troll in a game of wit and he decided to let you pass'
puts ''
elsif(choice == 1)
puts 'The Giant Troll requires a toll, you must pay Ɖ14'
puts ''
money -= 14
puts "#{player_name}'s doge is now at #{money}"
puts ''
elsif(choice == 2 && player_skill == 'Strength' && inventory.include?("Steel Plated Armor"))
puts 'With the steel plate armor you just bought, you decided to fight the troll and successfully defeated him, However you lost 10 hp'
puts ''
health -= 10
puts "#{player_name}'s health is now at #{health}"
elsif(choice == 2 && player_skill == 'Strength')
puts 'It was a tough fight, the troll gave up after a long battle, you came out with scars and bruises, you lost 18 hp'
puts ''
health -= 18
puts "#{player_name}'s health is now at #{health}"
puts ''
elsif(choice == 2)
puts 'You and the troll fought, you lost 24 hp, the troll felt bad and left you alone'
puts ''
health -= 24
puts "#{player_name}'s health is now at #{health}"
puts ''
elsif(choice == 3 && player_skill == 'Speed')
puts 'You out ran the troll and got away with out paying'
puts ''
elsif(choice == 3)
puts 'You tried to run, but the troll caught up and forced you to pay the toll plus Ɖ10'
puts ''
money -= 24
puts "#{player_name}'s doge is now at Ɖ#{money}"
puts ''
end
puts ''
puts 'Press enter to continue'
print '=> '
_wait = gets
system('clear')
# ********************************************************************************************#
# Magic Home Builder
# ********************************************************************************************#
selected = false
while !selected do
puts 'You met the best home builder in the area, and he can build you your dream home.'
puts ''
puts "You have #{money} doge"
puts ''
puts 'He give you three options:'
puts ''
puts render_ascii_art('cabin')
puts '(1) One story cabin for Ɖ20'
sleep 2
puts ''
puts render_ascii_art('mansion')
puts '(2) Two story mansion in the woods for Ɖ32'
sleep 2
puts ''
puts render_ascii_art('castle')
puts '(3) A massive castle for Ɖ49'
puts ''
print '=> '
choice = gets.chomp.to_i
if(choice == 1 || choice == 2 || choice == 3)
selected = true
end
if(choice == 1 && money > 20)
puts 'The builder took your doge and started building your cabin. One week he magically finshed and you moved in.'
money -= 20
puts ''
puts "You have #{money} doge left"
puts ''
elsif(choice == 2 && money >= 32)
puts 'The builder took your doge and started building your mansion. Two weeks later, he magically finished your home and your started moving in.'
money -= 32
puts ''
puts "You have #{money} doge left"
puts ''
elsif(choice == 3 && money >= 49)
puts "The builder took 49 doge and He said thank you King. And magically the castle appeared out of thin air."
money -= 49
puts ''
puts "You have #{money} doge left"
puts ''
end
end
p 'You have a home now, live it up, THE END'