GClasses
|
Represents the state of a chess board, and provides some basic functionality for implementing a chess game. More...
#include <GChess.h>
Public Types | |
enum | Piece { None = 0, Pawn = 1, Rook = 2, Knight = 3, Bishop = 4, Queen = 5, King = 6, PieceMask = 7, WhiteMask = 8, AllMask = 15 } |
Public Member Functions | |
GChessBoard () | |
GChessBoard (const GChessBoard &that) | |
copy-constructor More... | |
~GChessBoard () | |
bool | isValidMove (int xSrc, int ySrc, int xDest, int yDest) |
Returns true iff the parameters represent a valid move. More... | |
bool | move (int xSrc, int ySrc, int xDest, int yDest) |
Moves the piece from (xSrc, ySrc) to (xDest, yDest). If this move takes a king, then it will remove all pieces of the same color as the king that was taken and return true to indicate that the move ended the game. More... | |
int | moves (int *pOutMoves, int col, int row) |
Pass in the coordinates of a square with a piece on it and it will return the number of moves that piece can make and put the coordinates of the moves in pOutMoves (first col, then row, so pOutMoves should be big enough to hold 2 * MAX_PIECE_MOVES values) More... | |
Piece | piece (int col, int row, bool *pbWhite) |
Returns the piece located at position (col, row), and sets *pbWhite to true if the piece is white. More... | |
void | printBoard (std::ostream &stream) |
Print a representation of the board to the specified stream. More... | |
void | resetBoard () |
Sets up the board for a new game. More... | |
void | setPiece (int col, int row, Piece piece, bool white) |
Sets the piece at location (col, row). If piece is None, then it doesn't matter what the value of white is. More... | |
Protected Member Functions | |
bool | checkMove (int *pOutMoves, int *pnMoves, int col, int row, bool bWhite) |
bool | checkPawnMove (int *pOutMoves, int *pnMoves, int col, int row, bool bDiagonal, bool bWhite) |
int | dec (int pos) |
int | inc (int pos) |
Protected Attributes | |
unsigned int | m_rows [8] |
Represents the state of a chess board, and provides some basic functionality for implementing a chess game.
|
inline |
|
inline |
copy-constructor
|
inline |
|
protected |
|
protected |
|
inlineprotected |
|
inlineprotected |
bool GClasses::GChessBoard::isValidMove | ( | int | xSrc, |
int | ySrc, | ||
int | xDest, | ||
int | yDest | ||
) |
Returns true iff the parameters represent a valid move.
bool GClasses::GChessBoard::move | ( | int | xSrc, |
int | ySrc, | ||
int | xDest, | ||
int | yDest | ||
) |
Moves the piece from (xSrc, ySrc) to (xDest, yDest). If this move takes a king, then it will remove all pieces of the same color as the king that was taken and return true to indicate that the move ended the game.
int GClasses::GChessBoard::moves | ( | int * | pOutMoves, |
int | col, | ||
int | row | ||
) |
Pass in the coordinates of a square with a piece on it and it will return the number of moves that piece can make and put the coordinates of the moves in pOutMoves (first col, then row, so pOutMoves should be big enough to hold 2 * MAX_PIECE_MOVES values)
|
inline |
Returns the piece located at position (col, row), and sets *pbWhite to true if the piece is white.
void GClasses::GChessBoard::printBoard | ( | std::ostream & | stream | ) |
Print a representation of the board to the specified stream.
void GClasses::GChessBoard::resetBoard | ( | ) |
Sets up the board for a new game.
|
inline |
Sets the piece at location (col, row). If piece is None, then it doesn't matter what the value of white is.
|
protected |