Correction bug > Validation d'une proposition avec une pièce vide possible alors que non autorisée

This commit is contained in:
Mathis CHAIGNEAU 2023-04-08 18:22:26 +02:00
parent 2ef6863791
commit ece9929f4f
7 changed files with 47 additions and 32 deletions

View File

@ -76,6 +76,18 @@ public class MasterMindActivity extends AppCompatActivity {
} }
public void nextTurn(){ public void nextTurn(){
boolean nextable = true;
if (!vide){
LinearLayout anciennesPieces =(LinearLayout) this.jeu.getChildAt(this.tour);
for(int i=0; i<anciennesPieces.getChildCount(); i++){
if(((UnePiece)anciennesPieces.getChildAt(i)).getColor()==6){
nextable = false;
break;
}
}
}
if (nextable) {
if (this.tour < 9) { if (this.tour < 9) {
//on affiche la correction //on affiche la correction
boolean gagne = this.afficherCorrection((LinearLayout) this.jeu.getChildAt(this.tour)); boolean gagne = this.afficherCorrection((LinearLayout) this.jeu.getChildAt(this.tour));
@ -110,11 +122,14 @@ public class MasterMindActivity extends AppCompatActivity {
if (this.tour > 0) { if (this.tour > 0) {
LinearLayout anciennesPieces = (LinearLayout) this.jeu.getChildAt(this.tour - 1); LinearLayout anciennesPieces = (LinearLayout) this.jeu.getChildAt(this.tour - 1);
for(int i=0; i<anciennesPieces.getChildCount(); i++){anciennesPieces.getChildAt(i).setOnTouchListener(null);} for (int i = 0; i < anciennesPieces.getChildCount(); i++) {
anciennesPieces.getChildAt(i).setOnTouchListener(null);
}
} }
this.finDePartie(gagne); this.finDePartie(gagne);
} }
} }
}
public boolean afficherCorrection(LinearLayout pieces){ public boolean afficherCorrection(LinearLayout pieces){
int[] colorpiece=new int[4]; int[] colorpiece=new int[4];