本文整理汇总了C++中Chess::setPieceCaptured方法的典型用法代码示例。如果您正苦于以下问题:C++ Chess::setPieceCaptured方法的具体用法?C++ Chess::setPieceCaptured怎么用?C++ Chess::setPieceCaptured使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chess
的用法示例。
在下文中一共展示了Chess::setPieceCaptured方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isMoveValid
//------------------------------------------------------------------------------
bool Piece::isMoveValid(int src_row, int src_col,
int dest_row, int dest_col,
Piece* game_area[8][8], Chess& game_control)
{
Piece* dest_area = game_area[dest_row][dest_col];
if((dest_area == NULL) || (piece_color_ != dest_area->getColor()))
{
bool ret = areSquaresLegal(src_row, src_col, dest_row, dest_col, game_area,
game_control);
if(ret == false && game_control.getErrorCode() != ERROR_PIECE_ON_WAY)
{
game_control.setErrorCode(ERROR_TARGET_NOT_REACHABLE);
}
game_control.setPieceCaptured(false);
if((ret == true) && (dest_area != NULL) &&
(piece_color_ != dest_area->getColor()))
{
game_control.setPieceCaptured(true);
}
return ret;
}
else
{
bool ret = areSquaresLegal(src_row, src_col, dest_row,
dest_col, game_area,
game_control);
if(ret == false && game_control.getErrorCode() != ERROR_PIECE_ON_WAY)
{
game_control.setErrorCode(ERROR_TARGET_NOT_REACHABLE);
}
else
{
game_control.setErrorCode(ERROR_OWN_PIECE_ON_TARGET);
}
}
// check if the player goes to a square, where his own piece is on
// but also another piece is on the way
if((dest_area != NULL) && (piece_color_ == dest_area->getColor()))
{
areSquaresLegal(src_row, src_col, dest_row, dest_col, game_area,
game_control);
}
return false;
}