Compare commits

..

No commits in common. "2e04e595296f0eadf8b673dafff710efe664a5cf" and "474a24d10e81a230f317b2d44f92078457088a9e" have entirely different histories.

2 changed files with 0 additions and 68 deletions

View File

@ -79,10 +79,6 @@ public class Board {
public void cleanBoard() {
pieces.clear();
turnNumber = 0;
turnWhite = true;
selected = null;
highlighted.clear();
//TODO
}
@ -122,62 +118,6 @@ public class Board {
}
public void userTouch(int x, int y) {
// If no position has been previously selected
if (selected == null) {
// Check if there is a piece at the selected coordinates
for (Piece piece : pieces) {
if (piece.getX() == x && piece.getY() == y) {
// If a piece is found, select the position
selected = new int[]{x, y};
return;
}
}
} else {
// If a position is already selected
if (selected[0] == x && selected[1] == y) {
// If the selected position is the same as the current position, unselect it
selected = null;
} else {
// Otherwise, move the piece from the selected position to the new position
Piece selectedPiece = null;
Piece capturedPiece = null;
for (Piece piece : pieces) {
if (piece.getX() == selected[0] && piece.getY() == selected[1]) {
selectedPiece = piece;
break;
}
}
for (Piece piece : pieces) {
if (piece.getX() == x && piece.getY() == y && piece != selectedPiece) {
capturedPiece = piece; // Capture the piece
pieces.remove(piece); // Remove the captured piece from the board
break;
}
}
if (selectedPiece != null) {
// Move the piece to the new position
selectedPiece.setX(x);
selectedPiece.setY(y);
// Increment the turn number and switch turns
turnNumber++;
turnWhite = !turnWhite;
// Optionally, add the move to moveHistory if you'd like to track moves
moveHistory.add(new Move(selectedPiece, selected[0], selected[1], x, y, capturedPiece));
}
// After the move, unselect the piece
selected = null;
}
}
//TODO
Piece clickedPiece = getPieceAt(x, y);
if (selected == null) {
@ -205,7 +145,6 @@ public class Board {
}
}
}
}

View File

@ -14,16 +14,10 @@ public class Piece {
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public PieceType getType() {
return type;
@ -37,5 +31,4 @@ public class Piece {
this.x=x;
this.y=y;
}
}