Share Pastebin
Guest
Public paste!

fengshaun

By: a guest | Mar 5th, 2008 | Syntax: C++ | Size: 18.66 KB | Hits: 103 | Expires: Never
Copy text to clipboard
  1. //definitions
  2.  
  3. #ifndef DEFINITIONS_H
  4. #define DEFINITIONS_H
  5.  
  6. const int totalCards = 52;
  7. const int deckRows = 4;
  8. const int deckColumns = 13;
  9.  
  10. int deck[ deckRows ][ deckColumns ] = { 0 };
  11.  
  12. char *suite[] = { "Hearts", "Clubs", "Diamonds", "Spades" };
  13. char *face[] = { "Ace", "Deuce", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King" };
  14.  
  15. #endif
  16.  
  17.  
  18. //Class Player definition
  19.  
  20. #ifndef PLAYER_H
  21. #define PLAYER_H
  22.  
  23. #include "definitions.h"
  24.  
  25. class Player
  26. {
  27.         public:
  28.                 Player( int );
  29.                 ~Player();
  30.                
  31.                 void deal( int, int );
  32.                 void printCards();
  33.                 void rank();
  34.  
  35.         private:
  36.  
  37.                 char *cards[ 7 ][ 2 ];
  38.                 char *hold[ 1 ];
  39.                
  40.                 bool highCards;  //DONE
  41.                 bool pair; //DONE
  42.                 bool twoPair;  //DONE
  43.                 bool threeOfAKind; //DONE
  44.                 bool straight;
  45.                 bool flush;  //DONE
  46.                 bool fullHouse;  //DONE
  47.                 bool fourOfAKind;  //DONE
  48.                 bool straightFlush;
  49.                 bool royalFlush;
  50.  
  51.                 unsigned int pairCounter;
  52.                 unsigned int playerNumber;
  53.  
  54.                 friend class CommCards;
  55.                 friend void save( Player *, Player *, Player * );
  56.                 friend void printResults( Player *, Player *, Player * );
  57.                 friend void makeTrue( Player *, Player *, Player * );
  58.                
  59. };
  60.  
  61. Player::Player( int pNum ) {
  62.         cards[ 7 ][ 2 ];
  63.         hold[ 1 ];
  64.  
  65.         highCards = false;
  66.         pair = false;
  67.         twoPair = false;
  68.         threeOfAKind = false;
  69.         straight = false;
  70.         flush = false;
  71.         fullHouse = false;
  72.         fourOfAKind = false;
  73.         straightFlush = false;
  74.         royalFlush = false;
  75.  
  76.         pairCounter = 0;
  77.  
  78.         playerNumber = pNum;
  79. }
  80.  
  81. Player::~Player() {}
  82.  
  83. void Player::deal( int x, int y ) {
  84.         //first card
  85.         for( int row = 0; row < deckRows; row++ ) {
  86.                 for( int column = 0; column < deckColumns; column++ ) {
  87.                         if( deck[ row ][ column ] == x ) {
  88.                                 cards[ 0 ][ 0 ] = face[ column ] + '\0';
  89.                                 cards[ 0 ][ 1 ] = suite[ row ] + '\0';
  90.                         }
  91.                 }
  92.         }
  93.        
  94.         //second card
  95.         for( int row = 0; row < deckRows; row++ ) {
  96.                 for( int column = 0; column < deckColumns; column++ ) {
  97.                         if( deck[ row ][ column ] == y ) {
  98.                                 cards[ 1 ][ 0 ] = face[ column ] + '\0';
  99.                                 cards[ 1 ][ 1 ] = suite[ row ] + '\0';
  100.                         }
  101.                 }
  102.         }
  103.  
  104. }
  105.  
  106. void Player::printCards() {
  107.         cout << cards[ 0 ][ 0 ] << " of " << cards[ 0 ][ 1 ] << endl;
  108.         cout << cards[ 1 ][ 0 ] << " of " << cards[ 1 ][ 1 ] << endl;
  109. }
  110.  
  111. void Player::rank() {
  112.         int pairC1;
  113.         int pairC2;
  114.         int pair2C1;
  115.         int pair2C2;
  116.         int threeC1;
  117.         int threeC2;
  118.         int threeC3;
  119.         int straightC1;
  120.         int straightC2;
  121.         int straightC3;
  122.         int straightC4;
  123.         int straightC5;
  124.         int flushC1;
  125.         int flushC2;
  126.         int flushC3;
  127.         int flushC4;
  128.         int flushC5;
  129.         int fourC1;
  130.         int fourC2;
  131.         int fourC3;
  132.         int fourC4;
  133.  
  134.         int hearts = 0;
  135.         int clubs = 0;
  136.         int spades = 0;
  137.         int diamonds = 0;
  138.  
  139.         //THREE OF A KIND
  140.         for( threeC1 = 0; threeC1 < 7; threeC1++ ) {
  141.                 for( threeC2 = 0; threeC2 < 7; threeC2++ ) {
  142.                         if( threeC1 > threeC2 && cards[ threeC1 ][ 0 ] == cards[ threeC2 ][ 0 ] ) {
  143.                                 hold[ 0 ] = cards[ threeC1 ][ 0 ];
  144.                                
  145.                                 for( threeC3 = 0; threeC3 < 7; threeC3++ ) {
  146.                                         if( threeC3 != threeC1 && threeC3 != threeC2 ) {
  147.                                                 if( cards[ threeC3 ][ 0 ] == cards[ threeC1 ][ 0 ] && threeOfAKind == false ) {
  148.                                                         cout << "player " << playerNumber << " has a three of a kind: " << endl;
  149.                                                         cout << cards[ threeC1 ][ 0 ] << " of " << cards[ threeC1 ][ 1 ] << endl;
  150.                                                         cout << cards[ threeC2 ][ 0 ] << " of " << cards[ threeC2 ][ 1 ] << endl;
  151.                                                         cout << cards[ threeC3 ][ 0 ] << " of " << cards[ threeC3 ][ 1 ] << endl << endl;
  152.                                                         threeOfAKind = true;
  153.                                                 }
  154.                                         }
  155.                                 }
  156.                         }
  157.                 }
  158.         }
  159.        
  160.         //PAIRS
  161.         for( pairC1 = 0; pairC1 < 7; pairC1++ ) {
  162.         for( pairC2 = 0; pairC2 < 7; pairC2++ ) {
  163.                         if( pairC1 > pairC2 && cards[ pairC1 ][ 0 ] == cards[ pairC2 ][ 0 ] && pairCounter <= 2 ) {
  164.                                 cout << "Player " << playerNumber << " has a pair of: " << endl;
  165.                                 cout << cards[ pairC1 ][ 0 ] << " of " << cards[ pairC1 ][ 1 ] << " AND "
  166.                                                  << cards[ pairC2 ][ 0 ] << " of " << cards[ pairC2 ][ 1 ] << endl;
  167.                                 pairCounter++;
  168.                                 pair = true;
  169.                         }
  170.                 }
  171.         }
  172.  
  173.         //Two Pair
  174.         if( pairCounter >= 2 ) {
  175.                 cout << "Player has two pairs." << endl;
  176.                 twoPair = true;
  177.         }
  178.  
  179.         //FLUSH
  180.         for( int card1 = 0; card1 < 7; card1++ ) {
  181.                 if( cards[ card1 ][ 1 ] == suite[ 0 ] ) {
  182.                         hearts++;
  183.                 }
  184.                 if( cards[ card1 ][ 1 ] == suite[ 1 ] ) {
  185.                         clubs++;
  186.                 }
  187.                 if( cards[ card1 ][ 1 ] == suite[ 2 ] ) {
  188.                         diamonds++;
  189.                 }
  190.                 if( cards[ card1 ][ 1 ] == suite[ 3 ] ) {
  191.                         spades++;
  192.                 }
  193.         }
  194.         if( hearts >= 5 ) {
  195.                 cout << "Player " << playerNumber << " has a flush of Hearts" << endl;
  196.                 flush = true;
  197.         }
  198.         else if( clubs >= 5 ) {
  199.                 cout << "Player " << playerNumber << " has a flush of Clubs" << endl;
  200.                 flush = true;
  201.         }
  202.         else if( diamonds >= 5 ) {
  203.                 cout << "Player " << playerNumber << " has a flush of Diamonds" << endl;
  204.                 flush = true;
  205.         }
  206.         else if( spades >= 5 ) {
  207.                 cout << "Player " << playerNumber << " has a flush of Spades" << endl;
  208.                 flush = true;
  209.         }
  210.  
  211.  
  212.         //Four of a kind
  213.         for( fourC1 = 0; fourC1 < 7; fourC1++ ) {
  214.                 for( fourC2 = 0; fourC2 < 7; fourC2++ ) {
  215.                         for( fourC3 = 0; fourC3 < 7; fourC3++ ) {
  216.                                 for( fourC4 = 0; fourC4 < 7; fourC4++ ) {
  217.                                         if( fourC1 > fourC2 && fourC2 > fourC3 && fourC3 > fourC4 ) {
  218.                                                 if( cards[ fourC1 ][ 0 ] == cards[ fourC2 ][ 0 ] && cards[ fourC2 ][ 0 ] == cards[ fourC3 ][ 0 ] && cards[ fourC3 ][ 0 ] == cards[ fourC4 ][ 0 ] && cards[ fourC4 ][ 0 ] == cards[ fourC1 ][ 0 ] ) {
  219.                                                         cout << "Player " << playerNumber << " has a four of kind of: " << endl;
  220.                                                         cout << cards[ fourC1 ][ 0 ] << " of " << cards[ fourC1 ][ 1 ] << endl
  221.                                                                         << cards[ fourC2 ][ 0 ] << " of " << cards[ fourC2 ][ 1 ] << endl
  222.                                                                         << cards[ fourC3 ][ 0 ] << " of " << cards[ fourC3 ][ 1 ] << endl
  223.                                                                         << cards[ fourC4 ][ 0 ] << " of " << cards[ fourC4 ][ 1 ] << endl << endl;
  224.                                                         fourOfAKind = true;
  225.                                                 }
  226.                                         }
  227.                                 }
  228.                         }
  229.                 }
  230.         }
  231.  
  232.         //full house
  233.         if( pair && threeOfAKind ) {
  234.                 cout << "Player has a Full House." << endl;
  235.                 fullHouse = true;
  236.         }
  237.  
  238.         //High Cards
  239.         if( !( pair || twoPair || threeOfAKind || straight || flush || fullHouse || fourOfAKind || straightFlush || royalFlush) )  {
  240.                 cout << "Player has High Cards." << endl;
  241.                 highCards = true;
  242.         }
  243.        
  244. }
  245.  
  246. #endif
  247.  
  248.  
  249. //community cards
  250.  
  251. #ifndef COMMUNITY_CARDS_H
  252. #define COMMUNITY_CARDS_H
  253.  
  254. #include "definitions.h"
  255. #include "player.h"
  256.  
  257. class Player;
  258.  
  259. class CommCards
  260. {
  261.         public:
  262.                 CommCards();
  263.                 ~CommCards();
  264.                
  265.                 void deal( Player *, int, int, int, int, int);
  266.                 void print( Player * );
  267.  
  268.         private:
  269.                 int flop1Num;
  270.                 int flop2Num;
  271.                 int flop3Num;
  272.                 int turnNum;
  273.                 int riverNum;
  274.  
  275. };
  276.  
  277. CommCards::CommCards() {
  278.         flop1Num = flop2Num = flop3Num = turnNum = riverNum = 0;
  279. }
  280.  
  281. CommCards::~CommCards() {}
  282.  
  283. void CommCards::deal( Player *player, int a, int b, int c, int d, int e ) {
  284.         flop1Num = a;
  285.         flop2Num = b;
  286.         flop3Num = c;
  287.         turnNum = d;
  288.         riverNum = e;
  289.  
  290.         for( int row = 0; row < deckRows; row++ ) {
  291.                 for( int column = 0; column < deckColumns; column++ ) {
  292.                        
  293.                         if( deck[ row ][ column ] == flop1Num ) {
  294.                                 player->cards[ 2 ][ 0 ] = face[ column ] + '\0';
  295.                                 player->cards[ 2 ][ 1 ] = suite[ row ] + '\0';
  296.                         }
  297.                        
  298.                         else if( deck[ row ][ column ] == flop2Num ) {
  299.                                 player->cards[ 3 ][ 0 ] = face[ column ] + '\0';
  300.                                 player->cards[ 3 ][ 1 ] = suite[ row ] + '\0';
  301.                         }
  302.                        
  303.                         else if( deck[ row ][ column ] == flop3Num ) {
  304.                                 player->cards[ 4 ][ 0 ] = face[ column ] + '\0';
  305.                                 player->cards[ 4 ][ 1 ] = suite[ row ] + '\0';
  306.                         }
  307.                        
  308.                         else if( deck[ row ][ column ] == turnNum ) {
  309.                                 player->cards[ 5 ][ 0 ] = face[ column ] + '\0';
  310.                                 player->cards[ 5 ][ 1 ] = suite[ row ] + '\0';
  311.                         }
  312.                        
  313.                         else if( deck[ row ][ column ] == riverNum ) {
  314.                                 player->cards[ 6 ][ 0 ] = face[ column ] + '\0';
  315.                                 player->cards[ 6 ][ 1 ] = suite[ row ] + '\0';
  316.                         }
  317.                        
  318.                 }
  319.         }
  320.        
  321. }
  322.  
  323. void CommCards::print( Player *player ) {
  324.        
  325.         cout << "Flop cards are: " << endl;
  326.         cout << player->cards[ 2 ][ 0 ] << " of " << player->cards[ 2 ][ 1 ] << endl;
  327.         cout << player->cards[ 3 ][ 0 ] << " of " << player->cards[ 3 ][ 1 ] << endl;
  328.         cout << player->cards[ 4 ][ 0 ] << " of " << player->cards[ 4 ][ 1 ] << endl;
  329.         cout << endl;
  330.  
  331.         cout << "The turn is: " << endl;
  332.         cout << player->cards[ 5 ][ 0 ] << " of " << player->cards[ 5 ][ 1 ] << endl;
  333.         cout << endl;
  334.  
  335.         cout << "The river is: " << endl;
  336.         cout << player->cards[ 6 ][ 0 ] << " of " << player->cards[ 6 ][ 1 ] << endl;
  337.         cout << endl;
  338.        
  339. }
  340.  
  341. #endif
  342.  
  343.  
  344. //A simple, automatic poker game.
  345. //licenced under GPL 3.0 or above
  346.  
  347. #include <iostream>
  348. #include <ctime>
  349. #include <cstdlib>
  350. #include <iomanip>
  351. #include <string>
  352. #include <fstream>
  353. using namespace std;
  354.  
  355. #include "player.h"
  356. #include "community_cards.h"
  357. #include "definitions.h"
  358.  
  359. void shuffle();
  360. void save( Player *, Player *, Player * );
  361. void printResults( Player *, Player *, Player * );
  362.  
  363. int main ()
  364. {
  365.        
  366.         cout << endl;
  367.        
  368.         srand( time( 0 ) );
  369.         cout << "time is: " << time( 0 ) << endl << endl;
  370. //      sleep( 1 );
  371.         shuffle();
  372.        
  373.         Player player1( 1 );
  374.         Player player2( 2 );
  375.         Player player3( 3 );
  376.         CommCards communityCards;
  377.        
  378.         communityCards.deal( &player1, 7, 8, 9, 11, 13 );
  379.         communityCards.deal( &player2, 7, 8, 9, 11, 13 );
  380.         communityCards.deal( &player3, 7, 8, 9, 11, 13 );
  381.        
  382.         player1.deal( 1, 2 );
  383.         cout << "Player 1 has:" << endl;
  384.         player1.printCards();
  385.         cout << endl;
  386.  
  387.         player2.deal( 3, 4 );
  388.         cout << "Player 2 has:" << endl;
  389.         player2.printCards();
  390.         cout << endl;
  391.  
  392.         player3.deal( 5, 6 );
  393.         cout << "Player 3 has:" << endl;
  394.         player3.printCards();
  395.         cout << endl;
  396.        
  397.         communityCards.print( &player1 );
  398.         cout << "checking hands: " << endl;
  399. //      sleep( 2 );
  400.         player1.rank();
  401.         cout << endl;
  402. //      sleep( 1 );
  403.         player2.rank();
  404.         cout << endl;
  405. //      sleep( 1 );
  406.         player3.rank();
  407.         cout << endl;
  408.        
  409. //      makeTrue( &player1, &player2, &player3 );
  410.         printResults( &player1, &player2, &player3 );
  411.         cout << endl;
  412.  
  413.         char yn;
  414.         cout << endl << "Game will now exit, do you want to save your game?( y/n ) ";
  415.         cin >> yn;
  416.         switch( yn ) {
  417.                 case 'n':
  418.                 case 'N':
  419.                         exit( 1 );
  420.  
  421.                 case 'y':
  422.                 case 'Y':
  423.                         save( &player1, &player2, &player3 );
  424.                         exit( 1 );
  425.  
  426.                 default:
  427.                         cout << "invalid option.  Exiting" << endl;
  428.                         sleep( 3 );
  429.                         exit( 1 );
  430.        
  431.         }
  432. }
  433.  
  434.  
  435. void shuffle() {
  436.        
  437.         for( int card = 1; card <= totalCards; card++ ) {
  438.                 int randRow = rand() % deckRows;
  439.                 int randColumn = rand() % deckColumns;
  440.                
  441.                 while( deck[ randRow ][ randColumn ] != 0 ) {
  442.                         randRow = rand() % deckRows;
  443.                         randColumn = rand() % deckColumns;
  444.                 }
  445.                
  446.                 deck[ randRow ][ randColumn ] = card;
  447.         }
  448.        
  449. }
  450.  
  451.  
  452. void save( Player *player1, Player *player2, Player *player3 ) {
  453.         ofstream ofile;
  454.         ofile.open( "autopoker.sav" );
  455.  
  456.         if( ofile.is_open() ) {
  457.  
  458.                 ofile << "time is: " << time( 0 ) << endl << endl;
  459.                
  460.                 ofile << "Player 1 has:" << endl;
  461.                 ofile << player1->cards[ 0 ][ 0 ] << " of " << player1->cards[ 0 ][ 1 ] << endl;
  462.                 ofile << player1->cards[ 1 ][ 0 ] << " of " << player1->cards[ 1 ][ 1 ] << endl;
  463.                 ofile << endl;
  464.  
  465.                 ofile << "Player 2 has:" << endl;
  466.                 ofile << player2->cards[ 0 ][ 0 ] << " of " << player2->cards[ 0 ][ 1 ] << endl;
  467.                 ofile << player2->cards[ 1 ][ 0 ] << " of " << player2->cards[ 1 ][ 1 ] << endl;
  468.                 ofile << endl;
  469.  
  470.                 ofile << "Player 3 has:" << endl;
  471.                 ofile << player3->cards[ 0 ][ 0 ] << " of " << player3->cards[ 0 ][ 1 ] << endl;
  472.                 ofile << player3->cards[ 1 ][ 0 ] << " of " << player3->cards[ 1 ][ 1 ] << endl;
  473.                 ofile << endl;
  474.        
  475.                 ofile << "community cards are ( 3 flops, turn, and river ):" << endl;
  476.                 ofile << player1->cards[ 2 ][ 0 ] << " of " << player1->cards[ 2 ][ 1 ] << endl;
  477.                 ofile << player1->cards[ 3 ][ 0 ] << " of " << player1->cards[ 3 ][ 1 ] << endl;
  478.                 ofile << player1->cards[ 4 ][ 0 ] << " of " << player1->cards[ 4 ][ 1 ] << endl;
  479.                 ofile << player1->cards[ 5 ][ 0 ] << " of " << player1->cards[ 5 ][ 1 ] << endl;
  480.                 ofile << player1->cards[ 6 ][ 0 ] << " of " << player1->cards[ 6 ][ 1 ] << endl;
  481.                 ofile << endl;
  482.  
  483.                 {
  484.                 if( player1->highCards ) {
  485.                         ofile << "Player " << player1->playerNumber << " has high cards." << endl;
  486.                 }
  487.  
  488.                 if( player1->pair ) {
  489.                         ofile << "Player " << player1->playerNumber << " has a pair." << endl;
  490.                 }
  491.  
  492.                 if( player1->twoPair ) {
  493.                         ofile << "Player " << player1->playerNumber << " has two pairs." << endl;
  494.                 }
  495.  
  496.                 if( player1->threeOfAKind ) {
  497.                         ofile << "Player " << player1->playerNumber << " has a three of a kind." << endl;
  498.                 }
  499.  
  500.                 if( player1->straight ) {
  501.                         ofile << "Player " << player1->playerNumber << " has a straight." << endl;
  502.                 }
  503.  
  504.                 if( player1->flush ) {
  505.                         ofile << "Player " << player1->playerNumber << " has a flush." << endl;
  506.                 }
  507.  
  508.                 if( player1->fullHouse ) {
  509.                         ofile << "Player " << player1->playerNumber << " has a flush." << endl;
  510.                 }
  511.  
  512.                 if( player1->fourOfAKind ) {
  513.                         ofile << "Player " << player1->playerNumber << " has a four of a kind." << endl;
  514.                 }
  515.  
  516.                 if( player1->straightFlush ) {
  517.                         ofile << "Player " << player1->playerNumber << " has straight flush." << endl;
  518.                 }
  519.  
  520.                 if( player1->royalFlush ) {
  521.                         ofile << "Player " << player1->playerNumber << " has royal flush." << endl;
  522.                 }
  523.                 }
  524.                 {
  525.                 if( player2->highCards ) {
  526.                         ofile << "Player " << player2->playerNumber << " has high cards." << endl;
  527.                 }
  528.  
  529.                 if( player2->pair ) {
  530.                         ofile << "Player " << player2->playerNumber << " has a pair." << endl;
  531.                 }
  532.  
  533.                 if( player2->twoPair ) {
  534.                         ofile << "Player " << player2->playerNumber << " has two pairs." << endl;
  535.                 }
  536.  
  537.                 if( player2->threeOfAKind ) {
  538.                         ofile << "Player " << player2->playerNumber << " has a three of a kind." << endl;
  539.                 }
  540.  
  541.                 if( player2->straight ) {
  542.                         ofile << "Player " << player2->playerNumber << " has a straight." << endl;
  543.                 }
  544.  
  545.                 if( player2->flush ) {
  546.                         ofile << "Player " << player2->playerNumber << " has a flush." << endl;
  547.                 }
  548.  
  549.                 if( player2->fullHouse ) {
  550.                         ofile << "Player " << player2->playerNumber << " has a flush." << endl;
  551.                 }
  552.  
  553.                 if( player2->fourOfAKind ) {
  554.                         ofile << "Player " << player2->playerNumber << " has a four of a kind." << endl;
  555.                 }
  556.  
  557.                 if( player2->straightFlush ) {
  558.                         ofile << "Player " << player2->playerNumber << " has straight flush." << endl;
  559.                 }
  560.  
  561.                 if( player2->royalFlush ) {
  562.                         ofile << "Player " << player2->playerNumber << " has royal flush." << endl;
  563.                 }
  564.                 }
  565.                 {
  566.                 if( player3->highCards ) {
  567.                         ofile << "Player " << player3->playerNumber << " has high cards." << endl;
  568.                 }
  569.  
  570.                 if( player3->pair ) {
  571.                         ofile << "Player " << player3->playerNumber << " has a pair." << endl;
  572.                 }
  573.  
  574.                 if( player3->twoPair ) {
  575.                         ofile << "Player " << player3->playerNumber << " has two pairs." << endl;
  576.                 }
  577.  
  578.                 if( player3->threeOfAKind ) {
  579.                         ofile << "Player " << player3->playerNumber << " has a three of a kind." << endl;
  580.                 }
  581.  
  582.                 if( player3->straight ) {
  583.                         ofile << "Player " << player3->playerNumber << " has a straight." << endl;
  584.                 }
  585.  
  586.                 if( player3->flush ) {
  587.                         ofile << "Player " << player3->playerNumber << " has a flush." << endl;
  588.                 }
  589.  
  590.                 if( player3->fullHouse ) {
  591.                         ofile << "Player " << player3->playerNumber << " has a flush." << endl;
  592.                 }
  593.  
  594.                 if( player3->fourOfAKind ) {
  595.                         ofile << "Player " << player3->playerNumber << " has a four of a kind." << endl;
  596.                 }
  597.  
  598.                 if( player3->straightFlush ) {
  599.                         ofile << "Player " << player3->playerNumber << " has straight flush." << endl;
  600.                 }
  601.  
  602.                 if( player3->royalFlush ) {
  603.                         ofile << "Player " << player3->playerNumber << " has royal flush." << endl;
  604.                 }
  605.                 }
  606.  
  607.                 sleep( 3 );
  608.  
  609.                 cout << "game successfully saved." << endl;
  610.         }
  611.         else {
  612.                 sleep( 2 );
  613.                 cout << "ERROR: autopoker.sav could not be opened" << endl;
  614.                 cout << "Please make sure that the file is present in the same directory as the game." << endl;
  615.         }
  616. }
  617.  
  618. void printResults( Player *player1, Player *player2, Player *player3 ) {
  619.         cout << setw( 30 ) << "Player 1" << setw( 14 ) << "Player 2" << setw( 14 ) << "Player 3" << endl;
  620.         cout << "==============================================================" << endl;
  621.        
  622.         cout << setiosflags( ios::right );
  623.        
  624.         cout << setw( 20 ) << "Pair |";
  625.         cout << setw( 4 );
  626.         if( player1->pair ) cout << "X";
  627.         cout << setw( 14 );
  628.         if( player2->pair ) cout << "X";
  629.         cout << setw( 14 );
  630.         if( player3->pair ) cout << "X";
  631.        
  632.         cout << endl << setw( 20 ) << "Two pairs |";
  633.         cout << setw( 4 );
  634.         if( player1->twoPair ) cout << "X";
  635.         cout << setw( 14 );
  636.         if( player2->twoPair ) cout << "X";
  637.         cout << setw( 14 );
  638.         if( player3->twoPair ) cout << "X";
  639.        
  640.         cout << endl << setw( 20 ) << "Three of a kind |";
  641.         cout << setw( 4 );
  642.         if( player1->threeOfAKind ) cout << "X";
  643.         cout << setw( 14 );
  644.         if( player2->threeOfAKind ) cout << "X";
  645.         cout << setw( 14 );
  646.         if( player3->threeOfAKind ) cout << "X";
  647.        
  648.         cout << endl << setw( 20 ) << "Straight |";
  649.         cout << setw( 4 );
  650.         if( player1->straight ) cout << "X";
  651.         cout << setw( 14 );
  652.         if( player2->straight ) cout << "X";
  653.         cout << setw( 14 );
  654.         if( player3->straight ) cout << "X";
  655.        
  656.         cout << endl << setw( 20 ) << "Flush |";
  657.         cout << setw( 4 );
  658.         if( player1->flush ) cout << "X";
  659.         cout << setw( 14 );
  660.         if( player2->flush ) cout << "X";
  661.         cout << setw( 14 );
  662.         if( player3->flush ) cout << "X";
  663.        
  664.         cout << endl << setw( 20 ) << "Full house |";
  665.         cout << setw( 4 );
  666.         if( player1->fullHouse ) cout << "X";
  667.         cout << setw( 14 );
  668.         if( player2->fullHouse ) cout << "X";
  669.         cout << setw( 14 );
  670.         if( player3->fullHouse ) cout << "X";
  671.        
  672.         cout << endl << setw( 20 ) << "Four of a kind |";
  673.         cout << setw( 4 );
  674.         if( player1->fourOfAKind ) cout << "X";
  675.         cout << setw( 14 );
  676.         if( player2->fourOfAKind ) cout << "X";
  677.         cout << setw( 14 );
  678.         if( player3->fourOfAKind ) cout << "X";
  679.        
  680.         cout << endl << setw( 20 ) << "Straight flush |";
  681.         cout << setw( 4 );
  682.         if( player1->straightFlush ) cout << "X";
  683.         cout << setw( 14 );
  684.         if( player2->straightFlush ) cout << "X";
  685.         cout << setw( 14 );
  686.         if( player3->straightFlush ) cout << "X";
  687.        
  688.         cout << endl << setw( 20 ) << "Royal flush |";
  689.         cout << setw( 4 );
  690.         if( player1->royalFlush ) cout << "X";
  691.         cout << setw( 14 );
  692.         if( player2->royalFlush ) cout << "X";
  693.         cout << setw( 14 );
  694.         if( player3->royalFlush ) cout << "X";
  695.        
  696. }
  697.  
  698. void makeTrue( Player *player1, Player *player2, Player *player3 ) {  //for testing the table
  699.         player1->pair = true;
  700.         player1->twoPair = true;
  701.         player1->threeOfAKind = true;
  702.         player1->straight = true;
  703.         player1->flush = true;
  704.         player1->fullHouse = true;
  705.         player1->fourOfAKind = true;
  706.         player1->straightFlush = true;
  707.         player1->royalFlush = true;
  708.  
  709.         player2->pair = true;
  710.         player2->twoPair = true;
  711.         player2->threeOfAKind = true;
  712.         player2->straight = true;
  713.         player2->flush = true;
  714.         player2->fullHouse = true;
  715.         player2->fourOfAKind = true;
  716.         player2->straightFlush = true;
  717.         player2->royalFlush = true;
  718.        
  719.         player3->pair = true;
  720.         player3->twoPair = true;
  721.         player3->threeOfAKind = true;
  722.         player3->straight = true;
  723.         player3->flush = true;
  724.         player3->fullHouse = true;
  725.         player3->fourOfAKind = true;
  726.         player3->straightFlush = true;
  727.         player3->royalFlush = true;
  728. }