This commit is contained in:
romca 2025-05-06 16:33:27 +02:00
commit 6e3e5311b8
2 changed files with 7 additions and 9 deletions

View File

@ -95,7 +95,7 @@ public class Board {
String result = "";
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
String c = ".";
String c = " ";
for (Piece p : pieces) {
if (p.getX() == x && p.getY() == y) {
String letter = p.getType().getSummary();
@ -106,7 +106,7 @@ public class Board {
}
}
}
result += c + " ";
result += c + ",";
}
result += "\n";
}
@ -120,7 +120,7 @@ public class Board {
}
return result;
}
private Piece getPieceAt(int x, int y) {
public Piece getPieceAt(int x, int y) {
for (Piece p : pieces) {
if (p.getX() == x && p.getY() == y) {
return p;
@ -171,7 +171,6 @@ public class Board {
}
}
public boolean isSelected(int x, int y) {
// Check if the selected coordinates match the given x and y
if (selectedX != null && selectedY != null) {

View File

@ -1,16 +1,15 @@
package backend;
public class Piece {
private int x;
private int y;
private PieceType type;
private boolean isWhite;
private boolean isWhite; // true if the piece is white, false if black
public Piece(int x, int y, PieceType type, boolean isWhite) {
this.x = x;
this.y = y;
this.type = type;
this.isWhite = isWhite; // true if the piece is white, false if black
this.isWhite = isWhite;
}
public int getX() {