Fix bug : mauvais comptage des points (ajout de point dans la fonction verifyWin supprimé)

This commit is contained in:
Justine Yannis 2022-11-11 20:06:41 +01:00
parent d0a002d512
commit 6672ba61ff

View File

@ -81,9 +81,15 @@ public class GrilleModel extends AbstractGridInitiater{
for (int row = this.row - 1; row >= 0; row--) {
if (grille[column][row] == Constants.EMPTY_PLAYER) {
this.addPiece(column, row);
if(!this.verifyWin(column, row, this.playerTurn)){
this.switchPlayer();
if(this.verifyWin(column, row, this.playerTurn)){
if(this.playersList.size() > 2){
this.removePlayer();
} else{
this.setPartyStatus(GameStatus.WIN);
}
return;
}
this.switchPlayer();
this.verifyDraw();
return;
}
@ -101,14 +107,14 @@ public class GrilleModel extends AbstractGridInitiater{
private void verifyNewWin() {
int firstLastPlayer = this.playersList.get(0);
int seconfLastPlayer = this.playersList.get(1);
int secondLastPlayer = this.playersList.get(1);
boolean verifyFirstWin = this.verifyWinAll(firstLastPlayer);
boolean verifySecondWin = this.verifyWinAll(seconfLastPlayer);
boolean verifySecondWin = this.verifyWinAll(secondLastPlayer);
if(verifyFirstWin && verifySecondWin) {
this.setPartyStatus(GameStatus.DRAW);
}
else if(verifyFirstWin || verifySecondWin) {
this.playerTurn = verifyFirstWin ? firstLastPlayer : seconfLastPlayer;
this.playerTurn = verifyFirstWin ? firstLastPlayer : secondLastPlayer;
this.setPartyStatus(GameStatus.WIN);
}
}
@ -135,11 +141,7 @@ public class GrilleModel extends AbstractGridInitiater{
int diagonalRow = row;
//Vérification horizontal et vertical
if(verifyAlignedPiece(column, 0, 0, 1, playerColor) || verifyAlignedPiece(0, row, 1, 0, playerColor)) {
if(this.playersList.size()==3){
this.removePlayer();
}else{
this.setPartyStatus(GameStatus.WIN);
}
return true;
}
@ -149,11 +151,7 @@ public class GrilleModel extends AbstractGridInitiater{
}
//Vérification diagonale haut à gauche -> bas à droite
if(verifyAlignedPiece(diagonalColumn, diagonalRow, 1, 1, playerColor)) {
if(this.playersList.size() > 2){
this.removePlayer();
}else{
this.setPartyStatus(GameStatus.WIN);
}
return true;
}
@ -166,11 +164,7 @@ public class GrilleModel extends AbstractGridInitiater{
//Vérification diagonale haut à droite -> bas à gauche
if(verifyAlignedPiece(diagonalColumn, diagonalRow, -1, 1, playerColor)) {
if(this.playersList.size() > 2){
this.removePlayer();
}else{
this.setPartyStatus(GameStatus.WIN);
}
return true;
}
return false;