victory checking

This commit is contained in:
Valentine GIRAL 2025-05-16 12:20:35 +02:00
parent f854687c3e
commit 15fc3a6851
3 changed files with 4 additions and 5 deletions

View File

@ -449,7 +449,7 @@ public class Board {
return;
}
//get current piece coordinate
//gets current piece coordinate
int fromX = move.piece.getX();
int fromY = move.piece.getY();
int toX = move.toX;
@ -479,7 +479,7 @@ public class Board {
this.highlightedPositions.clear();
}
//manually check for victory if needed
//manually checks for victory if needed
public boolean isCheckmate() {
gameResult.checkForVictory(this);
return gameResult.isGameOver();

View File

@ -1,7 +1,6 @@
package backend;
// Class to track the outcome of a chess game
public class GameResult {
private boolean gameOver = false;
private boolean whiteWon = false;

View File

@ -10,7 +10,7 @@ public class VictoryChecker {
// Check if a player has won the chess game via checkmate
public static boolean checkVictory(Board board, boolean isWhitePlayer) {
// The opponent is the one who would be checkmated
// The opponent is the one who would be checkmated so opposite color
boolean opponentColor = !isWhitePlayer;
// Debug info