test highlight possible mais ca marche pas

This commit is contained in:
Romain MURPHY 2025-04-09 11:53:27 +02:00
parent 416a9c2ed7
commit 6d11ab8f0c
2 changed files with 48 additions and 1 deletions

View File

@ -1,5 +1,5 @@
package backend;
public class Move {
}

View File

@ -0,0 +1,47 @@
package backend;
import java.util.ArrayList;
public class PossibleMovements {
ArrayList<ArrayList<Piece>> board;
Piece pieceToMove;
PieceType type;
int x;
int y;
boolean turnColor;
public PossibleMovements(ArrayList<ArrayList<Piece>> board, int x, int y,boolean turnColor) {
this.board = board;
this.pieceToMove = board.get(y).get(x);
this.type = pieceToMove.getType();
this.x = x;
this.y = y;
this.turnColor = turnColor;
}
public ArrayList<ArrayList<Boolean>> PM(){
ArrayList<ArrayList<Boolean>> possibleMoves = new ArrayList<>();
int rows = 8;
int cols = 8;
for (int i = 0; i < rows; i++) {
ArrayList<Boolean> row = new ArrayList<>();
for (int j = 0; j < cols; j++) {
row.add(false); // Fill with false
}
possibleMoves.add(row);
}
if (turnColor) {
if (type == PieceType.Pawn) {
if (x == 0) {
if (board.get(y).get(x+1) != null) {
possibleMoves.get(y).set(x+1, true);
}
}
if (x==7) {
if (board.get(y).get(x-1) != null) {
possibleMoves.get(y).set(x-1, true);
}
}
for (int xi = 1; xi<7;i++) {
}
}
}
}