diff --git a/src/backend/Board.java b/src/backend/Board.java index 04bf1da..33f3e10 100644 --- a/src/backend/Board.java +++ b/src/backend/Board.java @@ -235,4 +235,10 @@ public class Board { } + public boolean isEmpty(int x, int newY) { + // TODO Auto-generated method stub + return false; + } + + } diff --git a/src/backend/Piece.java b/src/backend/Piece.java index 11e9a56..45a29ed 100644 --- a/src/backend/Piece.java +++ b/src/backend/Piece.java @@ -1,5 +1,7 @@ package backend; +import java.util.ArrayList; + public class Piece { private int x; private int y; @@ -28,5 +30,43 @@ 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