mirror of
https://github.com/lov3b/Schack.git
synced 2025-01-18 21:00:11 +01:00
We did the clear thing
This commit is contained in:
parent
9097a966f0
commit
f070ae87a4
@ -82,6 +82,7 @@ public class Board extends JPanel implements MouseListener {
|
|||||||
g2.fillOval(point.x * SIZE_OF_TILE, point.y * SIZE_OF_TILE, SIZE_OF_TILE, SIZE_OF_TILE);
|
g2.fillOval(point.x * SIZE_OF_TILE, point.y * SIZE_OF_TILE, SIZE_OF_TILE, SIZE_OF_TILE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Draw piece
|
// Draw piece
|
||||||
Arrays.stream(pieces).forEach(pieceArr -> Arrays.stream(pieceArr).forEach(piece -> {
|
Arrays.stream(pieces).forEach(pieceArr -> Arrays.stream(pieceArr).forEach(piece -> {
|
||||||
if (piece != null) {
|
if (piece != null) {
|
||||||
@ -171,32 +172,46 @@ public class Board extends JPanel implements MouseListener {
|
|||||||
|
|
||||||
// Ifall vi har tryckt på en pjäs och sedan ska gå dit
|
// Ifall vi har tryckt på en pjäs och sedan ska gå dit
|
||||||
if (validMovesToDraw.contains(clicked)) {
|
if (validMovesToDraw.contains(clicked)) {
|
||||||
|
|
||||||
|
System.out.println("1");
|
||||||
try {
|
try {
|
||||||
Piece p = pieces[selectedPiece.x][selectedPiece.y];
|
Piece p = pieces[selectedPiece.x][selectedPiece.y];
|
||||||
|
System.out.println("2");
|
||||||
p.move(pieces, clicked, selectedPiece);
|
p.move(pieces, clicked, selectedPiece);
|
||||||
validMovesToDraw.clear();
|
System.out.println("3");
|
||||||
System.out.println("came here");
|
|
||||||
|
System.out.println("4");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
validMovesToDraw.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
System.out.println("5");
|
||||||
selectedPiece = new Point(clicked);
|
selectedPiece = new Point(clicked);
|
||||||
|
System.out.println("6");
|
||||||
validMovesToDraw.clear();
|
validMovesToDraw.clear();
|
||||||
|
System.out.println("7");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("X: " + mouseCoordinateX + ", Y: " + mouseCoordinateY);
|
System.out.println("X: " + mouseCoordinateX + ", Y: " + mouseCoordinateY);
|
||||||
try {
|
if (!validMovesToDraw.contains(clicked)) {
|
||||||
Piece p = pieces[mouseCoordinateX][mouseCoordinateY];
|
System.out.println("8");
|
||||||
LinkedHashSet validMoves = p.validMoves(pieces);
|
try {
|
||||||
System.out.println("valid moves " + validMoves);
|
Piece p = pieces[mouseCoordinateX][mouseCoordinateY];
|
||||||
validMovesToDraw.addAll(validMoves);
|
System.out.println("9");
|
||||||
System.out.println("valid moves to draw " + validMovesToDraw);
|
LinkedHashSet validMoves = p.validMoves(pieces);
|
||||||
|
System.out.println("10");
|
||||||
|
validMovesToDraw.addAll(validMoves);
|
||||||
|
System.out.println("11");
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
System.out.println("12");
|
||||||
|
validMovesToDraw.clear();
|
||||||
|
System.out.println("13");
|
||||||
|
}
|
||||||
|
} else{
|
||||||
validMovesToDraw.clear();
|
validMovesToDraw.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ public class Queen extends Piece {
|
|||||||
public Queen(boolean isWhite, Point point) throws IOException {
|
public Queen(boolean isWhite, Point point) throws IOException {
|
||||||
super(isWhite, point);
|
super(isWhite, point);
|
||||||
setPieceIcon("Queen");
|
setPieceIcon("Queen");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LinkedHashSet<Point> validMoves(Piece[][] pieces) {
|
public LinkedHashSet<Point> validMoves(Piece[][] pieces) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user