/*! Returns true if the king of \a side can reach the eighth rank */ bool RacingKingsBoard::canFinish(Side side) { QVarLengthArray<Move> moves; WesternBoard::generateMovesForPiece(moves, King, kingSquare(side)); for (const Move& m: moves) { Square targetSq = chessSquare(m.targetSquare()); if (targetSq.rank() == 7 && vIsLegalMove(m) ) return true; } return false; }
bool OukBoard::inCheck(Side side, int square) const { int sign = (side == Side::White) ? 1 : -1; Side opSide = side.opposite(); if (square == 0) square = kingSquare(side); // Attack by Advisor (Maiden, Neang), initial move if (!m_moveCount[opSide][Maiden] && m_initialSquare[opSide][Maiden] == square - 2 * sign * (width() + 2)) return true; // Attack by King, initial move int ksq = kingSquare(opSide); bool attacked = (ksq == square - 8 * sign || ksq == square - 12 * sign); if (!m_moveCount[opSide][King] && attacked) { if (square == kingSquare(side) || !inCheck(opSide)) return true; } return MakrukBoard::inCheck(side, square); }
/*! Returns true if the king of \a side is on the eighth rank */ bool RacingKingsBoard::finished(Side side) const { Square ksq = chessSquare(kingSquare(side)); return (ksq.rank() == 7); }
/*! Returns true if the king of \a side is occupying a central square */ bool KingOfTheHillBoard::kingInCenter(Side side) const { return m_centralSquares.contains(kingSquare(side)); }