summaryrefslogtreecommitdiffstats
path: root/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'main.cpp')
-rw-r--r--main.cpp147
1 files changed, 76 insertions, 71 deletions
diff --git a/main.cpp b/main.cpp
index 75bc9dc..710d7a2 100644
--- a/main.cpp
+++ b/main.cpp
@@ -1,71 +1,76 @@
-/* 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;
-}
-
+/* 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;
+
+ struct countAndSuit userCountAndSuit = pokerGame->numOfSameSuit(pokerGame->getUserCards());
+ cout << "Top suit: " << *pokerGame->suits[userCountAndSuit.whatSuit] << ", count: "
+ << userCountAndSuit.count << 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;
+ PRINT_COLOR(ANSI_COLOR_CYAN, "\tBye!\n");
+
+ return 0;
+}
+