Suppresion commande mannuel de test au niveau de la logique par la classe controleur
This commit is contained in:
@@ -20,10 +20,6 @@ public class Controleur {
|
||||
|
||||
private final TextView tvScore;
|
||||
private final TextView tvCoups;
|
||||
private final RadioButton rbLigne;
|
||||
private final RadioButton rbDroite;
|
||||
private final Spinner spinnerIndex;
|
||||
private final Button btnJouer;
|
||||
|
||||
// Hard Mode logic
|
||||
private final boolean hardMode;
|
||||
@@ -33,22 +29,17 @@ public class Controleur {
|
||||
private TextView tvNbObjectifs;
|
||||
|
||||
public Controleur(Activity activite, EtatJeu etatJeu, VueGrille vueGrille,
|
||||
long graine,
|
||||
TextView tvScore, TextView tvCoups,
|
||||
RadioButton rbLigne, RadioButton rbDroite,
|
||||
Spinner spinnerIndex, Button btnJouer,
|
||||
long graine, TextView tvScore, TextView tvCoups,
|
||||
boolean hardMode) {
|
||||
|
||||
|
||||
|
||||
this.activite = activite;
|
||||
this.etatJeu = etatJeu;
|
||||
this.vueGrille = vueGrille;
|
||||
this.graine = graine;
|
||||
this.tvScore = tvScore;
|
||||
this.tvCoups = tvCoups;
|
||||
this.rbLigne = rbLigne;
|
||||
this.rbDroite = rbDroite;
|
||||
this.spinnerIndex = spinnerIndex;
|
||||
this.btnJouer = btnJouer;
|
||||
this.hardMode = hardMode;
|
||||
|
||||
if (hardMode) {
|
||||
@@ -60,20 +51,11 @@ public class Controleur {
|
||||
if (tvNbObjectifs != null) tvNbObjectifs.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
initialiserSpinner();
|
||||
|
||||
rafraichirAffichage();
|
||||
}
|
||||
|
||||
private void initialiserSpinner() {
|
||||
String[] indices = {"0", "1", "2", "3", "4", "5"};
|
||||
ArrayAdapter<String> adaptateur = new ArrayAdapter<>(
|
||||
activite,
|
||||
android.R.layout.simple_spinner_item,
|
||||
indices
|
||||
);
|
||||
adaptateur.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
spinnerIndex.setAdapter(adaptateur);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Initialise l'objectif au début de la partie ou lors de la restauration.
|
||||
@@ -119,20 +101,6 @@ public class Controleur {
|
||||
verifierFinDePartie();
|
||||
}
|
||||
|
||||
public void gererCoupJoueur() {
|
||||
boolean estLigne = rbLigne.isChecked();
|
||||
int index = spinnerIndex.getSelectedItemPosition();
|
||||
int sens = rbDroite.isChecked() ? 1 : -1;
|
||||
|
||||
boolean accepte = etatJeu.appliquerCoup(estLigne, index, sens);
|
||||
|
||||
if (!accepte) {
|
||||
Toast.makeText(activite, "Coup invalide !", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
gererFinDeCoup();
|
||||
}
|
||||
|
||||
public void verifierFinDePartie() {
|
||||
if (etatJeu.estTerminee()) {
|
||||
@@ -156,9 +124,7 @@ public class Controleur {
|
||||
if (tvNbObjectifs != null) tvNbObjectifs.setText("Objectifs réussis : " + gestionnaireObjectifs.getNbObjectifsRealises());
|
||||
}
|
||||
|
||||
if (etatJeu.estTerminee()) {
|
||||
btnJouer.setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void sauvegarderEtat(Bundle out) {
|
||||
|
||||
Reference in New Issue
Block a user