-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
72 lines (47 loc) · 1.16 KB
/
main.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
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include "black.h"
extern struct card deck[CARDS];
int main(void)
{
srand ((unsigned) time(NULL));
struct black table;
table.bet = 0;
table.credit = 50;
table.cards_dealt = 0;
int ans; /* For Hit/S answers */
printf("\n\nStep right up to the Blackjack tables\n\n");
printf("Ok, Get ready for casino action * Blackjack pays 3 to 2 * You're credit is 50$ * Press enter to start, q to quit\n\n");
shuffle(deck);
if(!init_game(&table))
return 0;
for (;;) {
printCards(&table);
printf("\n\nHit or stand (H/S)? ");
do {
ans = toupper(getchar());
if (ans == 'H' || ans == 'S')
break;
else if (ans == 'Q' || ans =='X')
return 0;
else
continue;
} while(1);
if (ans == 'H') {
getCard(&table, PLY);
if (table.player[CPU].total < 17)
getCard(&table, CPU);
}
if (ans == 'S') {
if (table.player[CPU].total < 17)
getCard(&table, CPU);
else
table.check_stand = 1;
}
if (!findWinner(&table))
return 0;
} /* end of for(;;) */
return 0;
}