DroidFish: Don't allow adding a null move to the game tree when the side to move is in check.

This commit is contained in:
Peter Osterlund
2014-10-04 12:32:48 +00:00
parent 944d16910d
commit 648a00dc92
2 changed files with 8 additions and 2 deletions

View File

@@ -2457,8 +2457,9 @@ public class DroidFish extends Activity implements GUIInterface {
}
boolean allowNullMove =
gameMode.analysisMode() ||
(gameMode.playerWhite() && gameMode.playerBlack() && !gameMode.clocksActive());
(gameMode.analysisMode() ||
(gameMode.playerWhite() && gameMode.playerBlack() && !gameMode.clocksActive())) &&
!ctrl.inCheck();
if (allowNullMove) {
lst.add(getString(R.string.add_null_move)); actions.add(ADD_NULL_MOVE);
}

View File

@@ -382,6 +382,11 @@ public class DroidChessController {
}
}
/** Return true if the player to move in the current position is in check. */
public final synchronized boolean inCheck() {
return MoveGen.inCheck(game.tree.currentPos);
}
/** Undo last move. Does not truncate game tree. */
public final synchronized void undoMove() {
if (game.getLastMove() != null) {