-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlackJack.c
8173 lines (7126 loc) · 311 KB
/
BlackJack.c
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
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <stdbool.h>
#include <time.h>
#define COLOR_BOLD "\e[1m"
#define COLOR_ITALICIZE "\e[3m"
#define COLOR_CYAN "\e[36m"
#define COLOR_MAGENTA "\e[35m"
#define COLOR_OFF "\e[m"
int mainMenuCompare(char a)
{
char mainMenuChoice;
mainMenuChoice = a;
// printf("%c <--- This is from the function.\n", mainMenuChoice); // TESTER
char mainMenuOptionOne = '1'; // PLAY
char mainMenuOptionTwo = '2'; // HOW TO PLAY
char mainMenuOptionThree = '3'; // GAME SETTINGS
char mainMenuOptionFour = '4'; // GAME CREDITS
char mainMenuOptionFive = '5'; // EXIT GAME
// Need to add more if we do more main menu options! <--- NOTE TO SELF!!!
if (mainMenuChoice == mainMenuOptionOne)
{
// Main game
return 1;
}
else if (mainMenuChoice == mainMenuOptionTwo)
{
// How to Play
return 2;
}
else if (mainMenuChoice == mainMenuOptionThree)
{
// Settings
return 3;
}
else if (mainMenuChoice == mainMenuOptionFour)
{
//Game Credits
return 4;
}
else if (mainMenuChoice == mainMenuOptionFive)
{
// Exits the Game
return 5;
}
else
{
// Invalid option
printf("\n\nInvalid option, please input a number corresponding to available existing option!\n\n");
return 9;
}
}
int tableSelectionCompare(char a)
{
char tableSelectionChoice;
tableSelectionChoice = a;
char tableSelectionOptionOne = '1';
char tableSelectionOptionTwo = '2';
char tableSelectionOptionThree = '3';
char tableSelectionOptionFour = '4';
char tableSelectionOptionFive = '5';
char tableSelectionOptionSix = '6';
if (tableSelectionChoice == tableSelectionOptionOne)
{
// Table 1
return 1;
}
else if (tableSelectionChoice == tableSelectionOptionTwo)
{
// Table 2
return 2;
}
else if (tableSelectionChoice == tableSelectionOptionThree)
{
// Table 3
return 3;
}
else if (tableSelectionChoice == tableSelectionOptionFour)
{
// Table 4
return 4;
}
else if (tableSelectionChoice == tableSelectionOptionFive)
{
// Table 5
return 5;
}
else if (tableSelectionChoice == tableSelectionOptionSix)
{
// Back to Main Menu Option
return 6;
}
else
{
// Invalid option
return 9;
}
}
int entryDigitValidator(char a)
{
char enteredDigit;
enteredDigit = a;
char optionZero = '0';
char optionOne = '1';
char optionTwo = '2';
char optionThree = '3';
char optionFour = '4';
char optionFive = '5';
char optionSix = '6';
char optionSeven = '7';
char optionEight = '8';
if (enteredDigit == optionZero)
{
// Will be reserved for returning to menu or abstaining from action.
// printf("%d ZERO",enteredDigit);
return 0;
}
else if (enteredDigit == optionOne)
{
// printf("%d ONE",enteredDigit);
return 1;
}
else if (enteredDigit == optionTwo)
{
// printf("%d TWO",enteredDigit);
return 2;
}
else if (enteredDigit == optionThree)
{
// printf("%d THREE",enteredDigit);
return 3;
}
else if (enteredDigit == optionFour)
{
// printf("%d FOUR",enteredDigit);
return 4;
}
else if (enteredDigit == optionFive)
{
// printf("%d FIVE",enteredDigit);
return 5;
}
else if (enteredDigit == optionSix)
{
// printf("%d SIX",enteredDigit);
return 6;
}
else if (enteredDigit == optionSeven)
{
// printf("%d SEVEN",enteredDigit);
return 7;
}
else if (enteredDigit == optionEight)
{
// printf("%d",enteredDigit);
return 8;
}
else
{
// Invalid option
// printf("%d",enteredDigit);
return 9;
}
}
int seedRandom(int lower, int upper, int count)
{
int i;
for (i = 0; i < count; i ++)
{
int num = (rand() % (upper - lower + 1)) + lower;
return num;
}
}
// Recieved from GeeksforGeeks.org -- Upendra Bartwal
int printRandoms(int lower, int upper, int count)
{
int i;
for (i = 0; i < count; i++) {
int num = (rand() %
(upper - lower + 1)) + lower;
return num;
}
}
// End credit
int pairRandom(int lower, int upper, int count)
{
int i;
for (i = 0; i < count; i++) {
int num = (rand() %
(upper - lower + 1)) + lower;
return num;
}
}
int sleepRandom(int lower, int upper, int count)
{
int i;
for (i = 0; i < count; i++) {
int num = (rand() %
(upper - lower + 1)) + lower;
return num;
}
}
int cardPrintf(int card) {
int aceCard = 1; // Ace Card will = 1 on rand
int twoCard = 2; // 2 Card will = 2 on rand
int threeCard = 3; // 3 Card will = 3 on rand
int fourCard = 4; // 4 Card will = 4 on rand
int fiveCard = 5; // 5 Card will = 5 on rand
int sixCard = 6; // 6 Card will = 6 on rand
int sevenCard = 7; // 7 Card will = 7 on rand
int eightCard = 8; // 8 Card will = 8 on rand
int nineCard = 9; // 9 Card will = 9 on rand
int tenCard = 10; // 10 Card will = 10 on rand
int jackCard = 11; // Jack Card will = 11 on rand
int queenCard = 12; // Queen Card will = 12 on rand
int kingCard = 13; // King Card will = 13 on rand
int aceCard2 = 14; // Ace Card will value of 11 = 14 on rand
int dealtCard = card;
if (dealtCard == aceCard)
{
printf("[A] ");
return 1;
}
else if (dealtCard == twoCard)
{
printf("[2] ");
return 2;
}
else if (dealtCard == threeCard)
{
printf("[3] ");
return 3;
}
else if (dealtCard == fourCard)
{
printf("[4] ");
return 4;
}
else if (dealtCard == fiveCard)
{
printf("[5] ");
return 5;
}
else if (dealtCard == sixCard)
{
printf("[6] ");
return 6;
}
else if (dealtCard == sevenCard)
{
printf("[7] ");
return 7;
}
else if (dealtCard == eightCard)
{
printf("[8] ");
return 8;
}
else if (dealtCard == nineCard)
{
printf("[9] ");
return 9;
}
else if (dealtCard == tenCard)
{
printf("[T] ");
return 10;
}
else if (dealtCard == jackCard)
{
printf("[J] ");
return 10;
}
else if (dealtCard == queenCard)
{
printf("[Q] ");
return 10;
}
else if (dealtCard == kingCard)
{
printf("[K] ");
return 10;
}
else if (dealtCard == aceCard2)
{
printf("[A] ");
return 11;
}
else
{
return 0;
}
}
int cardValuation(int card)
{
int aceCard = 1; // Ace Card will = 1 on rand
int twoCard = 2; // 2 Card will = 2 on rand
int threeCard = 3; // 3 Card will = 3 on rand
int fourCard = 4; // 4 Card will = 4 on rand
int fiveCard = 5; // 5 Card will = 5 on rand
int sixCard = 6; // 6 Card will = 6 on rand
int sevenCard = 7; // 7 Card will = 7 on rand
int eightCard = 8; // 8 Card will = 8 on rand
int nineCard = 9; // 9 Card will = 9 on rand
int tenCard = 10; // 10 Card will = 10 on rand
int jackCard = 11; // Jack Card will = 11 on rand
int queenCard = 12; // Queen Card will = 12 on rand
int kingCard = 13; // King Card will = 13 on rand
int aceCard2 = 14; // Ace Card with value of 11
int dealtCard = card;
if (dealtCard == aceCard)
{
return 1;
}
else if (dealtCard == twoCard)
{
return 2;
}
else if (dealtCard == threeCard)
{
return 3;
}
else if (dealtCard == fourCard)
{
return 4;
}
else if (dealtCard == fiveCard)
{
return 5;
}
else if (dealtCard == sixCard)
{
return 6;
}
else if (dealtCard == sevenCard)
{
return 7;
}
else if (dealtCard == eightCard)
{
return 8;
}
else if (dealtCard == nineCard)
{
return 9;
}
else if (dealtCard = tenCard)
{
return 10;
}
else if (dealtCard == jackCard)
{
return 10;
}
else if (dealtCard == queenCard)
{
return 10;
}
else if (dealtCard == kingCard)
{
return 10;
}
else if (dealtCard == aceCard2)
{
return 11;
}
else
{
return 0;
}
}
// Recieved from StackOverflow, but I will explain what is going on.
void printfspace2 (unsigned long long int n) { // Receives number from printfspace.
if (n < 1000) { // If the number is less than 1000 (only three digits), it does not need comma formatting and will print the number and exit the function.
printf ("%d", n); // Prints the value.
return;
}
printfspace2 (n/1000); // Divides n by 1000 and sends it back to the function.
printf (",%03d", n%1000); // Prints 3 digits from n. Divides until there is a remainder. -- ???
}
void printfspace (unsigned long long int n) { // Send all numbers that need formatting here first, in the case that there's a negative number.
if (n < 0) { // Determines if the number sent into the function is negative (less than zero).
printf ("-"); // If true, it will print out a negative sign to publicly display its negativity.
n = -n; // It will convert the inputted number (n) into a posivite number by multiplying it by -1.
}
printfspace2 (n); // It will then send the positive number into printfspace2 for proper formatting (only accepts positive numbers).
}
// Stores all of the relevant player data, separate from the main code to avoid direct interactions.
struct playerData
{
unsigned long long int money; //Balance of the player ($)
/*
NOTE TO SELF: Need a code to ensure that all inputted bets meet the minimum bet and do not exceed the player's balance (money)
*/
int mainBet; //How much the player currently has bet
int mainBetEarnings;
int splitBet;
int pairBet;
int insuranceBet;
};
int main(void)
{
// Card values in respect to Blackjack rules. Ace card can be 1 or 11; however, will not be given a value due to the high conditionality.
// Ace Card will likely have a base value of 11, but be changed conditionally to 1 if it benefits the hand.
int aceCard; // Ace Card will = 1 on rand
int twoCard = 2; // 2 Card will = 2 on rand
int threeCard = 3; // 3 Card will = 3 on rand
int fourCard = 4; // 4 Card will = 4 on rand
int fiveCard = 5; // 5 Card will = 5 on rand
int sixCard = 6; // 6 Card will = 6 on rand
int sevenCard = 7; // 7 Card will = 7 on rand
int eightCard = 8; // 8 Card will = 8 on rand
int nineCard = 9; // 9 Card will = 9 on rand
int tenCard = 10; // 10 Card will = 10 on rand
int jackCard = 10; // Jack Card will = 11 on rand
int queenCard = 10; // Queen Card will = 12 on rand
int kingCard = 10; // King Card will = 13 on rand
int pairLower = 1;
int pairUpper = 59;
int pairNum;
int sleepLower = 50;
int sleepUpper = 1801;
int sleepNum;
int i;
int lower = 1;
int upper = 13;
int count = 1;
int seedLower = 1;
int seedUpper = 998;
int seedCount = 1;
int seedAdd = 1;
int drawPair;
struct playerData playerData;
playerData.money = 750; // Intitializes the player's money prior to the loading in of the game. Player always starts off with 750 cash.
playerData.mainBet = 0;
playerData.splitBet = 0;
playerData.pairBet = 0;
playerData.insuranceBet = 0;
int betSource = 0;
int splitHandCheck;
int handHitCheck;
int handOneStandCheck;
int handTwoStandCheck;
int handOneCanDouble;
int handTwoCanDouble;
int canSplitHand;
char mainMenuOption; // Variable holder to log player main menu navigation choice.
int mainMenuSelection;
int goToMainMenuChecker;
bool hasPlayedBefore = false; // Determines whether the player has played before.
char tableSelectionOption; // Variable holder to long player table selection choice.
int tableSelection;
char MenuNavigationOption;
int MenuNavigation;
int enterKeyPress = 0;
// Table wager ranges settings:
// Table One wager ranges
int tableOneMin = 10;
int tableOneMax = 200;
//Table One wager intervals
int tableOneInterval1 = 10;
int tableOneInterval2 = 25;
int tableOneInterval3 = 50;
int tableOneInterval4 = 100;
//Table One pair max
int tableOnePairMax = 50;
//Table One pair bet intervals
int tableOnePair1 = 5;
int tableOnePair2 = 10;
int tableOnePair3 = 25;
int tableOnePair4 = 50;
// Table Two wager ranges
int tableTwoMin = 250;
int tableTwoMax = 5000;
//Table Two wager intervals
int tableTwoInterval1 = 250;
int tableTwoInterval2 = 500;
int tableTwoInterval3 = 1000;
int tableTwoInterval4 = 2500;
//Table Two pair max
int tableTwoPairMax = 250;
//Table Two pair bet intervals
int tableTwoPair1 = 25;
int tableTwoPair2 = 50;
int tableTwoPair3 = 100;
int tableTwoPair4 = 250;
// Table Three wager ranges
int tableThreeMin = 1000;
int tableThreeMax = 20000;
//Table Three wager intervals
int tableThreeInterval1 = 1000;
int tableThreeInterval2 = 2500;
int tableThreeInterval3 = 5000;
int tableThreeInterval4 = 10000;
//Table Three pair max
int tableThreePairMax = 2500;
//Table Three pair bet intervals
int tableThreePair1 = 250;
int tableThreePair2 = 500;
int tableThreePair3 = 1000;
int tableThreePair4 = 2500;
// Table Four wager ranges
int tableFourMin = 5000;
int tableFourMax = 100000;
//Table Four wager intervals
int tableFourInterval1 = 5000;
int tableFourInterval2 = 10000;
int tableFourInterval3 = 25000;
int tableFourInterval4 = 50000;
//Table Four pair max
int tableFourPairMax = 10000;
//Table Four pair bet intervals
int tableFourPair1 = 1000;
int tableFourPair2 = 2500;
int tableFourPair3 = 5000;
int tableFourPair4 = 10000;
// Table Five wager ranges
int tableFiveMin = 10000;
int tableFiveMax = 1000000;
//Table Five wager intervals
int tableFiveInterval1 = 10000;
int tableFiveInterval2 = 25000;
int tableFiveInterval3 = 100000;
int tableFiveInterval4 = 500000;
//Table Five pair max
int tableFivePairMax = 100000;
//Table Five pair bet intervals
int tableFivePair1 = 10000;
int tableFivePair2 = 25000;
int tableFivePair3 = 50000;
int tableFivePair4 = 100000;
int activeTableMin;
int activeTableMax;
int activeTableInterval1;
int activeTableInterval2;
int activeTableInterval3;
int activeTableInterval4;
int activeTablePairMax;
int activeTablePair1;
int activeTablePair2;
int activeTablePair3;
int activeTablePair4;
// Player Bets Section
char playerMainBetEntry;
int playerMainBet; // Self-explanatory
char playerSplitBetEntry;
int playerSplitBet; // Only if the player is dealth a pair of cards and can afford to double their wage.
char playerPairBetEntry;
int playerPairBet; // Prior to the dealing of cards.
char playerInsuranceBetEntry;
int playerInsuranceBet; // Only if the dealer shows an Ace -- Player must bet HALF of their wager.
// Section END
GameMainMenu: // Game Main Menu Section -- Checkpoint
printf("\nWELCOME TO BLACKJACK!\n\n");
printf("MENU OPTIONS\n\n");
if(hasPlayedBefore == false) // Calls on the value of the boolean to see whether the player has played before.
{
printf("1) PLAY\n");
}
else
{
printf("1) CONTINUE\n");
}
printf("2) HOW TO PLAY\n");
printf("3) SETTINGS\n");
printf("4) CREDITS\n");
printf("5) EXIT GAME\n");
printf("\nINPUT OPTION NUMBER:\t");
scanf(" %c", &mainMenuOption); // Scanning player decision
// printf("%c\n", mainMenuOption); // TESTER
mainMenuSelection = mainMenuCompare(mainMenuOption);
if(mainMenuSelection == 1)
{
//Runs the game
if(hasPlayedBefore == false) // Plays irrelevant backstory if the game hasn't been booted up before.
{
// Irrelevant backstory (for lore purposes)
printf("\n\n\nYou are stuck in a dead-end job with measely pay.\n");
Sleep(2000);
printf("\nYou need $1750 to pay for rent back in California and at least another $500 to get by until the next paycheck.\n");
Sleep(2000);
printf("\nYour recent paycheck amounted to roughly $500, but this only covers basic expenses since your roomates moved out.\n");
Sleep(2000);
printf("\nYou liquidate your paycheck and tap into your savings because YOU'RE HEADING TO VEGAS BABY!\n");
Sleep(2000);
printf("\nWith only $750 and an itch to go BIG or go BROKE, you hit the BLACKJACK table.\n");
Sleep(2000);
printf("\n\nYour legendary tale begins with your first bet...\n\n\n");
}
else // Welcomes the player back, skips the irrelevant backstory.
{
printf("\n\nWELCOME BACK!\n\n");
}
TableSelectionMenu: // Checkpoint of Table selection menu.
printf("\n\nBLACKJACK TABLE STAKES\n\n");
printf("1) TABLE ONE\t MINIMUM: $");
printfspace2(tableOneMin);
printf("\t\t MAXIMUM: $");
printfspace2(tableOneMax);
printf("\t\t\t PAIR BET MAX: $");
printfspace2(tableOnePairMax);
printf("\n");
printf("2) TABLE TWO\t MINIMUM: $");
printfspace2(tableTwoMin);
printf("\t\t MAXIMUM: $");
printfspace2(tableTwoMax);
printf("\t\t PAIR BET MAX: $");
printfspace2(tableTwoPairMax);
printf("\n");
printf("3) TABLE THREE\t MINIMUM: $");
printfspace2(tableThreeMin);
printf("\t MAXIMUM: $");
printfspace2(tableThreeMax);
printf("\t\t PAIR BET MAX: $");
printfspace2(tableThreePairMax);
printf("\n");
printf("4) TABLE FOUR\t MINIMUM: $");
printfspace2(tableFourMin);
printf("\t MAXIMUM: $");
printfspace2(tableFourMax);
printf("\t\t PAIR BET MAX: $");
printfspace2(tableFourPairMax);
printf("\n");
printf("5) TABLE FIVE\t MINIMUM: $");
printfspace2(tableFiveMin);
printf("\t MAXIMUM: $");
printfspace2(tableFiveMax);
printf("\t\t PAIR BET MAX: $");
printfspace2(tableFivePairMax);
printf("\n");
printf("\n6) RETURN TO MAIN MENU\n\n");
printf("Please select the table stakes you wish to participate in by entering the corresponding number: ");
scanf(" %c", &tableSelectionOption);
tableSelection = tableSelectionCompare(tableSelectionOption);
/* Table Selection (for different tiers)
Table 1: Min $10 ; Max $200
Table 2: Min $250 ; Max $25,000
Table 3: Min $1,000 ; Max $100,000
Table 4: Min $5,000 ; Max $500,000
Table 5: Min $10,000 ; Max $1,000,000
*/
if (tableSelection == 1)
{
if (playerData.money < tableOneMin) // Checks if the player meets the table's wager minimum requirements ($10)
{
// This instance should be impossible as the game would end if the player dropped below $10 (only number possible being $0).
// If somehow the player returned to the menu while at $0 and attempted to return to the table, this will ensure that the program ends in 'GAME OVER'.
printf("\n\nOh no! You lack the funds to enter the minimum bet for this table! (Less than $");
printfspace2(tableOneMin);
printf(")\n");
printf("Unfortunately this means you went broke trying to avoid going broke!\n\n");
printf("GAME OVER!\n");
Sleep(3000);
return 0; // Ends program
}
else
{
// GAME RUNS WITH TABLE ONE SETTINGS
activeTableMin = tableOneMin;
activeTableMax = tableOneMax;
activeTableInterval1 = tableOneInterval1;
activeTableInterval2 = tableOneInterval2;
activeTableInterval3 = tableOneInterval3;
activeTableInterval4 = tableOneInterval4;
activeTablePairMax = tableOnePairMax;
activeTablePair1 = tableOnePair1;
activeTablePair2 = tableOnePair2;
activeTablePair3 = tableOnePair3;
activeTablePair4 = tableOnePair4;
goto GameStart;
// Change settings, then goto GameStart:
}
}
else if (tableSelection == 2)
{
if (playerData.money < tableTwoMin) // Checks if the player meets the table's wager minimum requirements ($250)
{
printf("\n\nOh no! You lack the funds to enter the minimum bet for this table! (Less than $");
printfspace2(tableTwoMin);
printf(")\n");
printf("Please select another option!\n\n");
Sleep(3000);
goto TableSelectionMenu;
}
else
{
// GAME RUNS WITH TABLE TWO SETTINGS
activeTableMin = tableTwoMin;
activeTableMax = tableTwoMax;
activeTableInterval1 = tableTwoInterval1;
activeTableInterval2 = tableTwoInterval2;
activeTableInterval3 = tableTwoInterval3;
activeTableInterval4 = tableTwoInterval4;
activeTablePairMax = tableTwoPairMax;
activeTablePair1 = tableTwoPair1;
activeTablePair2 = tableTwoPair2;
activeTablePair3 = tableTwoPair3;
activeTablePair4 = tableTwoPair4;
goto GameStart;
// Change settings, then goto GameStart:
}
}
else if (tableSelection == 3)
{
if (playerData.money < tableThreeMin)
{
printf("\n\nOh no! You lack the funds to enter the minimum bet for this table! (Less than $");
printfspace2(tableThreeMin);
printf(")\n");
printf("Please select another option!\n\n");
Sleep(3000);
goto TableSelectionMenu;
}
else
{
// GAME RUNS WITH TABLE THREE SETTINGS
activeTableMin = tableThreeMin;
activeTableMax = tableThreeMax;
activeTableInterval1 = tableThreeInterval1;
activeTableInterval2 = tableThreeInterval2;
activeTableInterval3 = tableThreeInterval3;
activeTableInterval4 = tableThreeInterval4;
activeTablePairMax = tableThreePairMax;
activeTablePair1 = tableThreePair1;
activeTablePair2 = tableThreePair2;
activeTablePair3 = tableThreePair3;
activeTablePair4 = tableThreePair4;
goto GameStart;
// Change settings, then goto GameStart:
}
}
else if (tableSelection == 4)
{
if (playerData.money < tableFourMin)
{
printf("\n\nOh no! You lack the funds to enter the minimum bet for this table! (Less than $");
printfspace2(tableFourMin);
printf(")\n");
printf("Please select another option!\n\n");
Sleep(3000);
goto TableSelectionMenu;
}
else
{
// GAME RUNS WITH TABLE FOUR SETTINGS
activeTableMin = tableFourMin;
activeTableMax = tableFourMax;
activeTableInterval1 = tableFourInterval1;
activeTableInterval2 = tableFourInterval2;
activeTableInterval3 = tableFourInterval3;
activeTableInterval4 = tableFourInterval4;
activeTablePairMax = tableFourPairMax;
activeTablePair1 = tableFourPair1;
activeTablePair2 = tableFourPair2;
activeTablePair3 = tableFourPair3;
activeTablePair4 = tableFourPair4;
goto GameStart;
// Change settings, then goto GameStart:
}
}
else if (tableSelection == 5)
{
if (playerData.money < tableFiveMin)
{
printf("\n\nOh no! You lack the funds to enter the minimum bet for this table! (Less than $");
printfspace2(tableFiveMin);
printf(")\n");
printf("Please select another option!\n\n");
Sleep(3000);
goto TableSelectionMenu;
}
else
{
// GAME RUNS WITH TABLE FIVE SETTINGS
activeTableMin = tableFiveMin;
activeTableMax = tableFiveMax;
activeTableInterval1 = tableFiveInterval1;
activeTableInterval2 = tableFiveInterval2;
activeTableInterval3 = tableFiveInterval3;
activeTableInterval4 = tableFiveInterval4;
activeTablePairMax = tableFivePairMax;
activeTablePair1 = tableFivePair1;
activeTablePair2 = tableFivePair2;
activeTablePair3 = tableFivePair3;
activeTablePair4 = tableFivePair4;
goto GameStart;
// Change settings, then goto GameStart:
}
}
else if (tableSelection == 6)
{
//PLAYER CALLS TO GO BACK TO MAIN MENU
printf("\n\nRETURNING TO THE MAIN MENU\n\n");
Sleep(2000);
goto GameMainMenu;
}
else
{
// Invalid option
printf("\nINVALID OPTION, PLEASE INPUT A NUMBER CORRESPONDING TO AVAILABLE EXISTING OPTION!\n\n");
Sleep(3000);
goto TableSelectionMenu;
}
GameStart: //Beginning of the game. Point of reference to return to after the result of a play-through.
hasPlayedBefore = true;
// Going to assume that both the player and dealer can hit a maximum number of 20 times (very unrealistic).
// The dealer will likely never reach this; however, the player has an infinitely small chance of reaching this ceiling.
int dealerHand[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int dealerHandValue[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int dealerHandTotal = 0;
int dealerHandTotal2 = 0;
int playerHand[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int playerHandValue[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int playerHandTotal = 0;
int playerHandTotal2 = 0;
int playerSecondHand[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; // Only on split bets off of pairs
int playerSecondHandValue[20] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int playerSecondHandTotal = 0;
int playerSecondHandTotal2 = 0;
int playerHandAces = 0;
int playerHand2Aces = 0;
int dealerHandAces = 0;
drawPair = 0;
playerData.mainBet = 0;
playerData.mainBetEarnings = 0;
playerData.pairBet = 0;
playerData.splitBet = 0;
playerData.insuranceBet = 0;
betSource = 0;
splitHandCheck = 0;
handHitCheck = 0;
handOneStandCheck = 0;
handTwoStandCheck = 0;
handOneCanDouble = 1;
handTwoCanDouble = 1;
canSplitHand = 1;
enterKeyPress = 0;
MainWager:
printf("\n\n");
// Displays user money
printf("CASH: $");
printfspace2(playerData.money);
printf("\t\t\t");
// Displays current table's minimum and maximum bets (settings)
printf("MINIMUM: $");
printfspace2(activeTableMin);
printf("\t\t");
printf("MAXIMUM: $");
printfspace2(activeTableMax);