moves and pieces correlation
This commit is contained in:
parent
32333cf768
commit
76f061e679
|
|
@ -235,4 +235,10 @@ public class Board {
|
|||
|
||||
}
|
||||
|
||||
public boolean isEmpty(int x, int newY) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package backend;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Piece {
|
||||
private int x;
|
||||
private int y;
|
||||
|
|
@ -29,4 +31,42 @@ 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