Hello
im making a card game that deals cards for a poker game. My problem is that my card dealer generates the same cards for both the player and the community cards. i was wondering how i could make it so that it wouldnt do that. If i could get any hints or something, it would be greatly appreciated. also im looking for a way to score cards
Code:#include<iostream> #include<fstream> #include<ctime> #include<cstdlib> #include<string> using namespace std; /* Randall Foor Texas Holdem Game Last Edited:12/11/2010 */ /******************************* ********Functions*************** *******************************/ void shuffle( int wdeck[][13]); void deal2( const int wdeck[][13], const char *wface[], const char *wsuit[]); void dealcommunity( const int wdeck[][13], const char *wface[], const char *wsuit[]); void pair( int a[]); /********************************** ***********Classes***************** **********************************/ class Playerinfo { public: Playerinfo(); void getRecipients(); friend ostream& operator << (ostream&, Playerinfo&); private: string name, city, state, zip; }; Playerinfo::Playerinfo() { name=""; city=""; state=""; zip=""; } void Playerinfo::getRecipients() { cout << "Name: "; getline(cin, name); cout << "City: "; getline(cin, city); cout << "State: "; getline(cin, state); cout << "Zip: "; getline(cin, zip); } ostream& operator << (ostream& out, Playerinfo& info) { out << info.name << endl << info.city << endl; out << info.state << endl << info.zip << endl; return out; } /***************************************** ****************Main********************** *****************************************/ int main() { const char *suit[4] = {" of Hearts", " of Diamonds", " of Clubs", " of Spades"}; const char *face[13] = {"A", "2", "3", "3", "5", "6", "7", "8", "9", "10", "J", "Q", "K"}; ofstream myfile; Playerinfo mine; ofstream outFile; outFile.open("Playerinfo.txt", ios::app); myfile.open("numbers_file.txt",ios::trunc); //opens and deletes everything from before myfile.close(); int chooselevel; char repeatgame; do{ int playersmoney=100; /* cout<<"Welcome to TEXAS HOLD'EM!\n\n"; cout<<"Rules:\n"; cout<<"you are dealt a hand of 2 cards and there are 5 cards total that can\nbe flipped after that "; cout<<"once per turn a card will be flipped over. \nthe object is to beat the dealers hand to gain money until you reach\nthe amount of that level\n\n"; system("pause"); system("cls"); cout<<"Once you are dealt the cards, you have a choice of either\n1:Bet\n2:Folding\n3:Quit game\n"<<endl; cout<<"If you lose all your money you automatically lose the game."<<endl; cout<<"You will be asked for you name,city,state,and zip code for personal reasons\njust go with it!"<<endl; system("pause"); system("cls"); */ /* mine.getRecipients(); cout << mine; outFile << mine; */ /* cout<<"Choose a Level:\n\n"; cout<<"Level 1:make $100\n"; cout<<"Level 2:make $1000\n"; cout<<"Level 3:make $10000\n"; cout<<"Level 4:make $100000\n\n"; cout<<"Which level would you like<1-4>:\n"; cin>>chooselevel; system("cls"); */ cout<<" "; cout<<"Your money:$"<<playersmoney<<"\n\n\n"; int deck[4][13] ={0}; srand( time(0)); shuffle(deck); cout<<"Your Cards:"<<endl; deal2(deck, face, suit); cout<<"Community Cards:\n"; dealcommunity(deck, face, suit); if(playersmoney==0) { cout<<"You dont have any more money...you lost"<<endl; break; } cout<<"would you like to repeat game<Y or N>?"; cin>>repeatgame; system("cls"); }while(repeatgame=='y'||repeatgame=='Y'); system("pause"); } /*********************************************** ***************Functions*********************** ***********************************************/ void shuffle(int wdeck[][13]) { int row; int column; int card; for(card = 1; card <= 52; card++) { do { row = rand() % 4; column = rand() % 13; }while(wdeck [row] [column] !=0); wdeck [row] [column] = card; } } void deal2(const int wdeck[][13], const char *wface[], const char *wsuit[]) { int card; int row; int column; for ( card = 1; card <= 2; card++ ) { for ( row = 0; row <= 3; row++ ){ for ( column = 0; column <=12; column++ ){ if ( wdeck[row][column] == card ) { printf("%5s%-8s%\n", wface[column], wsuit[row], card % 52 == 0 ); } } } } } void dealcommunity(const int wdeck[][13], const char *wface[], const char *wsuit[]) { int card; int row; int column; for ( card = 1; card <= 3; card++ ) { for ( row = 0; row <= 3; row++ ){ for ( column = 0; column <=12; column++ ){ if ( wdeck[row][column] == card ) { printf("%5s%-8s%\n", wface[column], wsuit[row], card % 52 == 0 ); } } } } }



LinkBack URL
About LinkBacks


