From 48cad448d78e25154d9d2b7eeffbe403a455a883 Mon Sep 17 00:00:00 2001 From: loveb Date: Tue, 10 May 2022 14:45:57 +0200 Subject: [PATCH] tydligare variabelnamn --- src/schack/Board.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/schack/Board.java b/src/schack/Board.java index f934a05..f2221d7 100644 --- a/src/schack/Board.java +++ b/src/schack/Board.java @@ -116,7 +116,6 @@ public class Board extends JPanel implements MouseListener { ArrayList allValidMoves = new ArrayList<>(); for (Piece[] pieceArr : pieces) { for (Piece piece : pieceArr) { - // || pieces[currentPlayer].contains(piece) if (piece == null || whitesTurn != piece.isWhite()) { continue; } @@ -129,7 +128,7 @@ public class Board extends JPanel implements MouseListener { ArrayList opposingAttacks = checkAttacks(!whitesTurn); boolean weCanMove = allValidMoves.size() > 0; - boolean hasShowedMessageAboutSchack = false; + boolean isPatt = false; for (Point attack : opposingAttacks) { Piece attacked = pieces[attack.x][attack.y]; @@ -143,10 +142,10 @@ public class Board extends JPanel implements MouseListener { } else { JOptionPane.showMessageDialog(this, "Schackmatt"); } - hasShowedMessageAboutSchack = true; + isPatt = true; } } - if (!hasShowedMessageAboutSchack && !weCanMove) { + if (!isPatt && !weCanMove) { JOptionPane.showMessageDialog(this, "Patt"); }