-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameMenu.cpp
More file actions
74 lines (63 loc) · 2.62 KB
/
GameMenu.cpp
File metadata and controls
74 lines (63 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#include "GameMenu.h"
/**
* @author PengJu Chang, Yu Fan Chen , Logan Gunn , Everett Scott Melanson , William Zhen Yu Ngo
* @class GameMenu
* @brief A static class to represent the Game Menu
* @details provides static methods for the main function to get user input regarding the game
*/
/**
* @brief setUpGame - sets up Game for the main
* @details takes in user input regarding the settings for the black jack game
* @return Game that is specified by user input
*/
Game * GameMenu::setUpGame() {
Player *dealer = new Dealer();
int numPlayers = 1;
int numDecks = 1;
std::cout << "Standard Settings: 1 Player, 1 Deck, Normal Dealer Behaviour (Hit on 17 or lower)"
<< std::endl;
if (InputMenu::yesOrNoMenuChoice("Would you like to change these settings? (y/n): ")) {
numDecks = InputMenu::intMenuChoice("Enter the number of decks you would like to play with: ");
numPlayers = InputMenu::intMenuChoice("Enter the number of players you would like to play with: ");
bool customDealer = InputMenu::yesOrNoMenuChoice("Would you like to play with a customized dealer? (y/n): ");
if (customDealer) {
int customDealerSetting = InputMenu::intMenuChoice(
"Enter the number which you would like the dealer to not hit past: ");
dealer = new CustomDealer(customDealerSetting);
}
}
dealer->getWallet().newStartBet(-1);
Game *newGame = new Game(dealer, numDecks);
for (int i = 0; i < numPlayers; i++) {
std::string playerName = "Player " + std::to_string(i + 1);
Player *player = new HumanPlayer(playerName);
newGame->addPlayer(player);
}
newGame->getBets();
return newGame;
}
/**
* @brief finishGame - ends the Game for the main
* @param game the completed game
* @details takes in a Game object and provides user input regarding options for when the game is finished
* and returns a bool for if player wants to play again
* @return bool true if user wants to play again, and false if user quits
*/
bool GameMenu::finishGame(Game game) {
bool endGameMenu = true;
while (endGameMenu) {
char choice = InputMenu::optionalMenuChoice(
"Would you like to Reveal the deck? (d), watch a replay of the last game? (r), play again? (p), or quit? (q)",
{'d', 'r', 'p', 'q'});
if (choice == 'd') {
game.getDeck().printDeckCards();
} else if (choice == 'r') {
game.replay();
} else if (choice == 'p') {
return true;
} else {
return false;
}
}
return false;
}