Schack funkar lite bättre men man fattar inte

This commit is contained in:
k1ntas
2022-04-07 08:48:24 +02:00
parent 29df86030c
commit 70097886d4
3 changed files with 8 additions and 8 deletions

View File

@ -157,8 +157,8 @@ public class Board extends JPanel implements MouseListener {
validMoves.removeAll(turn ? blackAttacks : whiteAttacks);
}
// Funkar inte
for (Point attack : turn ? whiteAttacks : blackAttacks) {
Piece attacked = pieces[attack.x][attack.x];
for (Point attack : turn ? blackAttacks : whiteAttacks) {
Piece attacked = pieces[attack.x][attack.y];
if (attacked == null) {
continue;
}

View File

@ -18,6 +18,7 @@ public class Queen extends Piece {
// Vänster
for (int loopX = this.position.x - 1; loopX >= 0; loopX--) {
boolean shouldBreak = addMovesIfCan(new Point(loopX, this.position.y), movable, pieces);
if (shouldBreak) {
break;
}