Пример #1
0
  public boolean isKingInCheck() {

    Point kingsLocation = null;
    for (Entry<Point, Piece> p : b.entrySet()) {
      if (p.getValue() instanceof King && isWhitesTurn == p.getValue().getColor()) {
        kingsLocation = p.getKey();
      }
    }
    for (Entry<Point, Piece> p : b.entrySet()) {
      if ((isWhitesTurn != p.getValue().getColor()) && validTake(p.getKey(), kingsLocation)) {
        return true;
      }
    }
    return false;
  }
Пример #2
0
  public boolean checkForCheckMate() {

    boolean checkMate = true;

    for (Entry<Point, Piece> p : b.entrySet()) {
      if (isWhitesTurn == p.getValue().getColor() && validMove(p.getKey()).size() != 0) {
        checkMate = false;
      }
    }

    return checkMate;
  }