Implements the BlackJack mini-game.
More...
#include <minigames.h>
Implements the BlackJack mini-game.
The BlackJack class allows the player to play a simple version of the BlackJack card game against a dealer.
◆ BlackJack()
Constructor for the BlackJack game.
BlackJack game.
Initializes the game with default settings.
Constructor for the BlackJack class.
Initializes a new game of BlackJack by shuffling the deck and dealing cards to the player and dealer.
◆ displayState()
| void BlackJack::displayState |
( |
bool |
printAll | ) |
|
Displays the current state of the game.
Display the current state of the BlackJack game.
- Parameters
-
| printAll | Indicates whether to print all details or just the player's perspective. |
| printAll | A boolean indicating whether to show all the dealer's cards. |
Prints the dealer's and player's cards, and whether the dealer's second card should be hidden.
◆ endGame()
| bool BlackJack::endGame |
( |
bool |
won | ) |
|
Handles the end of the game.
- Parameters
-
| won | Indicates if the player won or lost the game. |
- Returns
- True if the player won, false otherwise.
◆ evaluate()
| int BlackJack::evaluate |
( |
bool |
hit | ) |
|
Evaluates the player's hand.
Evaluate the player's hand against the dealer's.
- Parameters
-
| hit | Indicates if the player has chosen to hit or stand. |
- Returns
- The result of the evaluation.
- Parameters
-
| hit | A boolean indicating if the player chose to hit. |
- Returns
- An integer indicating the outcome (-1 for loss, 0 for continue, 1 for win).
◆ getDealer()
| const int * BlackJack::getDealer |
( |
| ) |
const |
Gets the dealer's hand.
- Returns
- An array containing the dealer's cards.
◆ getGameName()
| std::string BlackJack::getGameName |
( |
| ) |
|
|
overridevirtual |
Gets the name of the game.
Get the name of the BlackJack game.
- Returns
- A string representing the name of the game.
Implements Game.
◆ getPlayerCards()
| const std::vector< int > & BlackJack::getPlayerCards |
( |
| ) |
const |
Gets the player's hand.
- Returns
- A vector containing the player's cards.
◆ handlePlayerTurn()
| bool BlackJack::handlePlayerTurn |
( |
| ) |
|
Handles a single player turn.
- Returns
- Whether the player chose to hit or stand.
◆ initializeGame()
| int BlackJack::initializeGame |
( |
| ) |
|
Initializes the game state.
- Returns
- The maximum number of rounds for the game.
◆ setDealer()
| void BlackJack::setDealer |
( |
const int |
newDealer[2] | ) |
|
Sets the dealer's hand.
- Parameters
-
| newDealer | An array containing the new cards for the dealer. |
◆ setPlayerCards()
| void BlackJack::setPlayerCards |
( |
const std::vector< int > & |
newPlayerCards | ) |
|
Sets the player's hand.
- Parameters
-
| newPlayerCards | A vector containing the new cards for the player. |
◆ start()
| bool BlackJack::start |
( |
| ) |
|
|
overridevirtual |
Starts the BlackJack game.
Start the BlackJack game.
- Returns
- True if the game was completed successfully, otherwise false.
-
True if the player wins, false otherwise.
The player plays against the dealer, attempting to win the majority of rounds.
Implements Game.
◆ updateGameState()
| void BlackJack::updateGameState |
( |
bool |
won, |
|
|
int |
rounds, |
|
|
int |
totalWins, |
|
|
int |
maxRounds, |
|
|
bool |
wasHit |
|
) |
| |
Updates the game state based on the result of a round.
- Parameters
-
| won | Indicates if the round was won or lost. |
The documentation for this class was generated from the following files: