king check sound (still small problems)
This commit is contained in:
parent
b494861f8d
commit
a4db7193e2
|
|
@ -3,6 +3,9 @@ package backend;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class KingCheck {
|
public class KingCheck {
|
||||||
|
private boolean opponentWasInCheck = false;
|
||||||
|
private SoundEffect soundEffect = new SoundEffect();
|
||||||
|
private boolean soundShouldPlay = true;
|
||||||
public ArrayList<ArrayList<Boolean>> getLegalMoves(Piece piece, ArrayList<ArrayList<Piece>> board, Move lastMove) {
|
public ArrayList<ArrayList<Boolean>> getLegalMoves(Piece piece, ArrayList<ArrayList<Piece>> board, Move lastMove) {
|
||||||
ArrayList<ArrayList<Boolean>> rawMoves = piece.getPossibleMoves(board,lastMove);
|
ArrayList<ArrayList<Boolean>> rawMoves = piece.getPossibleMoves(board,lastMove);
|
||||||
|
|
||||||
|
|
@ -53,12 +56,14 @@ public class KingCheck {
|
||||||
if (p != null && p.isWhite() != isWhiteTurn) {
|
if (p != null && p.isWhite() != isWhiteTurn) {
|
||||||
ArrayList<ArrayList<Boolean>> moves = p.getPossibleMoves(board);
|
ArrayList<ArrayList<Boolean>> moves = p.getPossibleMoves(board);
|
||||||
if (moves.get(kingY).get(kingX)) {
|
if (moves.get(kingY).get(kingX)) {
|
||||||
return true; // King can be captured
|
if (soundShouldPlay){
|
||||||
|
soundEffect.aiSound();
|
||||||
|
soundShouldPlay=false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false; // King is safe
|
return false; // King is safe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue