refactor game
This commit is contained in:
@@ -52,9 +52,8 @@ public class Game {
|
||||
if (destY != enemyLine)
|
||||
return false;
|
||||
|
||||
OnPromote.emit(pieceCoords);
|
||||
this.OnPromote.emit(pieceCoords);
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,22 +61,21 @@ public class Game {
|
||||
* @return true if game should end
|
||||
*/
|
||||
public boolean checkGameStatus() {
|
||||
final ChessBoard board = getBoard();
|
||||
|
||||
final Color enemy = Color.getEnemy(getPlayerTurn());
|
||||
|
||||
if (board.isKingInCheck(enemy)) {
|
||||
if (board.hasAllowedMoves(enemy)) {
|
||||
OnCheck.emit();
|
||||
if (this.board.isKingInCheck(enemy)) {
|
||||
if (this.board.hasAllowedMoves(enemy)) {
|
||||
this.OnCheck.emit();
|
||||
} else {
|
||||
OnMat.emit();
|
||||
OnWin.emit(getPlayerTurn());
|
||||
this.OnMat.emit();
|
||||
this.OnWin.emit(getPlayerTurn());
|
||||
return true;
|
||||
}
|
||||
} else if (!board.hasAllowedMoves(enemy)) {
|
||||
OnPat.emit();
|
||||
this.OnPat.emit();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -91,7 +89,7 @@ public class Game {
|
||||
int enemyLineY = color == Color.White ? 0 : 7;
|
||||
|
||||
for (int x = 0; x < Coordinate.VALUE_MAX; x++) {
|
||||
if(checkPromotion(new Coordinate(x, enemyLineY)))
|
||||
if (checkPromotion(new Coordinate(x, enemyLineY)))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user