Correction bug > Validation d'une proposition avec une pièce vide possible alors que non autorisée
This commit is contained in:
parent
2ef6863791
commit
ece9929f4f
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -76,45 +76,60 @@ public class MasterMindActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
public void nextTurn(){
|
||||
if(this.tour<9){
|
||||
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) {
|
||||
//on affiche la correction
|
||||
boolean gagne = this.afficherCorrection((LinearLayout) this.jeu.getChildAt(this.tour));
|
||||
//on supprime les listener et sauvegarde la combinaison
|
||||
LinearLayout anciennesPieces =(LinearLayout) this.jeu.getChildAt(this.tour);
|
||||
LinearLayout anciennesPieces = (LinearLayout) this.jeu.getChildAt(this.tour);
|
||||
|
||||
ArrayList<Integer> combinaison = new ArrayList<>();
|
||||
for(int i=0; i<anciennesPieces.getChildCount(); i++){
|
||||
for (int i = 0; i < anciennesPieces.getChildCount(); i++) {
|
||||
anciennesPieces.getChildAt(i).setOnTouchListener(null);
|
||||
combinaison.add(((UnePiece)anciennesPieces.getChildAt(i)).getColor());
|
||||
combinaison.add(((UnePiece) anciennesPieces.getChildAt(i)).getColor());
|
||||
}
|
||||
this.combinaisons.add(combinaison);
|
||||
|
||||
if (gagne){
|
||||
if (gagne) {
|
||||
this.finDePartie(true);
|
||||
} else {
|
||||
//on incremente le tour
|
||||
this.tour++;
|
||||
//on récupere le LinearLayout des pieces du tour
|
||||
LinearLayout pieces =(LinearLayout) this.jeu.getChildAt(this.tour);
|
||||
LinearLayout pieces = (LinearLayout) this.jeu.getChildAt(this.tour);
|
||||
//on ajoute le listener
|
||||
for(int i=0; i<pieces.getChildCount(); i++) {
|
||||
for (int i = 0; i < pieces.getChildCount(); i++) {
|
||||
UnePiece p = (UnePiece) pieces.getChildAt(i);
|
||||
p.setOnTouchListener(new MonOnTouchListener(p, this.vide));
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
//on affiche la correction
|
||||
boolean gagne = this.afficherCorrection((LinearLayout) this.jeu.getChildAt(this.tour));
|
||||
//on supprime les listener
|
||||
if(this.tour>0){
|
||||
LinearLayout anciennesPieces =(LinearLayout) this.jeu.getChildAt(this.tour-1);
|
||||
if (this.tour > 0) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean afficherCorrection(LinearLayout pieces){
|
||||
int[] colorpiece=new int[4];
|
||||
|
Loading…
Reference in New Issue
Block a user