Terminal Games
Simple games that run in the terminal.
Loading...
Searching...
No Matches
TerminalGames::Game Class Referenceabstract

Base class for all games. More...

#include "Game.hpp"

Inheritance diagram for TerminalGames::Game:
TerminalGames::Battleships TerminalGames::Hangman TerminalGames::TicTacToe

Public Member Functions

 Game ()=default
 Constructs a new Game object.
virtual ~Game ()=default
 Destructs the Game object.
virtual void Play () final
 The main orchestration loop for all games.
 Game (const Game &p_game)=delete
 Disable constructing a new Game object using copy constructor.
 Game (const Game &&p_game)=delete
 Disable constructing a new Game object using move constructor.
Gameoperator= (const Game &p_game)=delete
 Disable constructing a new Game object using copy assignment operator.
Gameoperator= (const Game &&p_game)=delete
 Disable constructing a new Game object using move assignment operator.

Private Member Functions

virtual void SetupGame ()=0
 Clears and sets all member variables to their game start default.
virtual void GetUserOptions ()=0
 Prompt the user for their choice on various game-related options.
virtual void UpdateGameInformation ()=0
 Updates GameInformation to match the current state of the game.
virtual bool IsGameOver ()=0
 Check whether the game is over.
virtual void ToggleCurrentPlayer ()=0
 Change the current player to the other player.
virtual bool IsCurrentTurnUsers ()=0
 Check whether the current turn should be executed by the user.
virtual void ExecuteUserCommand ()=0
 Prompt the user to enter their command for the current turn.
virtual void ExecuteComputerCommand ()=0
 Get a random command from the computer.
virtual void GameOver ()=0
 Display the game over message and prompt the user whether they would like to play again or quit the game.
virtual void RestartGame ()=0
 Update variables to allow for the game to be restarted with the same user options.
virtual void ResetGame ()=0
 Update variables to allow for the game to be reset and so the user will be asked for new options.

Detailed Description

Base class for all games.

Definition at line 15 of file Game.hpp.

Constructor & Destructor Documentation

◆ Game() [1/2]

TerminalGames::Game::Game ( const Game & p_game)
delete

Disable constructing a new Game object using copy constructor.

Parameters
p_gameThe Game to copy.

◆ Game() [2/2]

TerminalGames::Game::Game ( const Game && p_game)
delete

Disable constructing a new Game object using move constructor.

Parameters
p_gameThe Game to copy.

Member Function Documentation

◆ Play()

virtual void TerminalGames::Game::Play ( )
inlinefinalvirtual

The main orchestration loop for all games.

Definition at line 31 of file Game.hpp.

◆ operator=() [1/2]

Game & TerminalGames::Game::operator= ( const Game & p_game)
delete

Disable constructing a new Game object using copy assignment operator.

Parameters
p_gameThe Game to copy.

◆ operator=() [2/2]

Game & TerminalGames::Game::operator= ( const Game && p_game)
delete

Disable constructing a new Game object using move assignment operator.

Parameters
p_gameThe Game to copy.

◆ SetupGame()

virtual void TerminalGames::Game::SetupGame ( )
privatepure virtual

Clears and sets all member variables to their game start default.

Implemented in TerminalGames::Battleships, TerminalGames::Hangman, and TerminalGames::TicTacToe.

◆ GetUserOptions()

virtual void TerminalGames::Game::GetUserOptions ( )
privatepure virtual

Prompt the user for their choice on various game-related options.

Implemented in TerminalGames::Battleships, TerminalGames::Hangman, and TerminalGames::TicTacToe.

◆ UpdateGameInformation()

virtual void TerminalGames::Game::UpdateGameInformation ( )
privatepure virtual

Updates GameInformation to match the current state of the game.

Implemented in TerminalGames::Battleships, TerminalGames::Hangman, and TerminalGames::TicTacToe.

◆ IsGameOver()

virtual bool TerminalGames::Game::IsGameOver ( )
privatepure virtual

Check whether the game is over.

Returns
true If the game is over.
false If the game is NOT over.

Implemented in TerminalGames::Battleships, TerminalGames::Hangman, and TerminalGames::TicTacToe.

◆ ToggleCurrentPlayer()

virtual void TerminalGames::Game::ToggleCurrentPlayer ( )
privatepure virtual

Change the current player to the other player.

Implemented in TerminalGames::Battleships, TerminalGames::Hangman, and TerminalGames::TicTacToe.

◆ IsCurrentTurnUsers()

virtual bool TerminalGames::Game::IsCurrentTurnUsers ( )
privatepure virtual

Check whether the current turn should be executed by the user.

Returns
true If the current turn is the users'.
false If the current turn is NOT the users'.

Implemented in TerminalGames::Battleships, TerminalGames::Hangman, and TerminalGames::TicTacToe.

◆ ExecuteUserCommand()

virtual void TerminalGames::Game::ExecuteUserCommand ( )
privatepure virtual

Prompt the user to enter their command for the current turn.

Implemented in TerminalGames::Battleships, TerminalGames::Hangman, and TerminalGames::TicTacToe.

◆ ExecuteComputerCommand()

virtual void TerminalGames::Game::ExecuteComputerCommand ( )
privatepure virtual

Get a random command from the computer.

Implemented in TerminalGames::Battleships, TerminalGames::Hangman, and TerminalGames::TicTacToe.

◆ GameOver()

virtual void TerminalGames::Game::GameOver ( )
privatepure virtual

Display the game over message and prompt the user whether they would like to play again or quit the game.

Implemented in TerminalGames::Battleships, TerminalGames::Hangman, and TerminalGames::TicTacToe.

◆ RestartGame()

virtual void TerminalGames::Game::RestartGame ( )
privatepure virtual

Update variables to allow for the game to be restarted with the same user options.

Implemented in TerminalGames::Battleships, TerminalGames::Hangman, and TerminalGames::TicTacToe.

◆ ResetGame()

virtual void TerminalGames::Game::ResetGame ( )
privatepure virtual

Update variables to allow for the game to be reset and so the user will be asked for new options.

Implemented in TerminalGames::Battleships, TerminalGames::Hangman, and TerminalGames::TicTacToe.


The documentation for this class was generated from the following file: