-
Notifications
You must be signed in to change notification settings - Fork 1
/
FinalProject.java
1741 lines (1694 loc) · 63.7 KB
/
FinalProject.java
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
import java.util.Scanner;
import java.util.Random;
//This is the final project program
public class FinalProject{
public static int day=1;
public static int hp=100;
public static int food = 10;
public static Boolean pistol = false;
public static Boolean AutomaticRifle=false;
public static int ammo = 0;
public static int medicine = 5;
public static int bandage=3;
public static int valuables = 2;
public static int Moral=100;
public static Boolean sick=false;
public static int hungry=10;
public static Boolean FastRecover=false;
public static Boolean injured=false;
public static Boolean spyID=false;
public static Boolean Cipher=false;
public static Boolean Badge=false;
public static Boolean TryEscape=false;
/**
This string array contains map information, with the capital
letter denoting the type of buildings and small letter state
of buildings
*/
public static final String[][] Map=
{
{"Mw","Fn","Sn","Rr","Rr","Hw","Wt","Fr","Hr","Mr","Gr"},
{"Mr","Mr","Dr","Tw","Rr","Fn","Tw","Rr","Fn","Aw","Wn"},
{"Fn","Fn","Wr","Pr","Hr","Dr","Tw","Sw","Mr","Aw","Hw"},
{"Tr","Hr","Fn","Fn","Fw","Rr","Fw","Or","Or","Dw","Ow"},
{"Hn","Ar","Rr","Ar","Wt","Rr","Ww","Hr","Dn","Wn","Ow"},
{"Wb","Ar","Rr","Wr","Ob","Pr","Wn","Fr","Pr","Wb","Mr"},
{"An","Rr","Rr","Ow","Aw","On","Wt","Mr","Hr","Mr","Mr"},
{"An","Rr","Rt","Sn","An","An","Dw","Ar","Tw","Pr","An"},
{"Mr","On","On","Ow","An","On","Tw","Sn","Wr","Aw","An"},
{"Hr","Sw","Wt","On","On","On","Tb","Aw","Dn","Fn","Sn"},
{"Fn","Ar","Ar","Dn","Dr","An","Tn","Pr","Hr","Or","Wn"},
{"An","Pr","Aw","Dw","Hr","At","Tn","Ar","Fw","Or","Pr"},
{"An","An","At","Ar","Mr","Ft","On","Ar","Fw","Fw","Fb"},
{"Ar","Ar","Sn","Ar","Rt","Ww","Wn","Ww","Fb","Pr","Fn"},
{"Aw","Aw","Tn","Wt","Rr","Pr","Hr","Ww","Fn","Fn","Fw"}
};
//String[15][11]
//All 12 types of buildings
public static final String[] Btype={"T","M","A","F","W","S","O","R","P","H","D","G"};
/**
CurrentCoordinate represents the current coordinate of the player,
with starting point at (14,0)
*/
public static int[] CurrentCoordinate= {14,0};
//{Y,X} This is the starting point of the player
public static void main(String[] args){
Introduction();
/**
for(int i=0;i<15;i++){
for(int j=0;j<11;j++){
System.out.print(Map[i][j]+" ");
}
System.out.println();
}
*/
/**
Boolean Test=false;
char M;
while(Test!=true){
System.out.printf("Please input a Char.%nL for moving leftward; R for moving rightward; U for moving upwards; and D for moving downwards.%n");
Scanner s = new Scanner(System.in);
M=s.nextLine().charAt(0);
Test=Move(M);
}
System.out.println("After the move, current coordinate is ("+CurrentCoordinate[1]+","+CurrentCoordinate[0]+")");
*/
//Previous Codes are used to test whether subroutine M works properly.
do{
Scanner s = new Scanner(System.in);
PlayerStatus();
PositionReport();
System.out.println("Please enter a char to move. U for upwards, D for downwards, L for Leftwards and R for rightwards.");
Boolean ValidMove=true;
do{
// char M=s.nextLine().charAt(0);
ValidMove=Move(s.nextLine().charAt(0));
}while(!ValidMove);
PositionReport();
PlayerStatus();
action();
sleep();
}while(!win());
End();
}
/**
This subroutine is used for player movement.
@param M the player's input, if valid it will change current CurrentCoordinate
@return return true, if the movement is valid; otherwise, false
*/
public static Boolean Move(char M){
//Input a char M input this subroutine as command of movement. If the movement is valid, it will change current CurrentCoordinate and return true.
if (CurrentCoordinate[1]==0 && M=='L'){
System.out.println("You cannot go further left. Input again:");
return false;
} else if (CurrentCoordinate[1]==10 && M=='R'){
System.out.println("You cannot go further right. Input again:");
return false;
} else if (CurrentCoordinate[0]==14 && M=='D'){
System.out.println("You cannot go further down. Input again:");
return false;
} else if (CurrentCoordinate[0]==0 && M=='U'){
System.out.println("You cannot go further up. Input again:");
return false;
} else {
if (M=='U'){
CurrentCoordinate[0]-=1;
return true;
}else if(M=='D'){
CurrentCoordinate[0]+=1;
return true;
}else if(M=='L'){
CurrentCoordinate[1]-=1;
return true;
}else if(M=='R'){
CurrentCoordinate[1]+=1;
return true;
}else {
System.out.println("Illegal input. Input again:");
return false;
}
}
}
/**
This method is used to check whether current building type matches one of those inputed by the array
@param CurrentBtype A String that contains the building type of Reznov's current position.
@return A boolean that will be used in an if conditional to judge whether following codes will be executed
*/
public static Boolean CheckPosition(String[] input){
String CurrentBtype=String.valueOf((Map[CurrentCoordinate[0]][CurrentCoordinate[1]]).charAt(0));
for(int i=0;i<input.length;i++){
if(CurrentBtype.equals(input[i])){
return true;
}
}
return false;
}
/**
This method is used to check whether current building status matches one of those inputed by the array
@param CurrentBstatus A String that contains the building status of Reznov's current position.
@return A boolean that will be used in an if conditional to judge whether following codes will be executed
*/
public static Boolean CheckStatus(String[] input){
String CurrentBstatus=String.valueOf((Map[CurrentCoordinate[0]][CurrentCoordinate[1]]).charAt(1));
for(int i=0;i<input.length;i++){
if(CurrentBstatus.equals(input[i])){
return true;
}
}
return false;
}
/**
This method will print out all actions available at Reznov's current position.
@return Return an array of available choice No.
*/
public static int[] PrintAction(){
String available="";
if(CheckPosition("T A F W S O R P H D".split("\\s+"))){
System.out.println("1.Scavenge");
available+="1 ";
}
if(CheckPosition("T A F W S O R H D".split("\\s+"))&&CheckStatus("r".split("\\s+"))){
System.out.println("2.Steal");
available+="2 ";
}
if(CheckStatus("t".split("\\s+"))){
System.out.println("3.Trade");
available+="3 ";
}
if(CheckPosition("P".split("\\s+"))){
System.out.println("4.Fast Travel");
available+="4 ";
}
if(true){
System.out.println("5.Do Nothing");
available+="5 ";
}
if((CheckPosition("T A F W S O R H D".split("\\s+"))&&CheckStatus("b".split("\\s+")))||(CheckPosition("M".split("\\s+"))&&CheckStatus("r".split("\\s+")))){
System.out.println("6.Stealth in and try to find supplies.");
available+="6 ";
}
if(CheckPosition("H".split("\\s+"))&&CheckStatus("r".split("\\s+"))&&(injured||sick)){
System.out.println("7.Ask doctors inside to cure your disease and bandage your injuries to make you recover.");
available+="7 ";
}
if(CheckPosition("D".split("\\s+"))&&CheckStatus("r".split("\\s+"))){
System.out.println("8.Ask priests for material relief.");
available+="8 ";
}
if(CheckPosition("D".split("\\s+"))&&CheckStatus("r".split("\\s+"))){
System.out.println("9.Ask priests for mental relief.");
available+="9 ";
}
if(CheckPosition("G".split("\\s+"))){
System.out.println("10.Try to cheat rebel checkpoints and sneak out of the city");
available+="10 ";
}
String[] Raw1=available.split("\\s+");
int[] output=new int[Raw1.length];
for(int j=0;j<output.length;j++){
output[j]=Integer.parseInt(Raw1[j]);
}
return output;
}
/**
This method will check whether the No. input by players is among those available choices.
@param decision Choice made by Players.
@param PossibleDecision The integer array produced by PrintAction().
@return A Boolean value of true or false.
*/
public static Boolean CheckAvailable(int decision,int[] PossibleDecision){
for(int k=0;k<PossibleDecision.length;k++){
if(decision==PossibleDecision[k]){
return true;
}
}
return false;
}
/**
This method is used for the action stage in game.
@return This method does not need to return.
*/
public static void action(){
System.out.printf("Time to do something....%n");
System.out.printf("You need to make a choice among actions available in your current position. If you have decided, enter the number before the choice to choose. Choose wisely.%n");
Scanner y=new Scanner(System.in);
int[] Available=PrintAction();
int choice=0;
while(!CheckAvailable(choice,Available)){
System.out.println("Please input the No. you decide which is in font of available choices.");
choice=TextIO.getlnInt();
}
switch(choice){
case 1:
Scavenge();
break;
case 2:
Steal();
break;
case 3:
Trade();
break;
case 4:
Teleport();
break;
case 5:
break;
case 6:
Stealth();
break;
case 7:
DocHeal();
break;
case 8:
AskR();
break;
case 9:
AskM();
break;
default:
Escape();
break;
}
}
/**
Method to run when players choose to scavenge.
T A F W S O R P H D
@return No returns
*/
public static void Scavenge(){
int foodbuff=0;
int medicinebuff=0;
int weaponbuff=0;
int bandagebuff=0;
int valuablesbuff=0;
int ammobuff=0;
int IDbuff=0;
int DiseaseChance=0;
int BadgeBuff=0;
switch(String.valueOf((Map[CurrentCoordinate[0]][CurrentCoordinate[1]]).charAt(0))){
case "T":
foodbuff+=5;
medicine+=2;
bandagebuff+=2;
weaponbuff+=0;
valuablesbuff+=1;
ammobuff+=0;
BadgeBuff-=1;
IDbuff-=1;
break;
case "A":
foodbuff+=3;
medicine+=2;
bandagebuff+=2;
weaponbuff+=0;
valuablesbuff+=2;
ammobuff+=1;
IDbuff-=1;
BadgeBuff-=1;
break;
case "F":
foodbuff-=5;
medicine+=3;
bandagebuff+=4;
weaponbuff+=0;
valuablesbuff-=5;
ammobuff-=3;
BadgeBuff-=1;
IDbuff-=1;
break;
case "W":
foodbuff+=2;
medicine+=6;
bandagebuff+=6;
weaponbuff+=3;
valuablesbuff+=3;
ammobuff+=2;
BadgeBuff+=0;
IDbuff+=0;
break;
case "S":
foodbuff+=0;
medicine+=3;
bandagebuff+=3;
weaponbuff-=5;
valuablesbuff+=1;
ammobuff-=5;
IDbuff-=1;
BadgeBuff-=1;
break;
case "O":
foodbuff+=1;
medicine+=0;
bandagebuff+=0;
weaponbuff-=5;
valuablesbuff+=5;
ammobuff-=5;
BadgeBuff-=1;
IDbuff+=1;
break;
case "R":
foodbuff-=7;
medicine-=7;
bandagebuff-=7;
weaponbuff-=7;
valuablesbuff-=7;
ammobuff-=7;
IDbuff+=3;
BadgeBuff+=1;
DiseaseChance-=6;
break;
case "P":
foodbuff-=7;
medicine-=7;
bandagebuff-=7;
weaponbuff-=5;
valuablesbuff+=3;
ammobuff-=5;
IDbuff+=2;
BadgeBuff+=2;
DiseaseChance-=4;
break;
case "H":
foodbuff+=1;
medicine+=5;
bandagebuff+=5;
weaponbuff-=5;
valuablesbuff-=3;
ammobuff-=5;
IDbuff-=1;
BadgeBuff-=1;
DiseaseChance+=4;
break;
default:
foodbuff+=1;
medicine+=5;
bandagebuff+=5;
weaponbuff-=5;
valuablesbuff-=3;
ammobuff-=5;
IDbuff-=1;
BadgeBuff-=1;
DiseaseChance+=2;
break;
}
switch(String.valueOf((Map[CurrentCoordinate[0]][CurrentCoordinate[1]]).charAt(1))){
case "w":
foodbuff-=1;
medicine-=1;
bandagebuff-=1;
weaponbuff-=1;
valuablesbuff-=1;
ammobuff-=1;
IDbuff+=0;
DiseaseChance+=0;
break;
case "r":
foodbuff-=2;
medicine-=2;
bandagebuff-=2;
weaponbuff-=2;
valuablesbuff-=2;
ammobuff-=2;
IDbuff+=0;
DiseaseChance-=2;
break;
case "n":
foodbuff+=0;
medicine+=0;
bandagebuff+=0;
weaponbuff+=0;
valuablesbuff+=1;
ammobuff+=0;
IDbuff+=0;
DiseaseChance+=0;
break;
default:
foodbuff-=2;
medicine-=2;
bandagebuff-=2;
weaponbuff-=2;
valuablesbuff-=2;
ammobuff-=2;
IDbuff+=0;
DiseaseChance-=2;
break;
}
System.out.printf("After searching for a long time, you stop scavenging and examine what you found.%n");
AddFood(foodbuff);
AddMedicine(medicinebuff);
AddBandage(bandagebuff);
AddValuables(valuablesbuff);
AddAmmo(ammobuff);
AddWeapon(weaponbuff);
getDisease(DiseaseChance);
getID(IDbuff);
getBadge(BadgeBuff);
}
/**
pick a random element of a list of Strings
@param list the array of Strings
@return a randomly selected member of the list
*/
public static String pickRandom(String[] list){
Random f = new Random();
int k = f.nextInt(list.length);
return list[k];
}
/**
The method that will be executed when players choose to steal.
@return no returns
*/
public static void Steal(){
int foodbuff=0;
int medicinebuff=0;
int weaponbuff=0;
int bandagebuff=0;
int valuablesbuff=0;
int ammobuff=0;
int stealBuff=2;
String[] steal={
"'Stealing, of course, is a crime, and a very impolite thing to do. But like most impolite things, it is excusable under certain circumstances.' --Lemony Snicket",
"'If you don't get caught, you deserve everything you steal.' --Daniel Nayeri",
"'Stealers, keepers.' --Ilona Andrews",
"'Clothes make the man. Especially the pockets.' --Ljupka Cvetanova",
"'Taking books can't be counted as stealing...for a scholar...can't be counted as stealing.' --Yiji Kong"
};
System.out.printf("%s%n",pickRandom(steal));
Moral-=5;
int L=RollDice();
if(L>7){
switch(String.valueOf((Map[CurrentCoordinate[0]][CurrentCoordinate[1]]).charAt(0))){
case "T":
foodbuff+=5;
medicine+=2;
bandagebuff+=2;
weaponbuff+=0;
valuablesbuff+=1;
ammobuff+=0;
break;
case "A":
foodbuff+=3;
medicine+=2;
bandagebuff+=2;
weaponbuff+=0;
valuablesbuff+=2;
ammobuff+=1;
break;
case "F":
foodbuff-=5;
medicine+=3;
bandagebuff+=4;
weaponbuff+=0;
valuablesbuff-=5;
ammobuff-=3;
break;
case "W":
foodbuff+=2;
medicine+=6;
bandagebuff+=6;
weaponbuff+=3;
valuablesbuff+=3;
ammobuff+=2;
break;
case "S":
foodbuff+=0;
medicine+=3;
bandagebuff+=3;
weaponbuff-=5;
valuablesbuff+=1;
ammobuff-=5;
break;
case "O":
foodbuff+=1;
medicine+=0;
bandagebuff+=0;
weaponbuff-=5;
valuablesbuff+=5;
ammobuff-=5;
break;
case "R":
foodbuff-=7;
medicine-=7;
bandagebuff-=7;
weaponbuff-=7;
valuablesbuff-=7;
ammobuff-=7;
break;
case "H":
foodbuff+=1;
medicine+=5;
bandagebuff+=5;
weaponbuff-=5;
valuablesbuff-=3;
ammobuff-=5;
Moral-=5;
break;
default:
foodbuff+=1;
medicine+=5;
bandagebuff+=5;
weaponbuff-=5;
valuablesbuff-=3;
ammobuff-=5;
Moral-=5;
break;
}
foodbuff-=2;
medicine-=2;
bandagebuff-=2;
weaponbuff-=2;
valuablesbuff-=2;
ammobuff-=2;
System.out.printf("You sneak in, evade attention, grab a bag and run out.%nAfter you are sure that you are safe, you open the bag and begin counting what you stole.%n");
AddFood(foodbuff);
AddMedicine(medicinebuff);
AddBandage(bandagebuff);
AddValuables(valuablesbuff);
AddAmmo(ammobuff);
AddWeapon(weaponbuff);
}else{
System.out.printf("Your attempt at crime is discovered, you hear noises and sounds of loading guns.%n");
if((pistol||AutomaticRifle)&&ammo>=1){
System.out.printf("You jump out a window, and shoot some bullets back.%nIt sounds like you hit some civilians and they stop chasing you.%n");
Moral-=10;
ammo-=1;
}else{
System.out.printf("You begin to run away.%nWhile you are running away, people inside the house shoot you. You feel a bullet hit you.%n");
injured=true;
hp-=15;
Defeat();
}
}
}
/**
This is the method that will be used when players choose to trade.
@return No return needed.
*/
public static void Trade(){
System.out.printf("You walk into the building, which is now a trading spot.%n'Maybe I can find a good deal.', you tell youself.%n");
Boolean chance=false;
if(RollDice()>13){
chance=true;
}
System.out.printf("%n%n-----------------------------------------------------------------------------------------------------------------------%nHere is the trade price...%n");
System.out.printf("1.One unit of valuables can exchange three units of food, or one unit of medicine, or one unit of bandage, or two units of ammo.%n2.One unit of medicine can exchange three units of food, or one unit of bandage, or two units of ammo.%n3.One unit of bandage can exchange three units of food, or one unit of medicine, or two units of ammo.%n4.Four units of food can exchange one unit of medicines or one unit of bandage.%n");
if(chance){
System.out.printf("5.Five units of valuables can exchange one pistol.%n6.Ten units of valuables can exchange one automatic rifle.%n7.Ten units of valuables can exchange a spy ID or a badge or cipher of rebels spies.%n");
}
Boolean continueTrade=false;
PlayerItemStatus();
System.out.printf("%n%nDo you want to trade with them? Input 'yes' to trade, else to leave.%n");
String a=TextIO.getln();
if(!((a.toUpperCase()).equals("YES"))){
return;
}
String[] Choice1={"valuables","food","medicine","bandage","ammo"};
String[] Choice2={"medicine","food","bandage","ammo"};
String[] Choice3={"bandage","food","medicine","ammo"};
String[] Choice4={"food","medicine","bandage"};
String[] Choice7={"valuables","spyID","Badge","cipher"};
do{
String StringInput;
int typeInput;
System.out.printf("Input the number of the choice of item you wish to trade.%n");
typeInput=TextIO.getlnInt();
while((typeInput>7||typeInput<1)||(typeInput>4&&(!chance))){
System.out.printf("Invalid choices, input again.%n");
typeInput=TextIO.getlnInt();
}
switch(typeInput){
case 1:
Boolean ValidInput=true;
int input=0;
System.out.printf("Now enter name of the item you want to exchange to.%n");
StringInput=(TextIO.getln()).toUpperCase();
for(int k=1;k<Choice1.length;k++){
if(StringInput.equals(Choice1[k].toUpperCase())){
//Valid Input
input=k;
ValidInput=true;
break;
}else{
ValidInput=false;
}
}
while(!ValidInput){
System.out.printf("Please make sure you input a valid name. Please re-input.%n");
StringInput=(TextIO.getln()).toUpperCase();
for(int k=1;k<Choice1.length;k++){
if(StringInput.equals(Choice1[k].toUpperCase())){
//Valid Input
input=k;
ValidInput=true;
break;
}else{
ValidInput=false;
}
}
}
if(valuables<1){
System.out.printf("You do not have enough item to trade!.%n");
}else{
System.out.printf("Trade Completed.%n");
valuables-=1;
if(input==1){
food+=3;
}else if(input==2){
medicine+=1;
}else if(input==3){
bandage+=1;
}else if(input==4){
ammo+=2;
}else{
System.out.printf("Error!");
}
}
break;
case 2:
Boolean ValidInput1=true;
int input1=0;
System.out.printf("Now enter name of the item you want to exchange to.%n");
StringInput=(TextIO.getln()).toUpperCase();
for(int k=1;k<Choice2.length;k++){
if(StringInput.equals(Choice2[k].toUpperCase())){
//Valid Input
input1=k;
ValidInput1=true;
break;
}else{
ValidInput1=false;
}
}
while(!ValidInput1){
System.out.printf("Please make sure you input a valid name. Please re-input.%n");
StringInput=(TextIO.getln()).toUpperCase();
for(int k=1;k<Choice2.length;k++){
if(StringInput.equals(Choice2[k].toUpperCase())){
//Valid Input
input1=k;
ValidInput1=true;
break;
}else{
ValidInput1=false;
}
}
}
if(medicine<1){
System.out.printf("You do not have enough item to trade!.%n");
}else{
System.out.printf("Trade Completed.%n");
medicine-=1;
if(input1==1){
food+=3;
}else if(input1==2){
bandage+=1;
}else if(input1==3){
ammo+=2;
}else{
System.out.printf("Error!");
}
}
break;
case 3:
Boolean ValidInput2=true;
int input2=0;
System.out.printf("Now enter name of the item you want to exchange to.%n");
StringInput=(TextIO.getln()).toUpperCase();
for(int k=1;k<Choice3.length;k++){
if(StringInput.equals(Choice3[k].toUpperCase())){
//Valid Input
input2=k;
ValidInput2=true;
break;
}else{
ValidInput2=false;
}
}
while(!ValidInput2){
System.out.printf("Please make sure you input a valid name. Please re-input.%n");
StringInput=(TextIO.getln()).toUpperCase();
for(int k=1;k<Choice3.length;k++){
if(StringInput.equals(Choice3[k].toUpperCase())){
//Valid Input
input2=k;
ValidInput2=true;
break;
}else{
ValidInput2=false;
}
}
}
if(bandage<1){
System.out.printf("You do not have enough item to trade!.%n");
}else{
System.out.printf("Trade Completed.%n");
bandage-=1;
if(input2==1){
food+=3;
}else if(input2==2){
medicine+=1;
}else if(input2==3){
ammo+=2;
}else{
System.out.printf("Error!");
}
}
break;
case 4:
Boolean ValidInput3=true;
int input3=0;
System.out.printf("Now enter name of the item you want to exchange to.%n");
StringInput=(TextIO.getln()).toUpperCase();
for(int k=1;k<Choice4.length;k++){
if(StringInput.equals(Choice4[k].toUpperCase())){
//Valid Input
input3=k;
ValidInput3=true;
break;
}else{
ValidInput3=false;
}
}
while(!ValidInput3){
System.out.printf("Please make sure you input a valid name. Please re-input.%n");
StringInput=(TextIO.getln()).toUpperCase();
for(int k=1;k<Choice4.length;k++){
if(StringInput.equals(Choice4[k].toUpperCase())){
//Valid Input
input3=k;
ValidInput3=true;
break;
}else{
ValidInput3=false;
}
}
}
if(food<4){
System.out.printf("You do not have enough item to trade!.%n");
}else{
System.out.printf("Trade Completed.%n");
food-=4;
if(input3==1){
medicine+=1;
}else if(input3==2){
bandage+=1;
}else{
System.out.printf("Error!");
}
}
break;
case 5:
if(valuables<5){
System.out.printf("You do not have enough items to trade.%n");
}else if(pistol){
System.out.printf("You already have a pistol, you do not need to trade for a new one.%n");
}else{
System.out.printf("The man gives you a pistol.%n");
valuables-=5;
pistol=true;
}
break;
case 6:
if(valuables<10){
System.out.printf("You do not have enough items to trade.%n");
}else if(AutomaticRifle){
System.out.printf("You already have an automatic rifle, you do not need to trade for a new one.%n");
}else{
System.out.printf("After putting away all the valuable things you give him, the man picks up an automatic rifle from the safe.%n");
valuables-=10;
AutomaticRifle=true;
}
break;
default:
Boolean ValidInput4=true;
int input4=0;
System.out.printf("Now enter name of the item you want to exchange to.%n");
StringInput=(TextIO.getln()).toUpperCase();
for(int k=1;k<Choice7.length;k++){
if(StringInput.equals(Choice7[k].toUpperCase())){
//Valid Input
input4=k;
ValidInput4=true;
break;
}else{
ValidInput4=false;
}
}
while(!ValidInput4){
System.out.printf("Please make sure you input a valid name. Please re-input.%n");
StringInput=(TextIO.getln()).toUpperCase();
for(int k=1;k<Choice7.length;k++){
if(StringInput.equals(Choice7[k].toUpperCase())){
//Valid Input
input4=k;
ValidInput4=true;
break;
}else{
ValidInput4=false;
}
}
}
if(valuables<10){
System.out.printf("You do not have enough item to trade!.%n");
}else{
if(input4==1){
if(spyID){
System.out.printf("You do not need that anymore.");
}else{
System.out.printf("The man claims that he has something interesting. You buy it.%nYou find out that it is maybe a rebel spy ID.%n");
valuables-=10;
spyID=true;
}
}else if(input4==2){
if(Badge){
System.out.printf("You do not need that anymore.");
}else{
System.out.printf("The man claims that he has something interesting. You buy it.%nYou find out that it is maybe a rebel spy's badge.%n");
valuables-=10;
Badge=true;
}
}else if(input4==3){
if(Cipher){
System.out.printf("You do not need that anymore.");
}else{
System.out.printf("The man claims that he has something interesting. You buy it.%nYou find out that it is a booklet of words, sentences, and symbols, and it is a cipher of rebels spies.%n");
valuables-=10;
Cipher=true;
}
}else{
System.out.printf("Error!");
}
}
break;
}
PlayerItemStatus();
System.out.printf("Do you want to continue trading with them? Input 'yes' to continue, else to quit.%n");
String b=TextIO.getln();
if((b.toUpperCase()).equals("YES")){
continueTrade=true;
}else{
continueTrade=false;
}
}while(continueTrade);
}
/**
This is the method that will be used when players choose let Reznov to stealth in.
@return No return needed.
*/
public static void Stealth(){
int foodbuff=0;
int medicinebuff=0;
int weaponbuff=0;
int bandagebuff=0;
int valuablesbuff=0;
int ammobuff=0;
int stealBuff=2;
int L=RollDice();
if(L>10){
switch(String.valueOf((Map[CurrentCoordinate[0]][CurrentCoordinate[1]]).charAt(0))){
case "T":
foodbuff+=5;
medicine+=2;
bandagebuff+=2;
weaponbuff+=0;
valuablesbuff+=1;
ammobuff+=0;
break;
case "A":
foodbuff+=3;
medicine+=2;
bandagebuff+=2;
weaponbuff+=0;
valuablesbuff+=2;
ammobuff+=1;
break;
case "F":
foodbuff-=5;
medicine+=3;
bandagebuff+=4;
weaponbuff+=0;
valuablesbuff-=5;
ammobuff-=3;
break;
case "W":
foodbuff+=2;
medicine+=6;
bandagebuff+=6;
weaponbuff+=3;
valuablesbuff+=3;
ammobuff+=2;
break;
case "S":
foodbuff+=0;
medicine+=3;
bandagebuff+=3;
weaponbuff-=5;
valuablesbuff+=1;
ammobuff-=5;
break;
case "O":
foodbuff+=1;
medicine+=0;
bandagebuff+=0;
weaponbuff-=5;
valuablesbuff+=5;
ammobuff-=5;
break;
case "R":
foodbuff-=7;
medicine-=7;
bandagebuff-=7;
weaponbuff-=7;
valuablesbuff-=7;
ammobuff-=7;
break;
case "H":
foodbuff+=1;
medicine+=5;
bandagebuff+=5;
weaponbuff-=5;
valuablesbuff-=3;
ammobuff-=5;
break;
case "M":
foodbuff+=5;
medicine+=6;
bandagebuff+=6;
weaponbuff+=7;
valuablesbuff+=3;
ammobuff+=7;
break;
default:
foodbuff+=1;
medicine+=5;
bandagebuff+=5;