コード例 #1
0
ファイル: Overlord.java プロジェクト: KStClaire/Chess
  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
ファイル: Overlord.java プロジェクト: KStClaire/Chess
  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;
  }