diff options
author | Kyle K <kylek389@gmail.com> | 2011-01-29 12:13:21 -0600 |
---|---|---|
committer | Kamil Kaminski <kamilkss@gmail.com> | 2011-01-29 12:13:21 -0600 |
commit | dcfd43f8f48072754b9d952b621bac1cddbb7103 (patch) | |
tree | cf234c3fd9fa3b74e62ec74e1e23a04cc21df436 /main.cpp | |
download | poker-dcfd43f8f48072754b9d952b621bac1cddbb7103.tar.gz poker-dcfd43f8f48072754b9d952b621bac1cddbb7103.tar.bz2 poker-dcfd43f8f48072754b9d952b621bac1cddbb7103.zip |
Initial commit
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
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;
+}
+
|