* @param pos the piece to check
* @return the number of moves added
*/
private int addMovesForDirection( BoardPosition pos,
int rowInc, int colInc, TwoPlayerMove lastMove, MoveList moveList) {
BoardPosition next = board_.getPosition( pos.getRow() + rowInc, pos.getCol() + colInc );
if (next!=null)
{
if (next.isUnoccupied()) {
addSimpleMove(pos, rowInc, colInc, lastMove, moveList);
// only one move added
return 1;
}
// if just a simple move was not possible, we check for jump(s)
BoardPosition beyondNext = board_.getPosition( pos.getRow() + 2 * rowInc, pos.getCol() + 2 * colInc );
if (next.isOccupied() &&
(next.getPiece().isOwnedByPlayer1() != pos.getPiece().isOwnedByPlayer1()) &&
beyondNext!=null && beyondNext.isUnoccupied()) {
return addJumpMoves(pos, rowInc, lastMove, next, beyondNext, moveList);
}
}
return 0; // no moves added
}