currently working on highlights again cuz it didnt work

This commit is contained in:
keshi 2025-05-11 16:02:42 +02:00
parent 3ed3826df5
commit 0c88880e81
2 changed files with 11 additions and 6 deletions

View File

@ -9,7 +9,7 @@ public class Board {
private Piece chosenPiece=null;
private int turnNumber=0;
private boolean isTurnWhite=true;
private ArrayList<int[]> highlightedSquares= new ArrayList<>();
private ArrayList<int[]> highlightedSquares= new ArrayList<>(); //stores highlighted board position
public Board(int colNum, int lineNum) {
this.width=colNum;
@ -167,10 +167,15 @@ public class Board {
/* The following methods require more work ! */
public boolean isHighlighted(int x, int y) {
//return highlightedSquares.contains(Point(x,y));
return true
;}
public boolean isHighlighted(int x, int y) { //loop through list of highlighted squares
for(int i=0;i<highlightedSquares.size();i++) { //gets the current position of the piece at (x,y)
int[] position = highlightedSquares.get(i);
if(position[0]==x && position[1]==y) { //checking if position matches coordinates
return true;
}
}
return false; }
public void undoLastMove() {
//TODO

View File

@ -156,7 +156,7 @@ public class MovePiece {
if ((stepX <= 1 && stepY <= 1) && !(stepX == 0 && stepY == 0)) { //moving 1 space in any direction
Piece targetPiece = board.getPiece(x, y);
if (targetPiece == null || targetPiece.isWhite() != piece.isWhite()) { //move is space is empty or capture
if (targetPiece == null || targetPiece.isWhite() != piece.isWhite()) { //move is space is empty o
board.movePiece(currentX, currentY, x, y);
return true;
}