Maj Controleur + Fin de partie
This commit is contained in:
@@ -4,10 +4,6 @@ import android.app.Activity;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ArrayAdapter;
|
|
||||||
import android.widget.Button;
|
|
||||||
import android.widget.RadioButton;
|
|
||||||
import android.widget.Spinner;
|
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -91,9 +87,6 @@ public class Controleur {
|
|||||||
Toast.makeText(activite, "Objectif réussi !", Toast.LENGTH_SHORT).show();
|
Toast.makeText(activite, "Objectif réussi !", Toast.LENGTH_SHORT).show();
|
||||||
gestionnaireObjectifs.incrementerReussites();
|
gestionnaireObjectifs.incrementerReussites();
|
||||||
objectifActuel = gestionnaireObjectifs.genererObjectif();
|
objectifActuel = gestionnaireObjectifs.genererObjectif();
|
||||||
} else if (objectifActuel.estEchoue()) {
|
|
||||||
Toast.makeText(activite, "Objectif échoué ! Fin de partie.", Toast.LENGTH_LONG).show();
|
|
||||||
etatJeu.forcerFinDePartie();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,6 +102,29 @@ public class Controleur {
|
|||||||
intent.putExtra("nbCoups", etatJeu.obtenirNbCoups());
|
intent.putExtra("nbCoups", etatJeu.obtenirNbCoups());
|
||||||
intent.putExtra("graine", graine);
|
intent.putExtra("graine", graine);
|
||||||
intent.putExtra("objectifsReussis", hardMode ? gestionnaireObjectifs.getNbObjectifsRealises() : 0);
|
intent.putExtra("objectifsReussis", hardMode ? gestionnaireObjectifs.getNbObjectifsRealises() : 0);
|
||||||
|
if (hardMode && objectifActuel != null)
|
||||||
|
intent.putExtra("objectifDescription", objectifActuel.getDescription());
|
||||||
|
|
||||||
|
// Passer la grille finale (flatten)
|
||||||
|
int[][] grille = etatJeu.obtenirGrille();
|
||||||
|
int nbLignes = grille.length;
|
||||||
|
int nbCols = grille[0].length;
|
||||||
|
int[] grillePlat = new int[nbLignes * nbCols];
|
||||||
|
for (int l = 0; l < nbLignes; l++)
|
||||||
|
for (int c = 0; c < nbCols; c++)
|
||||||
|
grillePlat[l * nbCols + c] = grille[l][c];
|
||||||
|
intent.putExtra("grille", grillePlat);
|
||||||
|
intent.putExtra("nbLignes", nbLignes);
|
||||||
|
intent.putExtra("nbCols", nbCols);
|
||||||
|
|
||||||
|
// Passer les verrous (flatten)
|
||||||
|
boolean[][] verrous = etatJeu.obtenirVerrous();
|
||||||
|
boolean[] verrouxPlat = new boolean[nbLignes * nbCols];
|
||||||
|
for (int l = 0; l < nbLignes; l++)
|
||||||
|
for (int c = 0; c < nbCols; c++)
|
||||||
|
verrouxPlat[l * nbCols + c] = verrous[l][c];
|
||||||
|
intent.putExtra("verrous", verrouxPlat);
|
||||||
|
|
||||||
activite.startActivity(intent);
|
activite.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class FinPartieActivity extends Activity {
|
|||||||
int nbCoups = getIntent().getIntExtra("nbCoups", 0);
|
int nbCoups = getIntent().getIntExtra("nbCoups", 0);
|
||||||
long graine = getIntent().getLongExtra("graine", 0L);
|
long graine = getIntent().getLongExtra("graine", 0L);
|
||||||
|
|
||||||
// Afficher les données
|
// Afficher les données textuelles
|
||||||
TextView tvScore = findViewById(R.id.tvFinScore);
|
TextView tvScore = findViewById(R.id.tvFinScore);
|
||||||
TextView tvCoups = findViewById(R.id.tvFinCoups);
|
TextView tvCoups = findViewById(R.id.tvFinCoups);
|
||||||
TextView tvGraine = findViewById(R.id.tvFinGraine);
|
TextView tvGraine = findViewById(R.id.tvFinGraine);
|
||||||
@@ -27,6 +27,40 @@ public class FinPartieActivity extends Activity {
|
|||||||
tvCoups.setText(String.valueOf(nbCoups));
|
tvCoups.setText(String.valueOf(nbCoups));
|
||||||
tvGraine.setText(String.valueOf(graine));
|
tvGraine.setText(String.valueOf(graine));
|
||||||
|
|
||||||
|
// Objectif en cours (hard mode)
|
||||||
|
String objectifDesc = getIntent().getStringExtra("objectifDescription");
|
||||||
|
TextView tvLabelObjectif = findViewById(R.id.tvLabelObjectif);
|
||||||
|
TextView tvFinObjectif = findViewById(R.id.tvFinObjectif);
|
||||||
|
if (objectifDesc != null) {
|
||||||
|
tvLabelObjectif.setVisibility(android.view.View.VISIBLE);
|
||||||
|
tvFinObjectif.setVisibility(android.view.View.VISIBLE);
|
||||||
|
tvFinObjectif.setText(objectifDesc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reconstruire et afficher la grille finale
|
||||||
|
int nbLignes = getIntent().getIntExtra("nbLignes", 6);
|
||||||
|
int nbCols = getIntent().getIntExtra("nbCols", 6);
|
||||||
|
int[] grillePlat = getIntent().getIntArrayExtra("grille");
|
||||||
|
boolean[] verrouxPlat = getIntent().getBooleanArrayExtra("verrous");
|
||||||
|
|
||||||
|
VueGrille vueGrilleFinale = findViewById(R.id.vueGrilleFinale);
|
||||||
|
|
||||||
|
if (grillePlat != null && grillePlat.length == nbLignes * nbCols) {
|
||||||
|
int[][] grille = new int[nbLignes][nbCols];
|
||||||
|
for (int l = 0; l < nbLignes; l++)
|
||||||
|
for (int c = 0; c < nbCols; c++)
|
||||||
|
grille[l][c] = grillePlat[l * nbCols + c];
|
||||||
|
vueGrilleFinale.definirGrille(grille);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verrouxPlat != null && verrouxPlat.length == nbLignes * nbCols) {
|
||||||
|
boolean[][] verrous = new boolean[nbLignes][nbCols];
|
||||||
|
for (int l = 0; l < nbLignes; l++)
|
||||||
|
for (int c = 0; c < nbCols; c++)
|
||||||
|
verrous[l][c] = verrouxPlat[l * nbCols + c];
|
||||||
|
vueGrilleFinale.definirVerrous(verrous);
|
||||||
|
}
|
||||||
|
|
||||||
// Bouton retour au menu
|
// Bouton retour au menu
|
||||||
Button btnMenu = findViewById(R.id.btnFinMenu);
|
Button btnMenu = findViewById(R.id.btnFinMenu);
|
||||||
btnMenu.setOnClickListener(v -> {
|
btnMenu.setOnClickListener(v -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user