本文整理汇总了C++中Checker::getIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Checker::getIndex方法的具体用法?C++ Checker::getIndex怎么用?C++ Checker::getIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Checker
的用法示例。
在下文中一共展示了Checker::getIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getJump
// just gets the first jump it finds for now
Checkers::Move MoveMaker::getJump()
{
Checkers::Move move = {Checkers::SW, 22};
vector<Checker*> myCheckers = m_board.getComputerCheckers();
vector<Checker*>::iterator it;
for (it = myCheckers.begin(); it != myCheckers.end(); ++it)
{
Checker* checker = *it;
Square* sq = (*it)->getSquare();
Square* neighbor = sq->getSW();
if (neighbor != nullptr && neighbor->getChecker() != nullptr)
{
Checker* neighborChecker = neighbor->getChecker();
if (neighborChecker->getColor() == Checkers::RED)
{
Square* jumpSquare = neighbor->getSW();
if (jumpSquare != nullptr && jumpSquare->getChecker() == nullptr)
{
move.index = checker->getIndex();
move.dir = Checkers::SW;
break;
}
}
}
neighbor =sq->getSE();
if (neighbor != nullptr && neighbor->getChecker() != nullptr)
{
Checker* neighborChecker = neighbor->getChecker();
if (neighborChecker->getColor() == Checkers::RED)
{
Square* jumpSquare = neighbor->getSE();
if (jumpSquare != nullptr && jumpSquare->getChecker() == nullptr)
{
move.index = checker->getIndex();
move.dir = Checkers::SE;
break;
}
}
}
}
return move;
}