victory checking
This commit is contained in:
parent
f854687c3e
commit
15fc3a6851
|
|
@ -449,7 +449,7 @@ public class Board {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//get current piece coordinate
|
//gets current piece coordinate
|
||||||
int fromX = move.piece.getX();
|
int fromX = move.piece.getX();
|
||||||
int fromY = move.piece.getY();
|
int fromY = move.piece.getY();
|
||||||
int toX = move.toX;
|
int toX = move.toX;
|
||||||
|
|
@ -479,7 +479,7 @@ public class Board {
|
||||||
this.highlightedPositions.clear();
|
this.highlightedPositions.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
//manually check for victory if needed
|
//manually checks for victory if needed
|
||||||
public boolean isCheckmate() {
|
public boolean isCheckmate() {
|
||||||
gameResult.checkForVictory(this);
|
gameResult.checkForVictory(this);
|
||||||
return gameResult.isGameOver();
|
return gameResult.isGameOver();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package backend;
|
package backend;
|
||||||
|
|
||||||
// Class to track the outcome of a chess game
|
// Class to track the outcome of a chess game
|
||||||
|
|
||||||
public class GameResult {
|
public class GameResult {
|
||||||
private boolean gameOver = false;
|
private boolean gameOver = false;
|
||||||
private boolean whiteWon = false;
|
private boolean whiteWon = false;
|
||||||
|
|
@ -49,7 +48,7 @@ public class GameResult {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset the game result to start a new game
|
// Reset the game result to start a new game
|
||||||
public void reset() {
|
public void reset() {
|
||||||
gameOver = false;
|
gameOver = false;
|
||||||
whiteWon = false;
|
whiteWon = false;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ public class VictoryChecker {
|
||||||
// Check if a player has won the chess game via checkmate
|
// Check if a player has won the chess game via checkmate
|
||||||
|
|
||||||
public static boolean checkVictory(Board board, boolean isWhitePlayer) {
|
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;
|
boolean opponentColor = !isWhitePlayer;
|
||||||
|
|
||||||
// Debug info
|
// Debug info
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue