// Clone the current board set for this move.
BoardSet set = board.getSet().clone();
// Figure out which board the move is going to.
BoardDef boardDest = set.getBoard(Boards.values()[boardMove]);
// Check what is at the destination.
BoardPiece destPiece = boardDest.get(vertDest, horizDest);
// Destination piece is on the same team.
if (destPiece != null && destPiece.getTeam() == team) {
return ret;
// Destination piece is on the other team.
} else if (destPiece != null) {
PieceDef destPieceDef = PieceDef.get(destPiece.getType());
score = destPieceDef.getValue();
}
// FROM_AFAR only makes sense with capture moves.
if (getType() == MoveTypes.FROM_AFAR && score == 0) {
return ret;
}
// Perform move on cloned board set.
set.move(board.getType(), horizPos, vertPos, boardDest.getType(),
horizDest, vertDest);
// FROM_AFAR doesn't need to worry about check validation.
if (getType() != MoveTypes.FROM_AFAR && !check
&& set.isCheck(team.other())) {
return ret;
}
// get the board set's hash for this move.
hash = set.hash();
MoveTypes type = null;
// Define what the type of the move is.
if (getType() == MoveTypes.FROM_AFAR) {
type = getType();
} else if (score == 0) {
type = MoveTypes.MOVE;
} else {
type = MoveTypes.CAPTURE;
}
// Load the move into the returned array.
ret.add(new Move(hash, score, boardDest.getType(), horizDest, vertDest,
type));
return ret;
}