Move modification
This commit is contained in:
parent
a3c3c93858
commit
6fb087cbc0
|
|
@ -1,20 +1,51 @@
|
|||
package backend;
|
||||
|
||||
public class Move {
|
||||
private final Piece piece;
|
||||
private final int fromX, fromY, toX, toY;
|
||||
private final Piece movedPiece;
|
||||
private final int fromRow, fromCol;
|
||||
private final int toRow, toCol;
|
||||
private final Piece capturedPiece; // Optional, can be null
|
||||
|
||||
public Move(Piece piece, int fromX, int fromY, int toX, int toY) {
|
||||
this.piece = piece;
|
||||
this.fromX = fromX;
|
||||
this.fromY = fromY;
|
||||
this.toX = toX;
|
||||
this.toY = toY;
|
||||
public Move(Piece movedPiece, int fromRow, int fromCol, int toRow, int toCol) {
|
||||
this(movedPiece, fromRow, fromCol, toRow, toCol, null);
|
||||
}
|
||||
|
||||
public Piece getPiece() { return piece; }
|
||||
public int getFromX() { return fromX; }
|
||||
public int getFromY() { return fromY; }
|
||||
public int getToX() { return toX; }
|
||||
public int getToY() { return toY; }
|
||||
public Move(Piece movedPiece, int fromRow, int fromCol, int toRow, int toCol, Piece capturedPiece) {
|
||||
this.movedPiece = movedPiece;
|
||||
this.fromRow = fromRow;
|
||||
this.fromCol = fromCol;
|
||||
this.toRow = toRow;
|
||||
this.toCol = toCol;
|
||||
this.capturedPiece = capturedPiece;
|
||||
}
|
||||
|
||||
public Piece getMovedPiece() {
|
||||
return movedPiece;
|
||||
}
|
||||
|
||||
public int getFromRow() {
|
||||
return fromRow;
|
||||
}
|
||||
|
||||
public int getFromCol() {
|
||||
return fromCol;
|
||||
}
|
||||
|
||||
public int getToRow() {
|
||||
return toRow;
|
||||
}
|
||||
|
||||
public int getToCol() {
|
||||
return toCol;
|
||||
}
|
||||
|
||||
public Piece getCapturedPiece() {
|
||||
return capturedPiece;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return movedPiece.getType() + " from (" + fromRow + "," + fromCol + ") to (" + toRow + "," + toCol + ")" +
|
||||
(capturedPiece != null ? " capturing " + capturedPiece.getType() : "");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue