chessCAMO
Public Member Functions | Private Attributes | List of all members
Pawn Class Reference

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

#include <chess.h>

Inheritance diagram for Pawn:
Piece

Public Member Functions

 ~Pawn ()
 
 Pawn ()
 Default constructor with default board parameter initialization - Constructs a new instance. Calls Piece class constructor to intialize the member variables. More...
 
 Pawn (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 getEnPassantLeft () const override
 (Accessor) Gets the piece en-passant ability information for left side. More...
 
void setEnPassantLeft (bool en_passant_left) override
 (Mutator) Sets the piece en-passant ability information for left side. More...
 
bool getEnPassantRight () const override
 (Accessor) Gets the piece en-passant ability information for right side. More...
 
void setEnPassantRight (bool en_passant_right) override
 (Mutator) Sets the piece en-passant ability information for right side. More...
 
bool isPossibleMove (int dest, const Chess &chess) override
 Determines if possible move. More...
 
void enPassantHandling (int src, Chess &chess) override
 Captures the violating pawn if an en-passant move it made. More...
 
void promotePawn (Chess &chess, istream &in) override
 Promotes the pawn to a piece depending on the user's choice. 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...
 
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 bool canCastle (int dest, const Chess &chess)
 Can the king castle? More...
 
virtual bool movedIntoCheck (int dest, Chess &chess)
 Did the king move into check? More...
 

Private Attributes

bool en_passant_left
 
bool en_passant_right
 

Detailed Description

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

Constructor & Destructor Documentation

◆ ~Pawn()

Pawn::~Pawn ( )
inline

◆ Pawn() [1/2]

Pawn::Pawn ( )
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. Has en-passant initialization.

◆ Pawn() [2/2]

Pawn::Pawn ( 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. Has en-passant initialization.

Member Function Documentation

◆ getEnPassantLeft()

bool Pawn::getEnPassantLeft ( ) const
inlineoverridevirtual

(Accessor) Gets the piece en-passant ability information for left side.

Returns
The piece en-passant ability information in left direction.

Reimplemented from Piece.

◆ setEnPassantLeft()

void Pawn::setEnPassantLeft ( bool  en_passant_left)
inlineoverridevirtual

(Mutator) Sets the piece en-passant ability information for left side.

Parameters
[in]en_passant_leftThe piece en-passant ability information in left direction
Note
Intentionally left blank.

Reimplemented from Piece.

◆ getEnPassantRight()

bool Pawn::getEnPassantRight ( ) const
inlineoverridevirtual

(Accessor) Gets the piece en-passant ability information for right side.

Returns
The piece en-passant ability information in right direction.

Reimplemented from Piece.

◆ setEnPassantRight()

void Pawn::setEnPassantRight ( bool  en_passant_right)
inlineoverridevirtual

(Mutator) Sets the piece en-passant ability information for right side.

Parameters
[in]en_passant_rightThe piece en-passant ability information in right direction
Note
Intentionally left blank.

Reimplemented from Piece.

◆ isPossibleMove()

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

Determines if possible move.

Note
Can move 1 or 2 square (if not moved yet) forwards, attack diagonally 1 square, en-passant, and promote.
See also
virtual Piece::isPossibleMove(int dest, Chess &chess)
Parameters
[in]destThe piece's destination square
chessThe chess object
Returns
True if possible move, False otherwise.

Reimplemented from Piece.

◆ enPassantHandling()

void Pawn::enPassantHandling ( int  src,
Chess chess 
)
overridevirtual

Captures the violating pawn if an en-passant move it made.

See also
virtual Piece::enPassantHandling(int dest, Chess &chess)
Parameters
[in]srcThe piece's source square
chessThe chess object

Reimplemented from Piece.

◆ promotePawn()

void Pawn::promotePawn ( Chess chess,
istream &  in 
)
overridevirtual

Promotes the pawn to a piece depending on the user's choice.

See also
virtual Piece::promotePawn(int dest, Chess &chess, istream &in)
Parameters
chessThe chess object
inThe input stream type (ex. ifstream or cin)

Reimplemented from Piece.

Member Data Documentation

◆ en_passant_left

bool Pawn::en_passant_left
private
  • Can this pawn en-passant it's left rival currently?

◆ en_passant_right

bool Pawn::en_passant_right
private
  • Can this pawn en-passant it's right rival currently?

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