Compare commits

..

2 Commits

Author SHA1 Message Date
keshi 0449c8220a Merge branch 'master' of
https://gitarero.ecam.fr/keshini.nistar/OOP_Groupe_1A3_Project.git
2025-05-23 08:46:57 +02:00
keshi c0dc7d7b59 updated highlighter slgithly 2025-05-23 07:22:43 +02:00
3 changed files with 8 additions and 62 deletions

View File

@ -308,10 +308,11 @@ public class Board {
/* The following methods require more work ! */
/*private void highlightedPossibleMoves(Piece piece) {
private void highlightedPossibleMoves(Piece piece) {
highlightedSquares.clear();
highlightedSquares.addAll(MoveHighlighter.getPossibleMoves(piece, this));
}*/
MoveHighlighter highlighter= new MoveHighlighter();
highlightedSquares.addAll(highlighter.getPossibleMoves(piece, this));
}
public boolean isHighlighted(int x, int y) {
for(int i=0; i<highlightedSquares.size();i++) { //loops through list of highlighted squares
@ -375,18 +376,6 @@ return false; }
this.highlightedSquares.clear();
}
private void updateTurnLabel() {
// TODO Auto-generated method stub
}
private void repaint() {
// TODO Auto-generated method stub
}
/*public Board(Board board) {
//TODO
@ -394,55 +383,12 @@ return false; }
public void playMove(Move move) {
//TODO
}
}
/** Expose the raw 2D array for testing or drawing. */
public Piece[][] getBoardArray() {
return board;
}
public void highlightedPossibleMoves(Piece piece) {
highlightedSquares.clear();
MovePiece move = new MovePiece(piece, this);
int x = piece.getX();
int y = piece.getY();
for (int newX = 0; newX < width; newX++) {
for (int newY = 0; newY < height; newY++) {
boolean isValid = false;
switch (piece.getType()) {
case Pawn:
isValid = move.movePawnSimulate(newX, newY);
break;
case Rook:
isValid = move.moveRookSimulate(newX, newY);
break;
case Knight:
isValid = move.moveKnightSimulate(newX, newY);
break;
case Bishop:
isValid = move.moveBishopSimulate(newX, newY);
break;
case Queen:
isValid = move.moveQueenSimulate(newX, newY);
break;
case King:
isValid = move.moveKingSimulate(newX, newY);
break;
}
if (isValid) {
highlightedSquares.add(new int[]{newX, newY});
}
}
}
}
}

View File

@ -3,7 +3,7 @@ package backend;
import java.util.ArrayList;
public class MoveHighlighter {
public static ArrayList<int[]> getPossibleMoves(Piece piece, Board board){
public ArrayList<int[]> getPossibleMoves(Piece piece, Board board){
ArrayList<int[]> validMoves = new ArrayList<int[]>();
MovePiece movement = new MovePiece(piece, board);
PieceType type= piece.getType();

View File

@ -10,7 +10,7 @@ public class MovePiece {
this.board = board;
}
/* i honestly dont know if i change it to that or not #keshini
/*alternative
* public boolean validateMove(int x, int y, boolean simulate) {
PieceType type = piece.getType();
switch(type) {