From dcfd43f8f48072754b9d952b621bac1cddbb7103 Mon Sep 17 00:00:00 2001 From: Kyle K Date: Sat, 29 Jan 2011 12:13:21 -0600 Subject: Initial commit --- main.cpp | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 main.cpp (limited to 'main.cpp') diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..75bc9dc --- /dev/null +++ b/main.cpp @@ -0,0 +1,71 @@ +/* Kamil Kaminski + * NetID: kkamin8 + * + * CS340 + * Project 1, Poker Game + * + * + */ + +#include "game.h" + +int main(int argc, char *argv[]) +{ + /* seed rand() */ + srand((unsigned int ) time(NULL)); + + /* pokerGame instance */ + Game *pokerGame = new Game(); + PRINT_COLOR(ANSI_COLOR_GREEN, "\tWelcome to Poker Game\n\n"); + + /* number of opponents user input */ + pokerGame->askForNumberOfOpponents(); + + /* pokerGame loop */ + bool quit = false; + while (!quit) + { + cout << "\nThe deck is being shuffled" << endl; + pokerGame->shufflePile(); + +#ifdef DEBUG + cout << "Deck after shuffle" << endl; + pokerGame->printPile(); +#endif + + cout << "\nDealing cards to the user" << endl; + pokerGame->dealUserCards(); + pokerGame->sortUserCards(); + cout << "Cards in your hand: "; + pokerGame->printUserCards(); + + cout << "Number of same cards: " << + pokerGame->numOfSameCards(pokerGame->getUserCards()) << endl; + + if ( pokerGame->pairOrBetter(pokerGame->getUserCards())) + cout << "User has pair or better" << endl; + + cout << "\nDealing cards to opponent(s)" << endl; + pokerGame->dealOpponentCards(pokerGame->numOfOpponents); + pokerGame->sortOpponentCards(pokerGame->numOfOpponents); + cout << "Opponents' cards:" << endl; + pokerGame->printOpponentCards(pokerGame->numOfOpponents); + +#ifdef DEBUG + cout << "\nDeck after being delt to opponents and user" << endl; + pokerGame->printPile(); +#endif + + /* ask to repeat the game and reset the deck of cards */ + pokerGame->repeatGame(&quit); + pokerGame->resetDeck(); + } + + cout << "\nThank you for playing\n" << pokerGame->handsPlayed << ": Hands played\n" + << pokerGame->handsWon << ": Hands won" << endl; + + delete pokerGame; + + return 0; +} + -- cgit v1.2.3