chessCAMO
Public Member Functions | List of all members
King Class Reference

This class describes a king and provides functions related to king movements. More...

#include <chess.h>

Inheritance diagram for King:
Piece

Public Member Functions

 ~King ()
 
 King ()
 Default constructor with default board parameter initialization - Constructs a new instance. Calls Piece class constructor to intialize the member variables. More...
 
 King (int square, pieceType type, pieceColor color)
 Constructs a new instance with valid piece information initialization. Calls Piece class constructor to intialize the member variables. More...
 
bool isPossibleMove (int dest, const Chess &chess) override
 Determines if possible move. More...
 
bool canCastle (int dest, const Chess &chess) override
 Determines ability to castle. More...
 
bool movedIntoCheck (int dest, Chess &chess) override
 Determines if a king moved into check after a move was made. More...
 
- Public Member Functions inherited from Piece
virtual ~Piece ()
 
 Piece ()
 Default constructor with default board parameter initialization - Constructs a new instance. More...
 
 Piece (int square, pieceType type, pieceColor color)
 Constructs a new instance with valid piece information initialization. More...
 
int getPieceSquare () const
 (Accessor) Gets the piece square information. More...
 
void setPieceSquare (int square)
 (Mutator) Sets the piece square information. More...
 
pieceType getPieceType () const
 (Accessor) Gets the piece type information. More...
 
void setPieceType (pieceType type)
 (Mutator) Sets the piece type information. More...
 
pieceColor getPieceColor () const
 (Accessor) Gets the piece color information. More...
 
void setPieceColor (pieceColor color)
 (Mutator) Sets the piece color information. More...
 
bool getPieceMoveInfo () const
 (Accessor) Gets the piece move information useful for pawns, rooks, kings. More...
 
void setPieceMoveInfo (bool moved)
 (Mutator) Sets the piece move information. More...
 
virtual bool getEnPassantLeft () const
 (Accessor) Gets the piece en-passant ability information for left side. More...
 
virtual void setEnPassantLeft (bool en_passant_left)
 (Mutator) Sets the piece en-passant ability information for left side. More...
 
virtual bool getEnPassantRight () const
 (Accessor) Gets the piece en-passant ability information for right side. More...
 
virtual void setEnPassantRight (bool en_passant_right)
 (Mutator) Sets the piece en-passant ability information for right side. More...
 
bool isEmpty ()
 Determines if the square is empty. More...
 
bool isPawn ()
 Determines if the piece is a pawn. More...
 
bool isKnight ()
 Determines if the piece is a knight. More...
 
bool isBishop ()
 Determines if the piece is a bishop. More...
 
bool isRook ()
 Determines if the piece is a rook. More...
 
bool isQueen ()
 Determines if the piece is a queen. More...
 
bool isKing ()
 Determines if the piece is a king. More...
 
bool isPieceWhite ()
 Determines if the piece is white. More...
 
bool isPieceBlack ()
 Determines if the piece is black. More...
 
bool isSameColor (int dest, const Chess &chess)
 Determines if 2 pieces have the same color. More...
 
bool isPinned (int dest, const Chess &chess)
 Determines if a given piece is pinned to the king by opposing piece. More...
 
bool isPathFree (int dest, const Chess &chess)
 Determines if the path from the piece to its destination is empty. More...
 
bool isLegalMove (int dest, Chess &chess)
 Determines if a move is legal based on the rules of chess. More...
 
bool causeCheck (int dest, Chess &chess)
 Did the move cause a check? More...
 
bool causeDoubleCheck (int dest, Chess &chess)
 Did the move cause a double check? More...
 
virtual void enPassantHandling (int src, Chess &chess)
 Pawn attacks opposing pawn with en-passant More...
 
virtual void promotePawn (Chess &chess, istream &in)
 Promotes the pawn if needed. More...
 

Detailed Description

This class describes a king and provides functions related to king movements.

Constructor & Destructor Documentation

◆ ~King()

King::~King ( )
inline

◆ King() [1/2]

King::King ( )
inline

Default constructor with default board parameter initialization - Constructs a new instance. Calls Piece class constructor to intialize the member variables.

Note
Intentionally left blank.

◆ King() [2/2]

King::King ( int  square,
pieceType  type,
pieceColor  color 
)
inline

Constructs a new instance with valid piece information initialization. Calls Piece class constructor to intialize the member variables.

Parameters
[in]squareThe square of the piece
[in]typeThe type of the piece
[in]colorThe color of the piece
Note
Intentionally left blank.

Member Function Documentation

◆ isPossibleMove()

bool King::isPossibleMove ( int  dest,
const Chess chess 
)
overridevirtual

Determines if possible move.

Note
Combines rook and bishop moves but only 1 square
See also
virtual Piece::isPossibleMove(int dest, Chess &chess)
Parameters
[in]destThe destination
chessThe chess
Returns
True if possible move, False otherwise.

Reimplemented from Piece.

◆ canCastle()

bool King::canCastle ( int  dest,
const Chess chess 
)
overridevirtual

Determines ability to castle.

See also
virtual Piece::canCastle(int dest, Chess &chess)
Parameters
[in]destThe destination
chessThe chess
Returns
True if able to castle, False otherwise.

Reimplemented from Piece.

◆ movedIntoCheck()

bool King::movedIntoCheck ( int  dest,
Chess chess 
)
overridevirtual

Determines if a king moved into check after a move was made.

See also
virtual Piece::movedIntoCheck(int dest, Chess &chess)
Parameters
[in]destThe destination square of the piece
chessThe chess object
Returns
True if a piece attacks the king after the move was made, False otherwise.

Reimplemented from Piece.


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