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; }
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; }