diff --git a/.gradle/7.5/executionHistory/executionHistory.bin b/.gradle/7.5/executionHistory/executionHistory.bin index 5bc1eb2..2ec6332 100644 Binary files a/.gradle/7.5/executionHistory/executionHistory.bin and b/.gradle/7.5/executionHistory/executionHistory.bin differ diff --git a/.gradle/7.5/executionHistory/executionHistory.lock b/.gradle/7.5/executionHistory/executionHistory.lock index 7d1aac2..e570b12 100644 Binary files a/.gradle/7.5/executionHistory/executionHistory.lock and b/.gradle/7.5/executionHistory/executionHistory.lock differ diff --git a/.gradle/7.5/fileHashes/fileHashes.bin b/.gradle/7.5/fileHashes/fileHashes.bin index 1d59f97..87427cf 100644 Binary files a/.gradle/7.5/fileHashes/fileHashes.bin and b/.gradle/7.5/fileHashes/fileHashes.bin differ diff --git a/.gradle/7.5/fileHashes/fileHashes.lock b/.gradle/7.5/fileHashes/fileHashes.lock index 15235eb..30330fc 100644 Binary files a/.gradle/7.5/fileHashes/fileHashes.lock and b/.gradle/7.5/fileHashes/fileHashes.lock differ diff --git a/.gradle/7.5/fileHashes/resourceHashesCache.bin b/.gradle/7.5/fileHashes/resourceHashesCache.bin index 3b3af3a..1426bd1 100644 Binary files a/.gradle/7.5/fileHashes/resourceHashesCache.bin and b/.gradle/7.5/fileHashes/resourceHashesCache.bin differ diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock index be4ad6f..3cb8c53 100644 Binary files a/.gradle/buildOutputCleanup/buildOutputCleanup.lock and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ diff --git a/app/src/main/java/com/example/mastermind/MasterMindActivity.java b/app/src/main/java/com/example/mastermind/MasterMindActivity.java index aee1e2d..3d5b051 100644 --- a/app/src/main/java/com/example/mastermind/MasterMindActivity.java +++ b/app/src/main/java/com/example/mastermind/MasterMindActivity.java @@ -76,43 +76,58 @@ public class MasterMindActivity extends AppCompatActivity { } public void nextTurn(){ - 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 + boolean nextable = true; + if (!vide){ LinearLayout anciennesPieces =(LinearLayout) this.jeu.getChildAt(this.tour); - - ArrayList combinaison = new ArrayList<>(); for(int i=0; i0){ - LinearLayout anciennesPieces =(LinearLayout) this.jeu.getChildAt(this.tour-1); - - for(int i=0; i combinaison = new ArrayList<>(); + for (int i = 0; i < anciennesPieces.getChildCount(); i++) { + anciennesPieces.getChildAt(i).setOnTouchListener(null); + combinaison.add(((UnePiece) anciennesPieces.getChildAt(i)).getColor()); + } + this.combinaisons.add(combinaison); + + 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); + //on ajoute le listener + for (int i = 0; i < pieces.getChildCount(); i++) { + UnePiece p = (UnePiece) pieces.getChildAt(i); + p.setOnTouchListener(new MonOnTouchListener(p, this.vide)); + } + } + + } 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); + + for (int i = 0; i < anciennesPieces.getChildCount(); i++) { + anciennesPieces.getChildAt(i).setOnTouchListener(null); + } + } + this.finDePartie(gagne); } - this.finDePartie(gagne); } }