-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
551 lines (505 loc) · 15.9 KB
/
script.js
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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
//
// NOTES:
// Optimize by breaking down into if functions, similar to the pictures.
//
// CURRENT BUGS:
//
//
//Beento Variables
beentobedroom = true;
beentobathroom = false;
beenoutsidemroom = false;
beentowindow = false;
//
//Search Variable
searchtable = false;
searchwoman = false;
//
//Current Room
currentroom = "bedroom";
//
//Eating
eatwoman = false;
//
//Inventory
gun = false;
wallet = false;
jacket = false;
matches = false;
brush = false;
bible = false;
pen = false;
key = false;
bike = false;
chinesefood = false;
woman = false;
takewoman = false;
//
//
$(document).ready(function() {
$("#console").fadeIn(3000);
$("#message_start").fadeIn(3000);
// $("#area_bedroom").fadeIn(3000);
// $("#command_line").fadeIn(3000);
// When button is clicked, stores HTML value attribute in input
$("button").click(function() {
var input = $(this).val();
$("#start").fadeOut(500);
//
//help
if (input.indexOf("help") > -1) {
if (input == "help") {
$("#message_help").clone().insertBefore("#placeholder").fadeIn(1000);
}
}
//end help
//
//
//start
if (input.indexOf("start") > -1) {
if (input == "start") {
$("#area_bedroom").clone().insertBefore("#placeholder").fadeIn(1000);
$("#choice_menu").fadeIn(3000);
}
}
//end start
//
//
// take
else if (input.indexOf("take") > -1 || input.indexOf("read") > -1) {
if (input == "take") {
$('<p>Take what? Be specific. Type "help" for a list of all commands.</p>').insertBefore("#placeholder").fadeIn(1000);
}
//gun
else if (input == "take gun") {
if (currentroom == "bedroom" && gun == false) {
gun = true;
$('<p>You picked up the gun. It is a 9mm with 15 rounds in its chamber. Hmm. You might need this for later so you tuck it beneath your belt.</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//
// wallet
else if (input == "take wallet") {
if (currentroom == "bedroom" && wallet == false) {
wallet = true;
$('<p>You picked up the wallet and placed it into your pocket.</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//
// jacket
else if (input == "take jacket") {
if (currentroom == "bedroom" && jacket == false) {
jacket = true;
matches = true;
$('<p>You picked up and put on the jacket. Inside the pockets, you find matches. Cool!</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//
// chinese take out
else if (input == "take chinese take out" || input == "take chinese food" || input == "take chinese takeout"){
if (currentroom == "bedroom" && chinesefood == false){
chinesefood = true;
$('<p>You picked up the Chinese take out. Hmmm. It still seems to be good!</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//
// woman
else if (input == "take woman" || input == "take girl"){
if (currentroom == "bedroom" && takewoman == false){
takewoman = true;
$('<p>You attempt to pick up the unconscious woman. Sadly, she\'s heavier than she looks. So you leave her be.</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>Stop trying to pick her up! She\'s too heavy!</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//
// brush
else if (input == "take brush" || input == "take tooth brush" || input == "take toothbrush") {
if (currentroom == "bathroom" && brush == false) {
brush = true;
$('<p>You pick up the brush and brush your teeth. <br />Brush . . . <br /> Brush . . . <br /> Brush . . . <br /> All Clean!</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//
else {
$('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);
}
//*
// pen
/*
else if (input == "take pen") {
if (currentroom == "bedroom" && pen == false) {
pen = true;
$('<p>You pick up the pen and put it in your pocket.</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//
else {
$('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);
}
//
// Bible
else if (input == "take bible") {
if (currentroom == "bedroom" && bible == false) {
bible = true;
$('<p>You pick up the Bible. A key falls out into the drawer. You place the Bible into your pocket.</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//
else {
$('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);
}
//
// key
else if (input == "take key") {
if (currentroom == "bedroom" && key == false) {
key = true;
$('<p>The key appears to be covered in dry blood. Maybe it will be useful later. You pocket it.</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>That item is not here!</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//
else {
$('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);
}
*/
}
//
//end take
//
//
//inventory
else if (input.indexOf("inventory") > -1) {
if (input == "inventory") {
// gun
if (gun == true) {
g_wep = "Gun<br />";
}
else {
g_wep = "";
}
//
// wallet
if (wallet == true) {
wal = "Wallet<br />";
}
else {
wal = "";
}
//
// jacket
if (jacket == true) {
jack = "Jacket<br />";
}
else {
jack = "";
}
//
// matches
if (matches == true) {
match = "Matches<br />";
}
else {
match = "";
}
//bible
if (bible == true) {
bib = "Bible<br />";
}
else {
bib = "";
}
//
//key
if (key == true) {
ky = "Key<br />";
}
else {
ky = "";
}
//
//pen
if (pen == true) {
pn = "Pen<br />";
}
else {
pn = "";
}
//
//chinese food
if (chinesefood == true) {
cf = "Chinese Takeout<br / >";
}
else {
cf = "";
}
//
// printing message
if (g_wep == "" && wal == "" && jack == "" && match == "" && bib == "" && ky == "" && pn == "" && cf == "") {
$('<p>Inventory:<br /><i>There is nothing in your inventory</i></p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>Inventory:<br />' + g_wep + wal + jack + match + bib + ky + pn + cf + '</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
else $('<p>I don\'t understand "' + input + '"</p>').insertBefore("#placeholder").fadeIn(1000);
}
//end inventory
//
//
//eat
else if (input.indexOf("eat") > -1) {
if (input == "eat") {
$('<p>Eat what? Be specific. Type "help" for a list of all commands.</p>').insertBefore("#placeholder").fadeIn(1000);
}
//Chinese Takeout
else if (input == "eat chinese take out" || input == "eat chinese food" || input == "eat chinese takeout") {
if (chinesefood == true) {
$('<p>Omnomnomnom... Yum! You are now full and reek of Chinese take out.</p>').insertBefore("#placeholder").fadeIn(1000);
chinesefood = "ate";
}
else {
$('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//woman
else if (input == "eat woman" || input == "eat girl"){
if (currentroom == "bedroom" && eatwoman == false) {
$('<p>WHAT ARE YOU DOING? Do not be a cannibal! Leave the poor woman alone.</p>').insertBefore("#placeholder").fadeIn(1000);
eatwoman = true;
}
else {
$('<p>Stop trying to eat her!</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
}
//end eat
//
//
//go
else if (input.indexOf("go") > -1) {
if (input == "go") {
$('<p>Go in which direction?</p>').insertBefore("#placeholder").fadeIn(1000);
}
//go from bedroom
else if (input == "go west" && currentroom == "bedroom") {
if (beentobathroom == true) {
if (brush == false) {
tbrush = " The brush still sits on the edge of the sink.";
}
else {
tbrush = "";
}
$('<p>You are back in the bathroom. To the left there is a bathtub. On the right there is a sink and toilet. ' + tbrush + '</p>').insertBefore("#placeholder").fadeIn(3000);
currentroom = "bathroom";
beentobathroom = true;
}
else {
$("#area_bathroom").clone().insertBefore("#placeholder").fadeIn(3000);
currentroom = "bathroom";
beentobathroom = true;
}
}
//
//bathroom to bedroom
else if (input == "go east" && currentroom == "bathroom") {
if (beentobedroom == true) {
if(gun == false) {
bedgun = " The gun is still on the bedside table.";
} else {
bedgun = "";
}
if(wallet == false) {
bedwal = " The wallet is still on the bedside table.";
} else {
bedwal = "";
}
if(jacket == false) {
bedjack = " The jacket is still on the chair.";
} else {
bedjack = "";
}
$('<p>You are back in the bedroom. To the east is the door. To the west is the bathroom.' + bedgun + bedwal + bedjack + '</p>').insertBefore("#placeholder").fadeIn(3000);
currentroom = "bedroom";
}
else {
$("#area_bedroom").clone().insertBefore("#placeholder").fadeIn(3000);
currentroom = "bedroom";
beentobedroom = true;
}
}
// step outside room
else if (input == "go east" || input == "go outside" && currentroom == "bedroom") {
if (beenoutsidemroom == false && gun == true) {
$("#container").fadeOut(3000, function() {
$("#doorlock").fadeIn(3000);
});
}
// else if (beenoutsidemroom == false) {
// if (bike == false) {
// mbike = " A motorcycle sits near by.";
// }
// else {
// mbike = "";
// }
// $('<p>You step outside of your motel room. The fresh cold air greets your face. You look around.' + mbike + '</p>').insertBefore("#placeholder").fadeIn(3000);
// currentroom = "outside_room";
// beenoutsidemroom = true;
// }
else {
$("#area_outsideroom").clone().insertBefore("#placeholder").fadeIn(3000);
currentroom = "outside_room";
beenoutsidemroom = true;
}
}
//
//outside to bedroom
else if (input == "go west" && currentroom == "outside_room") {
if (beentobedroom == true) {
if(gun == false) {
bedgun = " The gun is still on the bedside table.";
} else {
bedgun = "";
}
if(wallet == false) {
bedwal = " The wallet is still on the bedside table.";
} else {
bedwal = "";
}
if(jacket == false) {
bedjack = " The jacket is still on the chair.";
} else {
bedjack = "";
}
$('<p>You are back in the bedroom. To the east is the door. To the west is the bathroom.' + bedgun + bedwal + bedjack + '</p>').insertBefore("#placeholder").fadeIn(3000);
currentroom = "bedroom";
}
else {
$("#area_bedroom").clone().insertBefore("#placeholder").fadeIn(3000);
currentroom = "bedroom";
beentobedroom = true;
}
}
//
//
//outside the window
// else if (input == "go north" && currentroom == "bedroom") {
// if (gun == true) {
// popo = "You hear the front door bust open through the window, the chief of police yelling at his officers to search the area. You should probably get moving!";
// }
// else {
// popo = "";
// }
// $('<p>You crawl out the window of your motel room. The fresh cold air greets your face. You look around.' + popo + '</p>').insertBefore("#placeholder").fadeIn(3000);
// currentroom = "outside_window";
// beentowindow = true;
// }
else {
$('<p>You can\'t go there.</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//
//
//
//search
else if (input.indexOf("search") > -1) {
if (input == "search") {
$('<p>Search what? Be specific. Type "help" for a list of all commands.</p>').insertBefore("#placeholder").fadeIn(1000);
}
//table
else if (input == "search table" || input == "search bedside table" || input == "search bed side table") {
if (currentroom == "bedroom" && searchtable == false) {
searchtable = true;
$('<p>There is a pen and Bible in the table.</p>').insertBefore("#placeholder").fadeIn(1000);
}
else $('<p>There is nothing to search for.</p>').insertBefore("#placeholder").fadeIn(1000);
}
//
//woman
else if (input == "search woman" || input == "search girl") {
if (currentroom == "bedroom" && searchwoman == false) {
searchwoman = true;
$('<p>There is nothing on her but you cop a feel.</p>').insertBefore("#placeholder").fadeIn(1000);
}
else $('<p>Bro. What are you doing. Stop touching her, you pervert! Get moving!</p>').insertBefore("#placeholder").fadeIn(1000);
}
//
else $('<p>There is nothing to search for.</p>').insertBefore("#placeholder").fadeIn(1000);
}
//end search
//
//
//kill
else if (input.indexOf("kill") > -1) {
if (input == "kill") {
$('<p>Kill what with what? Be specific. Type "help" for a list of all commands.</p>').insertBefore("#placeholder").fadeIn(1000);
}
else if (input == "kill woman" || input == "kill girl" && currentroom == "bedroom") {
$('<p>Kill woman with what?</p>').insertBefore("#placeholder").fadeIn(1000);
}
//woman
else if (input == "kill woman with gun" || input == "kill whore with gun" || input == "kill girl with gun") {
if (currentroom == "bedroom" && gun == true) {
$('<p>WHAT ARE YOU DOING? <br />Why would you want to kill some random woman that you woke up beside? Stop it!</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
else if (input == "kill woman with pen" || input == "kill whore with pen" || input == "kill girl with pen") {
if (currentroom == "bedroom" && pen == true) {
$('<p>WHAT ARE YOU DOING? <br />Why would you want to kill some random woman that you woke up beside? Stop it!</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
else if (input == "kill woman with bible" || input == "kill whore with bible" || input == "kill girl with bible") {
if (currentroom == "bedroom" && pen == true) {
$('<p>JEZZ. WHAT ON EARTH ARE YOU DOING? <br />Why would you want to kill some random woman that you woke up beside? <br />You should be reading the Bible to yourself!</p>').insertBefore("#placeholder").fadeIn(1000);
}
else {
$('<p>You can\'t do that.</p>').insertBefore("#placeholder").fadeIn(1000);
}
}
//
else $('<p>You can\'t do that!</p>').insertBefore("#placeholder").fadeIn(1000);
}
//end kill
//
//
// don't understand
else if (check == false) {
$("<p>I do not understand " + input + ".</p>").hide().insertBefore("#placeholder").fadeIn(1000);
}
// don't understand
//
//reset text box
$("#console").scrollTop($("#console")[0].scrollHeight);
$("#command_line").val("");
});
});