-
Notifications
You must be signed in to change notification settings - Fork 1
/
oregontrail.js
1554 lines (1421 loc) · 53.6 KB
/
oregontrail.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
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var root = js.exec_dir;
var server_file = new File(file_cfgname(root, "server.ini"));
server_file.open('r', true);
//var autoUpdate=server_file.iniGetValue(null,"autoUpdate");
var serverAddr = server_file.iniGetValue(null, "host", "localhost");
var serverPort = server_file.iniGetValue(null, "port", 10088);
server_file.close();
//The official and most updated version of this game can be found at
//https://github.com/chairmanmow/synchro_trail
load("sbbsdefs.js");
//somewhat faithfully version adapted by "larry lagomorph" from 1977 basic code @ http://deserthat.files.wordpress.com/2010/11/oregon1.doc (you can find traces of the BASIC left in this document)
//contact grudgemirror@gmail.com re:oregontrail with any bug reports (there probably are some i haven't found)
var version = "0.2.1b";
console.putmsg("\r\n\r\n\1y OREGON TRAIL \1wversion no " + version + "\r\n\r\n\1h\1cby Larry Lagomorph of Futureland BBS \1yvisit us @ futureland.grudgemirror.com\r\n");
console.putmsg("\r\n\r\n updated August 2014\r\n");
console.pause();
console.clear();
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min; //keep
}
load("json-client.js");
var db = new JSONClient(serverAddr, serverPort);
var highScores = db.read("TRAIL", "TRAIL.SCORES", 1);
db.cycle();
if (highScores == undefined) {
console.putmsg("Creating High Score File");
var blankArray = [];
db.write("TRAIL", "TRAIL.SCORES", blankArray, 2);
db.cycle();
}
highScores = db.read("TRAIL", "TRAIL.SCORES", 1);
db.cycle;
console.putmsg("\1g THESE SAVVY ADVENTURERS HAVE SAFELY ARRIVED IN OREGON CITY! \r\n\r\n");
function displayScores() {
if (highScores.length == 0) {
console.putmsg("\1h\1w No one has conquered the trail yet! Be the \1rfirst \1wname on the list!!! \r\n\r\n");
console.pause();
console.clear();
return;
} else {
var ct = 0;
for (i = 0; i < highScores.length; i++) {
var highScore = highScores[i];
console.putmsg("\1h\1y" + highScore["date"] + "\1w ---\1w " + highScore["name"] + "\1g traveled from \1w" + highScore["bbs"] + "\1g scoring \1w" + highScore["score"] + " \1gpoints!\r\n");
ct += 2;
}
console.pause();
console.clear();
return; // do not erase
}
}
displayScores();
var tombStones = db.read("TRAIL", "TRAIL.GRAVES", 1);
db.cycle();
if (tombStones == undefined) {
console.putmsg("Creating Grave File");
var blankArray = [];
db.write("TRAIL", "TRAIL.GRAVES", blankArray, 2);
db.cycle();
}
tombStones = db.read("TRAIL", "TRAIL.GRAVES", 1);
db.cycle();
tombStones = tombStones.reverse();
console.putmsg("\1h\1r THESE ARE THE MOST RECENT TRAVELERS TO PERISH ON THE TRAIL \r\n\1w \1h\1y\1i***\1w\1n[\1h\R.I.P.\1n]\1h\1y\1i***\r\n");
function displayGraves() {
var rowsMinusOne = console.screen_rows - 4;
var ct = 0;
for (i = 0; i < tombStones.length && ct < rowsMinusOne; i++) {
var tombStone = tombStones[i];
console.putmsg("\1h\1b" + tombStone["date"] + "\1n\1w**\1h" + tombStone["name"] + " \1n\1w" + tombStone["cause"] + "\1c,\1h\1w " + tombStone["score"] + "\1n miles from \1h\1w" + tombStone["bbs"] + "\r\n");
console.putmsg("\1h\1y-\1c" + tombStone["engraving"] + "\r\n");
ct += 2;
}
return; // do not erase
}
displayGraves();
console.pause();
console.clear();
// game start
function OregonTrail() {
function Score() {
return totalMileage + animalsAMT + foodAMT + clothingAMT + supplyAMT; //do not erase
}
var yesNo = new String;
var choiceShootingExptLvl = new Number;
var animalsAMT = new Number;
var foodAMT = new Number;
var ammoAMT = new Number;
var clothingAMT = new Number;
var supplyAMT = new Number;
var flagForFortOption = new Number;
var cashInitialPurchase = new Number;
var totalMileage = new Number;
var turnNumber = new Number;
var woundedFlag = new Number;
var southPassFlag = 0;
var blueMountainPassFlag = 0;
var mileSouthPassFlag = new Number;
var actionChoice = new Number;
var choiceEat = new Number;
var bangResponse = new Number;
var blizzardFlag = new Number;
var notEnoughClothes = new Number;
var fortAMT = new Number;
var eventNo = 0;
var blizzardFlag = 0;
var notEnoughClothes = 0;
var tacticChoice = 0;
var riderHostilityFactor = 0;
var deadFlag = 0;
var illnessFlag = 0;
var causeOfDeath = "";
var outOfAmmoToggle = new Boolean;
var userSelection = "0";
while (userSelection != "1") {
userSelection = firstPrompt();
}
rifleSkills(); // finds out what your shooting level is
initialPurchase();
firstTurn();
function firstPrompt() {
console.putmsg("\r\n\r\n1 - Play \r\n2 - Instructions\r\n3 - Quit\r\n");
yesNo = console.getstr();
yesNo = yesNo.toUpperCase();
if (yesNo == "2") {
instructions();
}
if (yesNo == "3") {
throw "gameOver";
// return
}
return yesNo;
}
function instructions() {
console.crlf();
console.crlf();
// ***INSTRUCTIONS***
console.putmsg("\r\n\1hTHIS PROGRAM SIMULATES A TRIP OVER THE OREGON TRAIL FROM");
console.putmsg("\r\n\1hINDEPENDENCE MISSOURI TO OREGON CITY, OREGON IN 1847.");
console.putmsg("\r\n\1hYOUR FAMILY OF FIVE WILL COVER THE 2040 MILE OREGONTRAIL");
console.putmsg("\r\n\1hIN 5-6 MONTHS --- IF YOU MAKE IT ALIVE.");
console.putmsg("\r\n\1hYOU HAD SAVED \1g$900 \1wTO SPEND FOR THE TRIP, AND YOU'VE JUST");
console.putmsg("\r\n\1h PAID \1r$200 FOR A WAGON.");
console.putmsg("\r\n\1hYOU WILL NEED TO SPEND THE REST OF YOUR MONEY (\1g$700\1w) ON THE");
console.putmsg("\r\n\1h FOLLOWING ITEMS:");
console.crlf();
console.putmsg("\r\n\1h \1gOXEN \1y*** \1wYOU CAN SPEND \1g$200-$300 \1wON YOUR TEAM");
console.putmsg("\r\n\1h THE MORE YOU SPEND, THE FASTER YOU'LL GO");
console.putmsg("\r\n\1h BECAUSE YOU'LL HAVE BETTER ANIMALS");
console.crlf();
console.putmsg("\r\n\1h FOOD\1y *** \1wTHE MORE YOU HAVE, THE LESS CHANCE THERE");
console.putmsg("\r\n\1h IS OF GETTING SICK");
console.crlf();
console.putmsg("\r\n\1h \1rAMMUNITION\1y *** \1g$1 \1wBUYS A BELT OF \1r50 BULLETS");
console.putmsg("\r\n\1h YOU WILL NEED BULLETS FOR ATTACKS BY \1yANIMALS");
console.putmsg("\r\n\1h AND \1rBANDITS, \1wAND FOR HUNTING \1nFOOD");
console.crlf();
console.putmsg("\r\n\1h \1cCLOTHING\1y *** \1wTHIS IS ESPECIALLY IMPORTANT FOR THE COLD");
console.putmsg("\r\n\1h WEATHER YOU WILL ENCOUNTER WHEN CROSSING");
console.putmsg("\r\n\1h THE MOUNTAINS");
console.crlf();
console.putmsg("\r\n\1h \1yMISCELLANEOUS SUPPLIES\1r *** \1wTHIS INCLUDES MEDICINE AND");
console.putmsg("\r\n\1h OTHER THINGS YOU WILL NEED FOR SICKNESS");
console.putmsg("\r\n\1h AND EMERGENCY REPAIRS");
console.crlf();
console.crlf();
console.putmsg("\r\n\1hYOU CAN SPEND ALL YOUR \1gMONEY\1w BEFORE YOU START YOUR TRIP -");
console.putmsg("\r\n\1hOR YOU CAN SAVE SOME OF YOUR \1gCASH\1w TO \1mSPEND AT FORTS \1wALONG");
console.putmsg("\r\n\1hTHE WAY WHEN YOU RUN LOW. HOWEVER, ITEMS COST MORE AT");
console.putmsg("\r\n\1hTHE FORTS. YOU CAN ALSO GO \1rHUNTING\1w ALONG THE WAY TO GET");
console.putmsg("\r\n\1hMORE \1nFOOD.");
console.crlf();
console.putmsg("\r\n\1hWHENEVER YOU HAVE TO USE YOUR TRUSTY RIFLE ALONG THE WAY,");
console.putmsg("\r\n\1hYOU WILL BE TOLD TO TYPE IN A WORD \1c(\1yONE THAT SOUNDS LIKE A");
console.putmsg("\r\n\1h\1yGUN SHOT\1c)\1w. \1mTHE FASTER YOU TYPE IN \1cTHAT WORD\1m AND HIT THE");
console.putmsg("\r\n\1h\1r\1i**ENTER**\1n\1h\1m KEY, \1yTHE BETTER LUCK YOU'LL HAVE WITH YOUR GUN.");
console.crlf();
console.putmsg("\r\n\1hAT EACH TURN, \1gALL ITEMS ARE SHOWN IN DOLLAR AMOUNTS");
console.putmsg("\r\n\1h\1rEXCEPT BULLETS");
console.putmsg("\r\n\1hWHEN ASKED TO ENTER MONEY AMOUNTS, \1n\1rDON'T USE A **$**.");
console.crlf();
console.putmsg("\r\n\1h\1g\1iGOOD LUCK!!!\1n");
}
function rifleSkills() {
console.crlf();
console.crlf();
console.putmsg("\1h\1mHOW GOOD A SHOT ARE YOU WITH YOUR RIFLE?\r\n");
console.putmsg("\1h\1y(1) \1wACE MARKSMAN, \1y(2) \1wGOOD SHOT, \1y(3)\1w FAIR TO MIDDLIN'");
console.putmsg("\r\n\1h\1y(4) \1wNEED MORE PRACTICE, \1y(5) \1wSHAKY KNEES");
console.crlf();
console.putmsg("\r\n\1h\1cENTER ONE OF THE ABOVE,THE BETTER YOU CLAIM YOU ARE, THE\r\n");
console.putmsg("\1h\1cFASTER YOU'LL HAVE TO BE WITH YOUR GUN TO BE SUCCESSFUL.");
choiceShootingExptLvl = console.getnum();
//if(choiceShootingExptLvl != 5) { // unsure about this expression taken from basic
//choiceShootingExptLvl = 0;
if (1 > choiceShootingExptLvl || choiceShootingExptLvl > 5) {
console.putmsg("\r\n\1r\1i[Invalid Selection]");
rifleSkills();
}
}
function getAnimals() {
console.putmsg("\1h\1mHOW MUCH DO YOU WANT TO SPEND ON YOUR OXEN TEAM\r\n \1y minimum : 201 \r\n");
animalsAMT = console.getnum();
while (300 <= animalsAMT || animalsAMT <= 200) {
if (animalsAMT <= 200) {
console.putmsg("NOT ENOUGH");
}
if (animalsAMT >= 300) {
console.putmsg("TOO MUCH");
}
animalsAMT = console.getnum();
}
}
function getFood() {
console.putmsg("\1h\1wHOW MUCH DO YOU WANT TO SPEND ON FOOD");
foodAMT = console.getnum();
while (foodAMT <= 0) {
console.putmsg("IMPOSSIBLE");
foodAMT = console.getnum();
}
}
function getAmmo() {
console.putmsg("\1h\1rHOW MUCH DO YOU WANT TO SPEND ON AMMUNITION");
ammoAMT = console.getnum();
while (ammoAMT <= 0) {
console.putmsg("IMPOSSIBLE");
ammoAMT = console.getnum();
}
}
function getClothing() {
console.putmsg("\1h\1bHOW MUCH DO YOU WANT TO SPEND ON CLOTHING");
clothingAMT = console.getnum();
while (clothingAMT <= 0) {
console.putmsg("IMPOSSIBLE");
clothingAMT = console.getnum();
}
}
function getSupplies() {
console.putmsg("\1h\1yHOW MUCH DO YOU WANT TO SPEND ON MISCELLANEOUS SUPPLIES");
supplyAMT = console.getnum();
while (supplyAMT <= 0) {
console.putmsg("IMPOSSIBLE");
supplyAMT = console.getnum();
}
}
function initialPurchase() {
flagForFortOption = flagForFortOption * -1; // WTF IS THIS? -- switch from true to false whether or not you have to go to the fort
//woundedFlag*illnessFlag*southPassFlag*blueMountainPassFlag*M*mileSouthPassFlag*turnNumber=0; // WTF IS THISg removed as its probably some legacy basic code for clearing memory in old cpus
anotherPurchase();
}
function anotherPurchase() {
console.crlf();
getAnimals();
getFood();
getAmmo();
getClothing();
getSupplies();
calculateCosts();
}
function calculateCosts() {
cashInitialPurchase = 700 - animalsAMT - foodAMT - ammoAMT - clothingAMT - supplyAMT;
if (cashInitialPurchase <= 0) {
console.putmsg("\r\n\1h\1r\1iYOU OVERSPENT! \r\n\1n\1h\1yYOU ONLY HAD $700 TO SPEND. BUY AGAIN");
initialPurchase();
}
else {
ammoAMT *= 50;
console.putmsg("\1h\1gAFTER ALL YOUR PURCHASES, YOU NOW HAVE \1r" + cashInitialPurchase + "\1g DOLLARS LEFT");
}
}
function inventoryCheck() {
if (foodAMT <= 0) {
foodAMT = 0;
}
if (ammoAMT <= 0) {
ammoAMT = 0;
}
//clearIllness();
if (clothingAMT <= 0) { // if there is no clothing then there is no clothing
clothingAMT = 0;
}
if (supplyAMT <= 0) {
supplyAMT = 0;
}
if (foodAMT <= 13) {
console.putmsg("\r\n\1h\1r\1i\1wYOU'D BETTER DO \1rSOME HUNTING OR \1n\1i\1mBUY FOOD \1h\1wAND SOON!!!!\1n\r\n\r\n");
console.beep();
console.pause();
}
foodAMT = parseInt(foodAMT);
ammoAMT = parseInt(ammoAMT);
clothingAMT = parseInt(clothingAMT);
supplyAMT = parseInt(supplyAMT);
cashInitialPurchase = parseInt(cashInitialPurchase);
totalMileage = parseInt(totalMileage);
prevMileage = totalMileage; // WTF IS THIS} decemberSixth();
//console.putmsg("end inventory check");
}
function doctorVisit() {
cashInitialPurchase = cashInitialPurchase - 20;
if (cashInitialPurchase > 0) {
console.putmsg("\r\n'\1h\1yLet's get you stitched up.\1n\1w'\r\n\1h\1r\1iDOCTOR'S BILL IS $20\1n\r\n");
clearIllness();
}
else {
cantAffordDoctor();
}
}
function turnStart() {
inventoryCheck();
//console.putmsg("\r\nTurn \1m" + turnNumber + "\1w Start.\r\n\1gIllness Flag = " + illnessFlag + "\r\n\1rWounded Flag = " + woundedFlag + "\r\n\1bActual Mileage = " + totalMileage + "\r\n\1mSouth Pass Flag normal[mile] = " + southPassFlag + "/" + mileSouthPassFlag + "\r\n");
if (illnessFlag == 1 || woundedFlag == 1) { //are you sick?
doctorVisit();
}
//console.putmsg("b4 southpass flagcheck");
southPassFlagCheck();
}
function firstTurn() {
turnNumber = 0;
console.crlf();
console.putmsg("\1h\1mMONDAY \1wMARCH 29 1847");
console.crlf();
turnStart();
}
function turnCheck() {
if (totalMileage <= 2040) {
// ***SETTING DATE****
turnNumber++; //advances turn
console.crlf();
console.putmsg("\1h\1mMONDAY ");
if (turnNumber == 1) {
console.putmsg("\1h\1wAPRIL 12");
}
if (turnNumber == 2) {
console.putmsg("\1h\1wAPRIL 26 ");
}
if (turnNumber == 3) {
console.putmsg("\1h\1wMAY 10");
}
if (turnNumber == 4) {
console.putmsg("\1h\1wMAY 24 ");
}
if (turnNumber == 5) {
console.putmsg("\1h\1wJUNE 7 ");
}
if (turnNumber == 6) {
console.putmsg("\1h\1wJUNE 21 ");
}
if (turnNumber == 7) {
console.putmsg("\1h\1wJULY 5 ");
}
if (turnNumber == 8) {
console.putmsg("\1h\1wJULY 19 ");
}
if (turnNumber == 9) {
console.putmsg("\1h\1wAUGUST 2 ");
}
if (turnNumber == 10) {
console.putmsg("\1h\1wAUGUST 16 ");
}
if (turnNumber == 11) {
console.putmsg("\1h\1wAUGUST 31 ");
}
if (turnNumber == 12) {
console.putmsg("\1h\1wSEPTEMBER 13");
}
if (turnNumber == 13) {
console.putmsg("\1h\1wSEPTEMBER 27 ");
}
if (turnNumber == 14) {
console.putmsg("\1h\1wOCTOBER 11 ");
}
if (turnNumber == 15) {
console.putmsg("\1h\1wOCTOBER 25");
}
if (turnNumber == 16) {
console.putmsg("\1h\1wNOVEMBER 8 ");
}
if (turnNumber == 17) {
console.putmsg("\1h\1wNOVEMBER 22 ");
}
if (turnNumber == 18) {
console.putmsg("\1h\1wDECEMBER 6 ");
}
if (turnNumber == 19) {
console.putmsg("\1h\1wDECEMBER 20 ");
}
if (turnNumber == 20) {
console.putmsg("\1h\1wYOU HAVE BEEN ON THE TRAIL TOO LONG ------ \r\n");
console.putmsg("\1h\1wYOUR FAMILY DIES IN THE FIRST BLIZZARD OF WINTER");
causeOfDeath = "got too tired";
formalities();
return; //this might be okay since it should exit the function after the end of the game, maybe take out
//console.crlf();
}
console.putmsg(" 1847\r\n");
turnStart();
}
else {
finalTurn();
}
}
function cantAffordDoctor() {
cashInitialPurchase = 0
console.putmsg("YOU CAN'T AFFORD A DOCTOR");
youDiedOf();
}
function clearIllness() {
woundedFlag = 0;
illnessFlag = 0;
}
function turnChoice() {
console.putmsg("\r\n\1h\1w*FOOD*" + "\1h\1rBULLETS " + "\1bCLOTHING" + "\1yMISC. SUPP." + "\1gCASH");
console.crlf();
console.putmsg("\1w--" + foodAMT + "\1w--\1r --" + ammoAMT + "--\1b-- " + clothingAMT + "--\1y--" + supplyAMT + " --\1g--" + cashInitialPurchase);
if (flagForFortOption != -1) {
flagForFortOption = flagForFortOption * -1;
fortHuntContinue();
}
}
function southPassFlagCheck() {
//console.putmsg("south pass flag check");
if (mileSouthPassFlag != 1) {
console.putmsg("\1h\1yTOTAL MILEAGE IS : \1g" + totalMileage + "\r\n");
turnChoice();
}
else {
console.putmsg("\1h\1yTOTAL MILEAGE IS 950\r\n\1n\1yYou are traveling through mountains");
mileSouthPassFlag = 0;
turnChoice();
}
}
function fortHuntContinue() {
console.putmsg("\r\n\r\n\1h\1wDO YOU WANT TO \1m(1) STOP AT THE NEXT FORT, \1h\1r(2) HUNT, ");
console.putmsg("OR \1h\1g(3) CONTINUE \1i\1y?\1n");
actionChoice = console.getnum();
if (actionChoice == 1) {
fortBuy();
}
else if (actionChoice == 2) {
if (ammoAMT < 39) {
console.putmsg("\1h\1rTOUGH---YOU NEED MORE BULLETS TO GO HUNTING");
fortHuntContinue();
}
else {
goHunting();
}
}
else if (actionChoice == 3) {
checkFoodAMT();
}
else {
console.putmsg("\1i\1r[Invalid Selection]\1n");
fortHuntContinue();
//return;
}
}
function fortBuy() {
console.putmsg("\1h\1gENTER WHAT YOU WISH TO SPEND ON THE FOLLOWING\r\n");
//setFortAmtSubroutine();
foodFortCycle();
ammoFortCycle();
clothingFortCycle();
supplyFortCycle();
totalMileage = totalMileage - 45;
checkFoodAMT();
}
function goHunting() {
if (ammoAMT < 39) {
console.putmsg("TOUGH---YOU NEED MORE BULLETS TO GO HUNTING");
fortHuntContinue();
}
else {
totalMileage = totalMileage - 45;
shootingSub();
//console.putmsg("bangResponse time " + bangResponse);
if (bangResponse >= 1) {
var randomMeasure = 1000 * Math.random();
//console.putmsg("\1r" + randomMeasure + " : random \1y" + 5*bangResponse + " adj bang response");
if (randomMeasure > 5 * bangResponse) {
console.putmsg("\1h\1y\1iNICE SHOT!!! \1n\1h\1c RIGHT ON TARGET \r\n\1gGOOD EATIN' TONIGHT!!\r\n");
console.putmsg("\1h\1rRIGHT BETWEEN THE EYES \1b---\1i\1mYOU GOT A BIG ONE!!!!");
console.putmsg("\r\n\1yFULL BELLIES TONIGHT!\r\n");
foodAMT = foodAMT + 52 + Math.random() * 6;
ammoAMT = ammoAMT - 10 - 3 * bangResponse;
//checkFoodAMT();
}
else {
console.putmsg("\1h\1rYOU MISSED..........\1wAND YOUR DINNER GOT AWAY.....");
ammoAMT = ammoAMT - 10 - Math.random() * 4;
}
}
checkFoodAMT();
}
}
//the following function is my own helper function for returning a random integer for selecting a bang word
function shootingSub() {
var variationsOfShootingWord = new Array;
variationsOfShootingWord[0] = "BANG"
variationsOfShootingWord[1] = "BLAM"
variationsOfShootingWord[2] = "POW"
variationsOfShootingWord[3] = "WHAM"
var shootingWordSelector = parseInt(getRandomInt(0, 3));
console.putmsg("\r\nTYPE \1h\1y" + variationsOfShootingWord[shootingWordSelector]);
console.crlf();
console.beep();
bangClockStart = system.timer;
//console.putmsg("bangClockStart time " + bangClockStart);
userBangWord = console.getstr();
bangResponse = system.timer;
userBangWord = userBangWord.toUpperCase();
//console.putmsg("bangResponse time " + bangResponse);
bangResponseCheck();
function bangResponseCheck() {
bangResponse = ((bangResponse - bangClockStart) * 36) - (choiceShootingExptLvl - 1)
console.crlf();
/*if(bangResponse<0) {
bangResponse=0;
} */
if (userBangWord != variationsOfShootingWord[shootingWordSelector]) {
bangResponse = 0;
misfire();
}
}
}
function checkFoodAMT() {
//console.putmsg("checkFoodAMT function");
if (foodAMT <= 13) {
starve();
return; //this should be okay
}
else
eatChoice();
}
function eatChoice() {
console.putmsg("\r\nDO YOU WANT TO EAT \1r(1) POORLY \1y(2) MODERATELY");
console.putmsg(" OR \1g(3) WELL \1h\1y?");
choiceEat = console.getnum();
if (foodAMT - 8 - 5 < 0) {
starve();
}
else if (choiceEat > 3 || choiceEat < 1) {
console.crlf();
console.putmsg("YOU CAN'T EAT THAT WELL");
eatChoice();
//return; this may need to be put back in
}
else {
choiceEat = parseInt(choiceEat);
foodAMT = foodAMT - 8 - 5 * choiceEat;
totalMileage = totalMileage + 200 + (animalsAMT - 220) / 5 + 10 * Math.random();
blizzardFlag = 0;
notEnoughClothes = 0;
riders();
}
}
function actionEvaluate() {
console.putmsg("\r\nDO YOU WANT TO (1) HUNT, OR (2) CONTINUE");
actionChoice = console.getnum();
if (actionChoice == 1) {
goHunting();
}
if (actionChoice == 2) {
checkFoodAMT();
fortBuy();
}
}
function riders() {
//console.putmsg("riders function beginning");
if (Math.random() * 10 < ((Math.pow(totalMileage / 100 - 4), 27) + 72) / (((Math.pow(totalMileage / 100 - 4), 2) + 12) - 1)) {
//console.putmsg("math selected event selector");
eventSelector();
}
else {
console.putmsg("\r\n\1rRIDERS \1yAHEAD. \1cTHEY ");
riderHostilityFactor = 0;
if (Math.random() < .8) {
console.putmsg("\1gDON'T ");
riderHostilityFactor = 1;
}
console.putmsg("\1rLOOK HOSTILE\r\n");
if (Math.random() > .2) {
riderHostilityFactor = 1 - riderHostilityFactor;
}
tacticChoice = 0;
while (tacticChoice < 1 || tacticChoice > 4) {
console.putmsg("\r\n\1h\1w\1iTACTICS\1n\r\n");
console.putmsg("\1h\1m(1) RUN \1h\1r(2) ATTACK \1h\1g(3) CONTINUE \1y(4) CIRCLE WAGONS\1i?\1n");
tacticChoice = console.getnum();
tacticChoice = parseInt(tacticChoice);
}
if (riderHostilityFactor == 1) {
milesAfterRiders();
}
else {
if (tacticChoice == 1) { // 3110
totalMileage = totalMileage + 20;
supplyAMT = supplyAMT - 15;
ammoAMT = ammoAMT - 150;
animalsAMT = animalsAMT - 40;
riderHostilityCheck();
}
if (tacticChoice == 2) { // attackCycle();
shootingSub();
//console.putmsg(bangResponse + "\1h\1r : BANG RESPONSE (multiply times 4 subtract 40 ammo amt)");
ammoAMT = ammoAMT - bangResponse * 4 - 40;
attackRiders();
}
if (tacticChoice == 3) {
fortAMT = 0;
milesAfterRiders();
}
if (tacticChoice == 4) {
if (Math.random() > .8) {
ridersNoAttack();
}
else {
ammoAMT = ammoAMT - 150;
supplyAMT = supplyAMT - 15;
riderHostilityCheck();
}
shootingSub();
ammoAMT = ammoAMT - bangResponse * 30 - 80
totalMileage = totalMileage - 25
attackRiders();
}
}
}
}
function milesAfterRiders() {
if (tacticChoice == 1) { //RUN milesMinusFive();
totalMileage = totalMileage + 15;
animalsAMT = animalsAMT - 10;
riderHostilityCheck();
}
if (tacticChoice == 2) { //checkMoney();
totalMileage = totalMileage - 5;
ammoAMT = ammoAMT - 100;
riderHostilityCheck();
}
if (tacticChoice == 3) { // milesMinusTwenty();
riderHostilityCheck();
}
if (tacticChoice == 4) {
totalMileage = totalMileage - 20;
riderHostilityCheck();
}
}
function ridersNoAttack() {
console.putmsg("\1h\1wTHEY DID NOT ATTACK");
eventSelector();
}
//was friendly.Riders()
function riderHostilityCheck() {
if (riderHostilityFactor != 0) {
console.putmsg("\r\n\1gRIDERS WERE FRIENDLY, \1h\1y\1iBUT CHECK FOR POSSIBLE LOSSES\1n");
eventSelector();
}
else {
console.putmsg("\r\n\1h\1rRIDERS WERE HOSTILE\r\n\1w--\1y\1iCHECK FOR LOSSES\1n\r\n");
console.beep();
if (ammoAMT <= 0) {
console.putmsg("\1mYOU RAN OUT OF BULLETS AND GOT MASSACRED BY THE RIDERS");
//nsole.putmsg("\1yammoAMT var : \1h\1r " + ammoAMT);
causeOfDeath = "got massacred";
formalities();
//return; //another one that might not be necessary but comes after death
}
else {
eventSelector();
}
}
}
//southPassFlagCheck();
function attackRiders() {
//console.putmsg("\r\n\1cYour BANG RESPONSE was " + bangResponse + "\r\n");
if (bangResponse <= 40 && bangResponse >= 1) {
console.putmsg("\1h\1gNICE SHOOTING---YOU DROVE THEM OFF");
riderHostilityCheck();
}
else {
if (bangResponse <= 60 && bangResponse >= 1) {
console.putmsg("\1h\1yKINDA SLOW WITH YOUR COLT .45");
riderHostilityCheck();
}
else {
console.putmsg("\1h\1yLOUSY SHOT---YOU GOT KNIFED\r\n");
console.beep();
woundedFlag = 1;
console.putmsg("\1cYOU HAVE TO SEE OL' DOC BLANCHARD\r\n");
riderHostilityCheck();
}
}
}
function showSupplies() {
console.putmsg("\r\n\1h\1w*FOOD*" + "\1h\1rBULLETS " + "\1bCLOTHING" + "\1yMISC. SUPP." + "\1gCASH");
console.crlf();
console.putmsg("\1w--" + foodAMT + "\1w--\1r --" + ammoAMT + "--\1b-- " + clothingAMT + "--\1y--" + supplyAMT + " --\1g--" + cashInitialPurchase + "\r\n");
}
function setFortAmtSubroutine() {
fortAMT = console.getnum();
if (cashInitialPurchase > 0) {
console.putmsg("\1h\1w *** \1g You have $\1y" + cashInitialPurchase + "\1g remaining\r\n");
//showSupplies();
fortAMT = console.getnum();
if (fortAMT > cashInitialPurchase) {
console.putmsg("\1h\1r\1iYOU DON'T HAVE THAT MUCH\1n\1h\1w--\1yKEEP YOUR SPENDING DOWN\r\n");
setFortAmtSubroutine();
}
else {
cashInitialPurchase = cashInitialPurchase - fortAMT;
//showSupplies();
}
}
else {
console.putmsg("\1h\1rYou don't have any money left");
}
}
function foodFortCycle() {
fortAMT = 0;
console.putmsg("\1h\1wFOOD\r\n");
if (cashInitialPurchase > 0) {
console.putmsg("\1h\1gYou have $\1y" + cashInitialPurchase + "\1g remaining\r\n");
//showSupplies();
fortAMT = console.getnum();
if (fortAMT > cashInitialPurchase) {
console.putmsg("\1h\1rYOU DON'T HAVE THAT MUCH--KEEP YOUR SPENDING DOWN\r\n");
foodFortCycle();
}
else {
cashInitialPurchase = cashInitialPurchase - fortAMT;
foodAMT = parseInt(foodAMT + .667 * fortAMT);
fortAMT = 0;
//showSupplies();
}
}
else {
console.putmsg("\1h\1rYou don't have any money left");
}
}
function ammoFortCycle() {
console.putmsg("\1h\1rAMMUNITION");
fortAMT = 0;
if (cashInitialPurchase > 0) {
console.putmsg("\1h\1gYou have $\1y" + cashInitialPurchase + "\1g remaining\r\n");
//showSupplies();
fortAMT = console.getnum();
if (fortAMT > cashInitialPurchase) {
console.putmsg("\1h\1rYOU DON'T HAVE THAT MUCH--KEEP YOUR SPENDING DOWN\r\n");
ammoFortCycle();
}
else {
cashInitialPurchase = cashInitialPurchase - fortAMT;
ammoAMT = parseInt(ammoAMT + 2 / 3 + fortAMT * 50);
fortAMT = 0; //this equation looks shaky
//showSupplies();
}
}
else {
console.putmsg("\1h\1rYou don't have any money left");
}
}
function clothingFortCycle() {
console.putmsg("\1h\1bCLOTHING");
fortAMT = 0;
if (cashInitialPurchase > 0) {
console.putmsg("\1h\1gYou have $\1y" + cashInitialPurchase + "\1g remaining\r\n");
//showSupplies();
fortAMT = console.getnum();
if (fortAMT > cashInitialPurchase) {
console.putmsg("\1h\1rYOU DON'T HAVE THAT MUCH--KEEP YOUR SPENDING DOWN\r\n");
clothingFortCycle();
}
else {
cashInitialPurchase = cashInitialPurchase - fortAMT;
clothingAMT = parseInt(clothingAMT + 2 / 3 * fortAMT);
fortAMT = 0;
//showSupplies();
}
}
else {
console.putmsg("\1h\1rYou don't have any money left");
}
}
function supplyFortCycle() {
console.putmsg("\1h\1yMISCELLANEOUS SUPPLIES");
fortAMT = 0;
if (cashInitialPurchase > 0) {
console.putmsg("\1h\1gYou have $\1y" + cashInitialPurchase + "\1g remaining\r\n");
//showSupplies();
fortAMT = console.getnum();
if (fortAMT > cashInitialPurchase) {
console.putmsg("\1h\1rYOU DON'T HAVE THAT MUCH--KEEP YOUR SPENDING DOWN\r\n");
supplyFortCycle();
}
else {
cashInitialPurchase = cashInitialPurchase - fortAMT;
supplyAMT = parseInt(supplyAMT + (.667 * fortAMT));
fortAMT = 0;
//showSupplies();
}
}
else {
console.putmsg("\1h\1rYou don't have any money left");
}
}
function shotInLeg() {
if (bangResponse <= 35 && ammoAMT > 1 && outOfAmmoToggle != true) {
quickestDraw();
}
else {
console.putmsg("\r\n\1h\1yYOU GOT \1rSHOT \1yIN THE LEG AND THEY TOOK ONE OF YOUR \1wOXEN");
woundedFlag = 1;
console.putmsg("\r\nBETTER HAVE A DOC LOOK AT YOUR WOUND");
supplyAMT = supplyAMT - 5;
animalsAMT = animalsAMT - 20;
outOfAmmoToggle = false;
mountains();
}
}
function eventSelector() {
//console.putmsg("event slector function beginning");
advanceEventCounter();
console.crlf();
secondSwitch();
//console.putmsg("event switch passed");
}
function advanceEventCounter() {
//console.putmsg("event prior ")
//log(eventNo.toSource());
//console.putmsg(eventNo);
eventNo++;
//log(eventNo.toSource());
//console.putmsg("event advanced ");
//console.putmsg(eventNo);
}
function secondSwitch() {
console.pause();
console.clear();
//ON eventNo-10 continue: 4220,4290,4340,4650,4610,indianFood();
if (eventNo == 1) {
console.putmsg("\1n\1h\1r\1yWAGON BREAKS DOWN \1w--\r\n\1iLOSE TIME AND SUPPLIES FIXING IT\1n\r\n");
totalMileage = totalMileage - 15 - 5 * Math.random();
supplyAMT = supplyAMT - 8;
mountains();
}
if (eventNo == 2) {
console.putmsg("\1cOX INJURES LEG\r\n\1y---\r\n\1r\1iSLOWS YOU DOWN REST OF TRIP\1i\r\n");
totalMileage = totalMileage - 25;
animalsAMT = animalsAMT - 20;
mountains();
}
if (eventNo == 3) {
console.putmsg("\1h\1r\1iBAD LUCK\1b\1n\1h---\1mYOUR DAUGHTER BROKE HER ARM\r\n");
console.putmsg("\1h\1yYOU HAD TO STOP AND USE SUPPLIES TO MAKE A SLING\r\n");
totalMileage = totalMileage - 5 - 4 * Math.random();
supplyAMT = supplyAMT - 2 - 3 * Math.random();
mountains();
}
if (eventNo == 4) {
console.putmsg("\1bOX WANDERS OFF\--- \1h\1mSPEND TIME LOOKING FOR IT\r\n");
totalMileage = totalMileage - 17;
mountains();
}
if (eventNo == 5) {
console.putmsg("\1h\1bYOUR SON GETS LOST\r\n\1y---\r\n\1cSPEND HALF THE DAY LOOKING FOR HIM");
totalMileage = totalMileage - 10
mountains();
}
if (eventNo == 6) {
console.putmsg("\1yUNSAFE \1bWATER\r\n\1y--\r\n\1rLOSE TIME LOOKING FOR \1cCLEAN SPRING");
totalMileage = totalMileage - 10 * Math.random() * -2
mountains();
}
if (eventNo == 7) {
if (totalMileage > 950) {
coldWeather();
}
else {
console.putmsg("\1bHEAVY RAINS---\1rTIME \1wAND \1ySUPPLIES LOST");
foodAMT = foodAMT - 10;
ammoAMT = ammoAMT - 500;
supplyAMT = supplyAMT - 15;
totalMileage = totalMileage - 10 * Math.random() - 5;
mountains();
}
}
if (eventNo == 8) {
console.putmsg("\1h\1rBANDITS ATTACK\1y\1iDraw Your Weapon\1n\r\n");
console.beep();
console.pause();
shootingSub();
ammoAMT = ammoAMT - 20 * bangResponse;
//console.putmsg("\r\n\1h\1yBANG RESPONSE = " + bangResponse + "\r\n");
if (bangResponse <= 50 && bangResponse >= 1) {
shotInLeg();
}
else {
console.putmsg("\1rYOU RAN OUT OF BULLETS---THEY GET LOTS OF CASH");
cashInitialPurchase = cashInitialPurchase / 3;
outOfAmmoToggle = true;
shotInLeg();
}
}
if (eventNo == 9) {
console.putmsg("\1h\1rTHERE WAS A \1rF\1yI\1rR\1yE \1n\1yIN YOUR WAGON\r\n--\r\n \1h\1wFOOD \1mAND \1ySUPPLIES \1rDAMAGED!\r\n");
foodAMT = foodAMT - 40;
ammoAMT = ammoAMT - 400;
supplyAMT = supplyAMT - Math.random() * 68 - 3;
totalMileage = totalMileage - 15;
mountains();
}
if (eventNo == 10) {