GameModel: Added win condition when the opposite player has no pawn left

master
Gregory Martin 2018-03-14 15:16:01 +01:00
parent 4978de23b9
commit ea13653588
No known key found for this signature in database
GPG Key ID: 8791DD65FA92D9F0
1 changed files with 3 additions and 5 deletions

View File

@ -39,8 +39,6 @@ public class Board {
whiteHasWon = board.whiteHasWon;
blackHasWon = board.blackHasWon;
// initializeBoard();
}
public Board(@NotNull Board board, @NotNull Move move){
@ -166,7 +164,7 @@ public class Board {
tiles[move.start.x][move.start.y] = Tile.EMPTY;
tiles[move.end.x][move.end.y] = Tile.WHITE;
whiteHasWon = move.end.x == 0;
whiteHasWon = move.end.x == 0 || blacks.size() == 0;
break;
case BLACK:
blacks.remove(move.start);
@ -175,7 +173,7 @@ public class Board {
tiles[move.start.x][move.start.y] = Tile.EMPTY;
tiles[move.end.x][move.end.y] = Tile.BLACK;
blackHasWon = move.end.x == SIZEX-1;
blackHasWon = move.end.x == SIZEX-1 || whites.size() == 0;
break;
}
} else {
@ -231,7 +229,7 @@ public class Board {
}
public boolean isFinished(){
return whiteHasWon || blackHasWon;
return whiteHasWon || blackHasWon || blacks.size()==0 || whites.size()==0;
}
//********** Standard Methods **********//