comments
This commit is contained in:
parent
2db80d8b31
commit
3cf002e795
|
|
@ -8,7 +8,7 @@ public abstract class Piece {
|
||||||
public PieceType type;
|
public PieceType type;
|
||||||
public boolean isWhite;
|
public boolean isWhite;
|
||||||
|
|
||||||
// Track the previous Y position
|
|
||||||
protected int previousY;
|
protected int previousY;
|
||||||
|
|
||||||
private boolean hasMoved = false;
|
private boolean hasMoved = false;
|
||||||
|
|
@ -18,7 +18,7 @@ public abstract class Piece {
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.isWhite = isWhite;
|
this.isWhite = isWhite;
|
||||||
this.previousY = y; // Initialize previousY to current Y position
|
this.previousY = y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getX() {
|
public int getX() {
|
||||||
|
|
@ -37,17 +37,17 @@ public abstract class Piece {
|
||||||
return this.isWhite;
|
return this.isWhite;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getter for previous Y position
|
|
||||||
public int getPreviousY() {
|
public int getPreviousY() {
|
||||||
return previousY;
|
return previousY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the moved flag and update previous Y when the piece moves
|
|
||||||
public void moveTo(int newX, int newY) {
|
public void moveTo(int newX, int newY) {
|
||||||
this.previousY = this.y; // Update previous Y before changing the position
|
this.previousY = this.y;
|
||||||
this.x = newX;
|
this.x = newX;
|
||||||
this.y = newY;
|
this.y = newY;
|
||||||
this.hasMoved = true; // Mark that the piece has moved
|
this.hasMoved = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasMoved() {
|
public boolean hasMoved() {
|
||||||
|
|
@ -58,7 +58,7 @@ public abstract class Piece {
|
||||||
this.hasMoved = moved;
|
this.hasMoved = moved;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abstract method to get possible moves (to be implemented by subclasses)
|
|
||||||
public abstract ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board);
|
public abstract ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board);
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -67,8 +67,8 @@ public abstract class Piece {
|
||||||
return "Piece [x=" + x + ", y=" + y + ", type=" + type + ", isWhite=" + isWhite + "]";
|
return "Piece [x=" + x + ", y=" + y + ", type=" + type + ", isWhite=" + isWhite + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the overloaded method for getting possible moves with lastMove
|
|
||||||
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board, Move lastMove) {
|
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board, Move lastMove) {
|
||||||
return null; // Will be implemented in specific piece subclasses (e.g., Pawn)
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue