8#include "helpers/Globals.hpp"
9#include "helpers/PageBuilder.hpp"
10#include "helpers/Terminal.hpp"
12#include "games/TicTacToe.hpp"
135 std::this_thread::sleep_until(std::chrono::system_clock::now() + std::chrono::seconds(
m_computerSpeed));
166 const std::vector<std::string> QUIT_MENUS =
m_pageBuilder.GetQuitOptionSelectionPage();
175 const std::vector<std::string> QUIT_MENUS =
m_pageBuilder.GetQuitOptionSelectionPage();
184 const std::vector<std::string> QUIT_MENUS =
m_pageBuilder.GetQuitOptionSelectionPage();
199 const uint32_t ROW = std::get<0>(p_command);
200 const uint32_t COLUMN = std::get<1>(p_command);
static void GetUserChoiceFromGameOverMenu(const std::string &p_gameOverPage, const std::vector< std::string > &p_quitOptionMenus)
Get the user choice whether to restart the game, reset the game or a choice from the GetUserChoiceFro...
static void PrintOutput(const std::string &p_output)
Clears and then prints to the terminal.
static uint32_t GetUserChoiceFromGameMenus(const std::vector< std::string > &p_menus, const std::vector< std::string > &p_quitOptionMenus)
Get the user choice from a list of game menus screens that are printed to the terminal.
static std::tuple< uint32_t, uint32_t > GetUserCommandFromGameGrid(const std::tuple< uint32_t, uint32_t > &p_startingGridLocation, const PageBuilder &p_pageBuilder, const GameInformation &p_gameInformation, const bool &p_displayGetUserCommandPage)
Gets a user command based on the currently displayed game grid (wrapper function around the platform-...
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 std::string G_TICTACTOE_GRID_PLAYER_X_OCCUPIED
TicTacToe grid values.
static const std::string G_TICTACTOE_GRID_PLAYER_O_OCCUPIED
TicTacToe grid values.
static constexpr T ImplementStdRangesFind(const T &p_begin, const T &p_end, const U &p_value)
Implements std::ranges::find which should work for all standard template library containers.
static const std::vector< std::string > G_GAME_MAX_TWO_PLAYERS_OPTIONS
Used by multiple games or an attribute not specific to one game.
static const uint32_t G_TICTACTOE_GRID_WIDTH
TicTacToe grid attributes.
static const std::string G_TICTACTOE_EMPTY_GRID_VALUE
TicTacToe grid values.
static const std::vector< std::string > G_TICTACTOE_PLAYER_CHOICE_OPTIONS
TicTacToe player choice options.
static const std::string G_TICTACTOE_PLAYER_X
TicTacToe player choice options.
static const uint32_t G_TICTACTOE_MAXIMUM_ERROR_COUNT
TicTacToe maximum errors count to determine whether the game is over.
static const std::string G_TICTACTOE_PLAYER_O
TicTacToe player choice options.
static const std::vector< std::string > G_GAME_COMPUTER_SPEED_OPTIONS
Used by multiple games or an attribute not specific to one game.
static const uint32_t G_TICTACTOE_GRID_HEIGHT
TicTacToe grid attributes.
static const std::string G_GAME_UNKNOWN_OPTION
Used by multiple games or an attribute not specific to one game.
Contains all Terminal-Games objects.
@ TICTACTOE
Page supported by PageBuilder.