chessCAMO
Namespaces | Functions
chess.cpp File Reference
#include "chess.h"

Namespaces

 anonymous_namespace{chess.cpp}
 This anonymous namespace contains the local functions related to chessCAMO which are mainly used as helper functions to determine critical information regarding a given move choice.
 
 chessCAMO
 This namespace contains the global functions related to chessCAMO which are mainly used as helper functions to print information to the console to improve user experience while playing the game.
 

Functions

ostream & operator<< (ostream &out, const Chess &chess_object)
 Overloaded extraction operator. More...
 
istream & operator>> (istream &in, Chess &chess_object)
 Overloaded insertion operator. More...
 
bool anonymous_namespace{chess.cpp}::destNotInPinPath (int src, int dest, int pin)
 Determines if a destination square is in the pinning path as sometimes you can simply move the pinned piece closer to the pinning piece. More...
 
bool anonymous_namespace{chess.cpp}::sameCol (int src, int dest)
 Determines if the source and destination squares are in the same column. More...
 
bool anonymous_namespace{chess.cpp}::sameRow (int src, int dest)
 Determines if the source and destination squares are in the same row. More...
 
bool anonymous_namespace{chess.cpp}::sameDiag (int src, int dest)
 Determines if the source and destination squares are in the same diagonal. More...
 
int anonymous_namespace{chess.cpp}::squareOfPieceInPath (int src, int dest, const Chess &chess)
 Used to determine the coordinate of a pinned piece. More...
 
int anonymous_namespace{chess.cpp}::incrementChoice (int src, int dest)
 Used to determine the increment to use when moving a piece from 'src' to 'dest'. More...
 
int anonymous_namespace{chess.cpp}::findKingPos (int src, const Chess &chess, bool enemy)
 Used to determine the coordinate of a pinned piece. More...
 
string anonymous_namespace{chess.cpp}::getPath (int num_moves)
 Gets the path to the object_states folder. More...
 
void chessCAMO::printBoard (const vector< Piece * > &board, const vector< pair< int, char >> &reservoir)
 Iterates through the pieces on a current board representation to produce the board on the console screen. More...
 
void chessCAMO::printFooterMessage (string input_message, const Chess &chess)
 Prints the footer message before each move indicating whose move it is for the current board representation. More...
 
void chessCAMO::drawOrResign (bool clear_screen, Chess &chess, istream &in)
 At any moment, the players can either continue, draw, or resign. More...
 
void chessCAMO::clearScreen (bool apply)
 Clears the screen of the console window using a special string instead of a platform specific command. More...
 
void chessCAMO::printMessage (string text, int color)
 Prints the given message ('text') with a given 'color' to console. More...
 
void chessCAMO::saveObject (const Chess &chess_object)
 Saves an object by serializing its member fields to a text file, allowing it to later be reset. More...
 
void chessCAMO::restoreObject (Chess &chess_object)
 De-serializes an object from a file based on the number of moves made, essentially restoring the object's saved properties (in the file). More...
 

Function Documentation

◆ operator<<()

ostream& operator<< ( ostream &  out,
const Chess chess_object 
)

Overloaded extraction operator.

Parameters
outThe output type (ex. ofstream or cout)
[in]chess_objectThe chess object
Returns
The output stream type

◆ operator>>()

istream& operator>> ( istream &  in,
Chess chess_object 
)

Overloaded insertion operator.

Overlaoded insertion operator.

Parameters
inThe input type (ex. ifstream or cin)
chess_objectThe chess object
Returns
The input stream type