Update Board.java

This commit is contained in:
loveb 2022-05-10 14:48:39 +02:00
parent 48cad448d7
commit 8e171a85db

View File

@ -128,7 +128,7 @@ public class Board extends JPanel implements MouseListener {
ArrayList<Point> opposingAttacks = checkAttacks(!whitesTurn); ArrayList<Point> opposingAttacks = checkAttacks(!whitesTurn);
boolean weCanMove = allValidMoves.size() > 0; boolean weCanMove = allValidMoves.size() > 0;
boolean isPatt = false; boolean inSchack = false;
for (Point attack : opposingAttacks) { for (Point attack : opposingAttacks) {
Piece attacked = pieces[attack.x][attack.y]; Piece attacked = pieces[attack.x][attack.y];
@ -142,10 +142,10 @@ public class Board extends JPanel implements MouseListener {
} else { } else {
JOptionPane.showMessageDialog(this, "Schackmatt"); JOptionPane.showMessageDialog(this, "Schackmatt");
} }
isPatt = true; inSchack = true;
} }
} }
if (!isPatt && !weCanMove) { if (!inSchack && !weCanMove) {
JOptionPane.showMessageDialog(this, "Patt"); JOptionPane.showMessageDialog(this, "Patt");
} }