本文整理汇总了C++中Chess::Clone方法的典型用法代码示例。如果您正苦于以下问题:C++ Chess::Clone方法的具体用法?C++ Chess::Clone怎么用?C++ Chess::Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chess
的用法示例。
在下文中一共展示了Chess::Clone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ApplyMove
Board* Board::ApplyMove(Move* move)
{
Board* new_board = new Board();
for (int i = 0; i < BoardSize * BoardSize; i++)
{
if (this->Chesses[i] != NULL)
new_board->Chesses[i] = this->Chesses[i]->Clone();
else
new_board->Chesses[i] = NULL;
}
while (move != NULL)
{
Chess* before = move->GetChessBeforeMove();
Chess* after = move->GetChessAfterMove();
Chess* captured = move->GetChessCaptured();
if (captured != NULL)
{
delete new_board->Chesses[captured->GetX() + captured->GetY() * pp9k::BoardSize];
new_board->Chesses[captured->GetX() + captured->GetY() * pp9k::BoardSize] = NULL;
}
delete new_board->Chesses[before->GetX() + before->GetY() * pp9k::BoardSize];
new_board->Chesses[before->GetX() + before->GetY() * pp9k::BoardSize] = NULL;
new_board->Chesses[after->GetX() + after->GetY() * pp9k::BoardSize] = after->Clone();
new_board->LastMovedChess = new_board->Chesses[after->GetX() + after->GetY() * pp9k::BoardSize];
move = move->GetSubMove();
}
new_board->Turn = this->Turn == White ? Black : White;
new_board->Confirm();
return new_board;
}