Open Question: Generating simple poker game in C++?

include #include #include #define sSize 4 // Suit size array #define fsize 13 // Face size array #define deckColSize 13 // Deck column size #define deckRowSize 4 // Deck row size #define pokerColSize 2 // Poker column size #define pokerRowSize 5 // Poker row size #define cardAmount 52 // A Card set is 52 cards void ShuffleCard(int [][13] , int , int ); void Swap(int *, int * ); void TakeCard( int [][2], int [][deckColSize]); void deal(int [][2],const char *[], const char *[]); void cardQuality( int [][2] ); int main () { // Variable declaration ------------------------------- const char *suit[sSize] = {"\3", "\4", "\5", "\6"}; // Array contain suits const char *face[fsize]= {"A", "2", "3", "4", "5", // Array contain faces "6", "7", "8", "9", "10", "J", "Q", "K"}; int deck[deckRowSize][deckColSize]; // Double-subcript array contain 52 card int row , column , card; int poker1[pokerRowSize][pokerColSize], poker2[pokerRowSize][pokerColSize], poker3[pokerRowSize][pokerColSize], poker4[pokerRowSize][pokerColSize], poker5[pokerRowSize][pokerColSize], poker6[pokerRowSize][pokerColSize], poker7[pokerRowSize][pokerColSize], poker8[pokerRowSize][pokerColSize], poker9[pokerRowSize][pokerColSize], poker10[pokerRowSize][pokerColSize]; srand(time(NULL)); card = 1 ; for (row = 0 ; row <= deckRowSize - 1 ; row++ ) { for (column = 0 ; column <= deckColSize - 1 ; column++ ) { deck[row][column] = card ; card++; } } ShuffleCard( deck,deckColSize,deckRowSize ) ; printf("Poker hand1's card :\n\n"); TakeCard( poker1, deck ); deal(poker1,suit, face); cardQuality(poker1); printf("\n\n\nPoker hand2's card :\n\n"); TakeCard( poker2, deck ); deal(poker2,suit, face); cardQuality(poker2); printf("Poker hand3's card :\n\n"); TakeCard( poker3, deck ); deal(poker3,suit, face); cardQuality(poker3); printf("\n\n\nPoker hand4's card :\n\n"); TakeCard( poker4, deck ); deal(poker4,suit, face); cardQuality(poker4); printf("Poker hand5's card :\n\n"); TakeCard( poker5, deck ); deal(poker5,suit, face); cardQuality(poker5); printf("\n\n\nPoker hand6's card :\n\n"); TakeCard( poker6, deck ); deal(poker6,suit, face); cardQuality(poker6); printf("Poker hand7's card :\n\n"); TakeCard( poker7, deck ); deal(poker7,suit, face); cardQuality(poker7); printf("\n\n\nPoker hand8's card :\n\n"); TakeCard( poker8, deck ); deal(poker8,suit, face); cardQuality(poker8); printf("\n\n"); printf("Poker hand9's card :\n\n"); TakeCard( poker9, deck ); deal(poker9,suit, face); cardQuality(poker9); printf("\n\n\nPoker hand10's card :\n\n"); TakeCard( poker10, deck ); deal(poker10,suit, face); cardQuality(poker10); return 0; } // Shuffling card funtion ------------------------------------------- void ShuffleCard( int table[][13], int columnSize,int rowSize ){ int tRow, tColumn, randRow, randColumn ; for ( tRow = 0 ; tRow <= rowSize - 1 ; tRow++ ) { for (tColumn = 0; tColumn <= columnSize - 1 ; tColumn++ ) { randRow = rand() % 4 ; randColumn = rand() % 13; Swap(&table[tRow][tColumn],&table[randRow][randColumn]); } } } //Swap card funtion ------------------------------------------------ void Swap(int *cell1 , int *cell2) { int hold = *cell1; *cell1= *cell2; *cell2= hold; } // Poker hand take five card from shuffled cards---------------------- void TakeCard(int player[][2] , int shuffledCard[][13]) { int sCard, sRow, sColumn, pRow = 0 , pColumn = 0; static int cardStart = 1; for (sCard = cardStart ; sCard <= cardStart + 4; sCard++ ) { for (sRow = 0 ; sRow <= 3; sRow++ ){ for(sColumn = 0 ; sColumn <= 12; sColumn++ ){ if (shuffledCard[sRow][sColumn] == sCard ){ player[pRow][pColumn] = sRow; pColumn++; player[pRow][pColumn] = sColumn; pColumn--; pRow++; } } } } cardStart = sCard; } // Dealing five card funtion-------------------------------------------- void deal(int pokerHand[][2], const char *suit1[], const char *face1[]) { int a , b; for ( a = 0 ; a <= 4; a++ ){ b = 0; printf("%s&quo

29 Jul 2010, 11:47 pm | click here to view more



©2008 Poker Interactif. All rights reserved.