if (!Boards.inRange(boardMove, horizDest, vertDest)) {
break;
}
// Make a clone of the current board set to calculate the move with.
BoardSet set = board.getSet().clone();
// Figure out which board to work with.
BoardDef boardDest = set.getBoard(Boards.values()[boardMove]);
// Diagonal step checking: The in-between steps for diagonal
// movements must be empty if doing this check.
if (getCheck() != null) {
int horizCheck = horizDest - getDir().getHoriz()
+ getCheck().getHoriz();
int vertCheck = vertDest - getDir().getVert()
+ getCheck().getVert();
int boardCheck = boardMove - getDir().getBoard()
+ getCheck().getBoard();
BoardDef boardCheckDest = set
.getBoard(Boards.values()[boardCheck]);
if (boardCheckDest.get(vertCheck, horizCheck) != null) {
break;
}
}
// Figure out what piece (if any) is at the destination location.
BoardPiece destPiece = boardDest.get(vertDest, horizDest);
// Destination piece is the same team.
if (destPiece != null && destPiece.getTeam() == team) {
break;
// Destination piece is the other team.
} else if (destPiece != null) {
PieceDef destPieceDef = PieceDef.get(destPiece.getType());
score = destPieceDef.getValue();
}
// CAPTURE can only capture, MOVE can only move.
if ((score == 0 && getType() == MoveTypes.CAPTURE)
|| (score > 0 && getType() == MoveTypes.MOVE)) {
break;
}
// Perform the move on the cloned board set.
set.move(board.getType(), horizPos, vertPos, boardDest.getType(),
horizDest, vertDest);
// Validate for check condition -- the move cannot place your own
// king in check.
if (!check && set.isCheck(team.other())) {
continue;
}
// Get the hash for the board set for this move.
hash = set.hash();
MoveTypes type = null;
// The user will be told if the move captures or just moves the
// piece.