I added the sound
This commit is contained in:
parent
ebcda9c623
commit
93e9c71855
Binary file not shown.
Binary file not shown.
|
|
@ -59,7 +59,7 @@ public class Board {
|
|||
Piece p = pieces.get(i);
|
||||
if (p.getX() == x && p.getY() == y) {
|
||||
pieces.remove(i);
|
||||
break;
|
||||
i = pieces.size();
|
||||
}
|
||||
}
|
||||
Piece newPiece = new Piece(x, y, type, isWhite);
|
||||
|
|
@ -72,7 +72,7 @@ public class Board {
|
|||
Piece p = pieces.get(i);
|
||||
if (p.getX() == x && p.getY() == y) {
|
||||
pieces.remove(i);
|
||||
break;
|
||||
i = pieces.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -189,6 +189,10 @@ public class Board {
|
|||
if (move.isValid()) {
|
||||
move.execute();
|
||||
|
||||
// Play the move sound
|
||||
Sound.getInstance().playMoveSound();
|
||||
|
||||
|
||||
// Check for checkmate
|
||||
if (move.putsOpponentInCheckmate()) {
|
||||
System.out.println("Checkmate! " + (isWhiteTurn ? "Black" : "White") + " wins!");
|
||||
|
|
@ -256,7 +260,9 @@ public class Board {
|
|||
}
|
||||
|
||||
for (int y = 0; y < height; y++) {
|
||||
if (y >= array.length) break;
|
||||
if (y >= array.length) {
|
||||
y = height;
|
||||
}else {
|
||||
|
||||
String line = array[y];
|
||||
String[] squares = line.split(",");
|
||||
|
|
@ -274,6 +280,7 @@ public class Board {
|
|||
pieces.add(new Piece(x, y, type, isWhite));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (array.length > height) {
|
||||
String turnInfo = array[height];
|
||||
|
|
@ -360,6 +367,9 @@ public class Board {
|
|||
public void playMove(Move move) {
|
||||
if (move.isValid() && !move.putsOwnKingInCheck()) {
|
||||
move.execute();
|
||||
|
||||
// Play the move sound
|
||||
Sound.getInstance().playMoveSound();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue