From 18c29cd2df978f46a086dd6f60d3d90771990420 Mon Sep 17 00:00:00 2001 From: ricoc Date: Fri, 18 Apr 2025 15:58:52 +0200 Subject: [PATCH] removed wrong pieces of code --- src/backend/Move.java | 85 ------------------------------------------ src/backend/Piece.java | 40 +------------------- 2 files changed, 1 insertion(+), 124 deletions(-) diff --git a/src/backend/Move.java b/src/backend/Move.java index 02a46a9..6d77bf7 100644 --- a/src/backend/Move.java +++ b/src/backend/Move.java @@ -7,90 +7,5 @@ import java.util.Optional; * the moving piece, and an optional captured piece. */ 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 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 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; - } } diff --git a/src/backend/Piece.java b/src/backend/Piece.java index a8ca25d..55cd98a 100644 --- a/src/backend/Piece.java +++ b/src/backend/Piece.java @@ -30,43 +30,5 @@ public class Piece { public boolean isWhite() { return pieceColor; } - - public ArrayList getPossibleMoves(Board board) { - ArrayList 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; - } - + } \ No newline at end of file