lots of things

This commit is contained in:
2025-04-01 23:11:41 +02:00
parent 2c6b64fa7d
commit 1b9ff5bdd1
15 changed files with 428 additions and 79 deletions

View File

@@ -3,15 +3,17 @@ package chess.model;
public abstract class Piece {
private final Color color;
private boolean moved;
private int moved;
private int ejectedMoveNumber;
public Piece(Color color) {
this.color = color;
this.moved = false;
this.moved = 0;
this.ejectedMoveNumber = -1;
}
public void move() {
this.moved = true;
this.moved++;
}
public Color getColor() {
@@ -19,11 +21,23 @@ public abstract class Piece {
}
public boolean hasMoved() {
return moved;
return moved > 0;
}
public void eject() {
// for later
public void unMove() {
this.moved--;
}
public boolean isEjected() {
return this.ejectedMoveNumber != -1;
}
public int getEjectedMoveNumber() {
return ejectedMoveNumber;
}
public void eject(int moveNumber) {
this.ejectedMoveNumber = moveNumber;
}
public abstract <T> T accept(PieceVisitor<T> visitor);