removed wrong pieces of code
This commit is contained in:
parent
7a3ae0e2a9
commit
18c29cd2df
|
|
@ -8,89 +8,4 @@ import java.util.Optional;
|
|||
*/
|
||||
public class Move {
|
||||
|
||||
private final int startX;
|
||||
private final int startY;
|
||||
private final int endX;
|
||||
private final int endY;
|
||||
private final Piece movingPiece;
|
||||
private final Optional<Piece> capturedPiece;
|
||||
|
||||
/**
|
||||
* Constructor for a move without a captured piece.
|
||||
*
|
||||
* @param startX the starting x-coordinate
|
||||
* @param startY the starting y-coordinate
|
||||
* @param endX the ending x-coordinate
|
||||
* @param endY the ending y-coordinate
|
||||
* @param movingPiece the piece being moved
|
||||
*/
|
||||
public Move(int startX, int startY, int endX, int endY, Piece movingPiece) {
|
||||
this.startX = startX;
|
||||
this.startY = startY;
|
||||
this.endX = endX;
|
||||
this.endY = endY;
|
||||
this.movingPiece = movingPiece;
|
||||
this.capturedPiece = Optional.empty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for a move involving a captured piece.
|
||||
*
|
||||
* @param startX the starting x-coordinate
|
||||
* @param startY the starting y-coordinate
|
||||
* @param endX the ending x-coordinate
|
||||
* @param endY the ending y-coordinate
|
||||
* @param movingPiece the piece being moved
|
||||
* @param capturedPiece the piece being captured
|
||||
*/
|
||||
public Move(int startX, int startY, int endX, int endY, Piece movingPiece, Piece capturedPiece) {
|
||||
this.startX = startX;
|
||||
this.startY = startY;
|
||||
this.endX = endX;
|
||||
this.endY = endY;
|
||||
this.movingPiece = movingPiece;
|
||||
this.capturedPiece = Optional.of(capturedPiece);
|
||||
}
|
||||
|
||||
public int getStartX() {
|
||||
return startX;
|
||||
}
|
||||
|
||||
public int getStartY() {
|
||||
return startY;
|
||||
}
|
||||
|
||||
public int getEndX() {
|
||||
return endX;
|
||||
}
|
||||
|
||||
public int getEndY() {
|
||||
return endY;
|
||||
}
|
||||
|
||||
public Piece getMovingPiece() {
|
||||
return movingPiece;
|
||||
}
|
||||
|
||||
public Optional<Piece> getCapturedPiece() {
|
||||
return capturedPiece;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this move involves a capture.
|
||||
*
|
||||
* @return true if a piece is captured, false otherwise
|
||||
*/
|
||||
public boolean isCapture() {
|
||||
return capturedPiece.isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String moveInfo = movingPiece.getType() + " from (" + startX + "," + startY + ") to (" + endX + "," + endY + ")";
|
||||
if (isCapture()) {
|
||||
moveInfo += " capturing " + capturedPiece.get().getType();
|
||||
}
|
||||
return moveInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,42 +31,4 @@ public class Piece {
|
|||
return pieceColor;
|
||||
}
|
||||
|
||||
public ArrayList<Move> getPossibleMoves(Board board) {
|
||||
ArrayList<Move> moves = new ArrayList<>();
|
||||
|
||||
switch (type) {
|
||||
case Pawn:
|
||||
// Example for a simple forward move (white only)
|
||||
int direction = isWhite() ? -1 : 1;
|
||||
int newY = y + direction;
|
||||
if (board.isEmpty(x, newY)) {
|
||||
moves.add(new Move(x, y, x, newY, this));
|
||||
}
|
||||
// Add capture moves, double-step moves etc. here
|
||||
break;
|
||||
|
||||
case Rook:
|
||||
// Add horizontal and vertical moves here
|
||||
break;
|
||||
|
||||
case Knight:
|
||||
// Add L-shaped moves here
|
||||
break;
|
||||
|
||||
case Bishop:
|
||||
// Add diagonal moves here
|
||||
break;
|
||||
|
||||
case Queen:
|
||||
// Combine Rook + Bishop moves
|
||||
break;
|
||||
|
||||
case King:
|
||||
// Add adjacent square moves
|
||||
break;
|
||||
}
|
||||
|
||||
return moves;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue