本文整理汇总了C++中Move::AddPieceReference方法的典型用法代码示例。如果您正苦于以下问题:C++ Move::AddPieceReference方法的具体用法?C++ Move::AddPieceReference怎么用?C++ Move::AddPieceReference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Move
的用法示例。
在下文中一共展示了Move::AddPieceReference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
std::list<Move*> *Slide::DetermineNextSteps(Move *baseMove, Piece *piece, MoveStep *previousStep)
{
std::list<Move*> *moves = new std::list<Move*>();
// some steps will specify a different piece to act upon, rather than the piece being moved
if (!moveSelf)
{
piece = baseMove->GetPieceByReference(pieceRef, piece);
if (piece == 0)
{
ReportError("Referenced piece not found for slide move: %s\n", pieceRef);
return moves;
}
}
Player *player = baseMove->GetPlayer();
Game *game = player->GetGame();
direction_t dirs = player->ResolveDirections(direction, previousStep != 0 && previousStep->GetDirection() != 0 ? previousStep->GetDirection() : player->GetForwardDirection());
FOR_EACH_DIR_IN_SET(dirs, dir)
{
int boardMaxDist = piece->GetPosition()->GetMaxDist(dir);
int minDist = distance->GetValue(previousStep, boardMaxDist);
int maxDist = distance->GetMaxValue(distanceMax, previousStep, boardMaxDist);
Cell *cell = piece->GetPosition();
for (int dist = 1; dist <= maxDist; dist++)
{
cell = cell->FollowLink(dir);
if (cell == 0)
break;
Piece *target = cell->GetPiece();
if (dist >= minDist)
{
MoveStep *captureStep = 0;
if (target == 0)
{
if (when == Capturing)
continue; // needs to be a capture for this slide to be valid, and there is no piece here. But there might be pieces beyond this one.
}
else
{
if (when == Moving)
break;
else if (piece->CanCapture(target))
captureStep = CreateCapture(target, piece);
else
break; // cannot capture this piece. Slides cannot pass over pieces, so there can be no more valid slides in this direction.
}
Move *move = baseMove->Clone();
MoveStep *lastPerformedStep = move->GetSteps().empty() ? 0 : *move->GetSteps().rbegin();
if (captureStep != 0)
{
move->AddStep(captureStep);
move->AddPieceReference(target, "target");
}
move->AddStep(MoveStep::CreateMove(piece, piece->GetPosition(), cell, dir, dist));
if (conditions == 0 || conditions->IsSatisfied(piece, move, lastPerformedStep))
moves->push_back(move);
else
delete move;
}
if (target != 0)
break; // Slides can't pass intervening pieces. As this cell was occupied, can be no more valid slides in this direction.
}
}