10#include "games/Game.hpp"
11#include "helpers/GameInformation.hpp"
12#include "helpers/Globals.hpp"
13#include "helpers/PageBuilder.hpp"
33 explicit TicTacToe(
const bool& p_useAnsiEscapeCodes);
Game()=default
Constructs a new Game object.
Builds pages (i.e. strings) to be printed to the terminal.
void GetUserOptions() override
Prompt the user for their choice on various game-related options.
void ResetGame() override
Update variables to allow for the game to be reset and so the user will be asked for new options.
void GetPlayerCount()
Prompts the user to select how many players will be playing the game.
void ExecuteUserCommand() override
Prompt the user to enter their command for the current turn.
void GetComputerSpeed()
Prompts the user to select how the speed of computer decision making (this does not affect the diffic...
void ExecuteGeneralCommand(const std::tuple< uint32_t, uint32_t > &p_command)
Executes the command against the game grid.
void GetUserPlayerChoice()
Prompts the user to select which player the will be playing the game as (only supported if playing ag...
uint32_t m_turnCount
The number of turns that have occurred.
TicTacToe(const bool &p_useAnsiEscapeCodes)
Constructs a new TicTacToe object.
std::tuple< uint32_t, uint32_t > m_previousCommand
The previous grid <row, column> value that was chosen by the user. This is used to return the cursor ...
bool IsGameOver() override
Check whether the game is over.
void ExecuteComputerCommand() override
Get a random command from the computer.
void GameOver() override
Display the game over message and prompt the user whether they would like to play again or quit the g...
void ToggleCurrentPlayer() override
Change the current player to the other player.
bool IsCurrentTurnUsers() override
Check whether the current turn should be executed by the user.
GameInformation m_gameInformation
Used to package up the current state of the game so it can be used by m_pageBuilder.
std::string m_currentPlayer
The name of the player whose turn it is.
std::vector< std::tuple< uint32_t, uint32_t > > m_commandsRemaining
The grid <row, column> values that have not been chosen yet.
bool m_hasSavedGameOptions
Whether the user has selected all the game options (true) or not/partially (false)....
void SetupGame() override
Clears and sets all member variables to their game start default.
std::string m_userPlayerChoice
The choice of which player the user has selected.
void RestartGame() override
Update variables to allow for the game to be restarted with the same user options.
std::string m_computerSpeedName
The name of the user selected computer speed.
PageBuilder m_pageBuilder
Used to build pages required by the game.
void UpdateGameInformation() override
Updates GameInformation to match the current state of the game.
std::string m_playerCount
The count of the user selected number of players.
std::array< std::array< std::string, Globals::G_TICTACTOE_GRID_WIDTH >, Globals::G_TICTACTOE_GRID_HEIGHT > m_gameGrid
The Tic Tac Toe grid.
bool ValidateCommand(const std::tuple< uint32_t, uint32_t > &p_command)
Checks whether the command is valid.
uint32_t m_computerSpeed
The computer speed determined by the amount of seconds the computer must wait before executing it's c...
bool m_hasWinner
Whether the game has concluded with a winner (true) or whether it is a draw (false).
std::default_random_engine m_randomNumberGenerator
Used to randomly choose the player to start the game and to randomly decide the computer's next comma...
bool m_saveGameOptions
Whether to save the user's currently selected game options (true) and restart the game or not (false)...
static const uint32_t G_TICTACTOE_GRID_HEIGHT
TicTacToe grid attributes.
Contains all Terminal-Games objects.