mirror of
https://github.com/lov3b/Schack.git
synced 2024-11-10 07:00:11 +01:00
tydligare variabelnamn
This commit is contained in:
parent
57d7f54e6f
commit
48cad448d7
@ -116,7 +116,6 @@ public class Board extends JPanel implements MouseListener {
|
|||||||
ArrayList<Point> allValidMoves = new ArrayList<>();
|
ArrayList<Point> allValidMoves = new ArrayList<>();
|
||||||
for (Piece[] pieceArr : pieces) {
|
for (Piece[] pieceArr : pieces) {
|
||||||
for (Piece piece : pieceArr) {
|
for (Piece piece : pieceArr) {
|
||||||
// || pieces[currentPlayer].contains(piece)
|
|
||||||
if (piece == null || whitesTurn != piece.isWhite()) {
|
if (piece == null || whitesTurn != piece.isWhite()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -129,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 hasShowedMessageAboutSchack = false;
|
boolean isPatt = false;
|
||||||
|
|
||||||
for (Point attack : opposingAttacks) {
|
for (Point attack : opposingAttacks) {
|
||||||
Piece attacked = pieces[attack.x][attack.y];
|
Piece attacked = pieces[attack.x][attack.y];
|
||||||
@ -143,10 +142,10 @@ public class Board extends JPanel implements MouseListener {
|
|||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(this, "Schackmatt");
|
JOptionPane.showMessageDialog(this, "Schackmatt");
|
||||||
}
|
}
|
||||||
hasShowedMessageAboutSchack = true;
|
isPatt = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasShowedMessageAboutSchack && !weCanMove) {
|
if (!isPatt && !weCanMove) {
|
||||||
JOptionPane.showMessageDialog(this, "Patt");
|
JOptionPane.showMessageDialog(this, "Patt");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user