Correction bug - Détection fin de jeu
This commit is contained in:
@@ -31,6 +31,11 @@
|
|||||||
android:name=".MainActivity"
|
android:name=".MainActivity"
|
||||||
android:parentActivityName=".MenuActivity"/>
|
android:parentActivityName=".MenuActivity"/>
|
||||||
|
|
||||||
|
<!-- Fin de partie : retour arrière = MenuActivity -->
|
||||||
|
<activity
|
||||||
|
android:name=".FinPartieActivity"
|
||||||
|
android:parentActivityName=".MenuActivity"/>
|
||||||
|
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
||||||
@@ -2,6 +2,7 @@ package sae.chuzzle;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.RadioButton;
|
import android.widget.RadioButton;
|
||||||
@@ -9,6 +10,8 @@ import android.widget.Spinner;
|
|||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Controleur {
|
public class Controleur {
|
||||||
|
|
||||||
private final Activity activite;
|
private final Activity activite;
|
||||||
@@ -23,6 +26,9 @@ public class Controleur {
|
|||||||
private final Spinner spinnerIndex;
|
private final Spinner spinnerIndex;
|
||||||
private final Button btnJouer;
|
private final Button btnJouer;
|
||||||
|
|
||||||
|
// Hard Mode
|
||||||
|
private final boolean hardMode;
|
||||||
|
|
||||||
// -
|
// -
|
||||||
// CONSTRUCTEUR
|
// CONSTRUCTEUR
|
||||||
|
|
||||||
@@ -31,7 +37,8 @@ public class Controleur {
|
|||||||
long graine,
|
long graine,
|
||||||
TextView tvScore, TextView tvCoups,
|
TextView tvScore, TextView tvCoups,
|
||||||
RadioButton rbLigne, RadioButton rbDroite,
|
RadioButton rbLigne, RadioButton rbDroite,
|
||||||
Spinner spinnerIndex, Button btnJouer) {
|
Spinner spinnerIndex, Button btnJouer,
|
||||||
|
boolean hardMode) {
|
||||||
|
|
||||||
this.activite = activite;
|
this.activite = activite;
|
||||||
this.etatJeu = etatJeu;
|
this.etatJeu = etatJeu;
|
||||||
@@ -43,6 +50,7 @@ public class Controleur {
|
|||||||
this.rbDroite = rbDroite;
|
this.rbDroite = rbDroite;
|
||||||
this.spinnerIndex = spinnerIndex;
|
this.spinnerIndex = spinnerIndex;
|
||||||
this.btnJouer = btnJouer;
|
this.btnJouer = btnJouer;
|
||||||
|
this.hardMode = hardMode;
|
||||||
|
|
||||||
initialiserSpinner();
|
initialiserSpinner();
|
||||||
rafraichirAffichage();
|
rafraichirAffichage();
|
||||||
@@ -82,12 +90,10 @@ public class Controleur {
|
|||||||
|
|
||||||
if (!accepte) {
|
if (!accepte) {
|
||||||
Toast.makeText(activite, "Coup invalide !", Toast.LENGTH_SHORT).show();
|
Toast.makeText(activite, "Coup invalide !", Toast.LENGTH_SHORT).show();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(accepte){
|
Toast.makeText(activite, "Coup valide !", Toast.LENGTH_SHORT).show();
|
||||||
Toast.makeText(activite, "Coup valide !", Toast.LENGTH_SHORT).show();
|
|
||||||
}
|
|
||||||
|
|
||||||
rafraichirAffichage();
|
rafraichirAffichage();
|
||||||
verifierFinDePartie();
|
verifierFinDePartie();
|
||||||
}
|
}
|
||||||
@@ -115,9 +121,13 @@ public class Controleur {
|
|||||||
tvCoups.setText("Coups : " + etatJeu.obtenirNbCoups());
|
tvCoups.setText("Coups : " + etatJeu.obtenirNbCoups());
|
||||||
vueGrille.definirGrille(etatJeu.obtenirGrille());
|
vueGrille.definirGrille(etatJeu.obtenirGrille());
|
||||||
vueGrille.definirVerrous(etatJeu.obtenirVerrous());
|
vueGrille.definirVerrous(etatJeu.obtenirVerrous());
|
||||||
|
|
||||||
if (etatJeu.estTerminee()) {
|
if (etatJeu.estTerminee()) {
|
||||||
btnJouer.setEnabled(false);
|
btnJouer.setEnabled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void sauvegarderEtat(Bundle out) {
|
||||||
|
// Nettoyé de la logique d'objectifs
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -527,6 +527,10 @@ public class EtatJeu {
|
|||||||
public boolean aUnCoupValide() {
|
public boolean aUnCoupValide() {
|
||||||
// Teste tous les décalages possibles (1 à N-1) pour les lignes
|
// Teste tous les décalages possibles (1 à N-1) pour les lignes
|
||||||
for (int i = 0; i < NB_LIGNES; i++) {
|
for (int i = 0; i < NB_LIGNES; i++) {
|
||||||
|
|
||||||
|
// AJOUT : Si la ligne est bloquée par un verrou, on ne peut pas la bouger
|
||||||
|
if (estBloque(true, i)) continue;
|
||||||
|
|
||||||
for (int s = 1; s < NB_COLONNES; s++) {
|
for (int s = 1; s < NB_COLONNES; s++) {
|
||||||
if (coupCreeSerie(true, i, s)) {
|
if (coupCreeSerie(true, i, s)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -536,6 +540,10 @@ public class EtatJeu {
|
|||||||
|
|
||||||
// Teste tous les décalages possibles (1 à N-1) pour les colonnes
|
// Teste tous les décalages possibles (1 à N-1) pour les colonnes
|
||||||
for (int j = 0; j < NB_COLONNES; j++) {
|
for (int j = 0; j < NB_COLONNES; j++) {
|
||||||
|
|
||||||
|
// AJOUT : Si la colonne est bloquée par un verrou, on ne peut pas la bouger
|
||||||
|
if (estBloque(false, j)) continue;
|
||||||
|
|
||||||
for (int s = 1; s < NB_LIGNES; s++) {
|
for (int s = 1; s < NB_LIGNES; s++) {
|
||||||
if (coupCreeSerie(false, j, s)) {
|
if (coupCreeSerie(false, j, s)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -585,4 +593,6 @@ public class EtatJeu {
|
|||||||
System.arraycopy(sauvegarde[l], 0, grille[l], 0, NB_COLONNES);
|
System.arraycopy(sauvegarde[l], 0, grille[l], 0, NB_COLONNES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ public class MenuActivity extends Activity implements View.OnClickListener {
|
|||||||
setContentView(R.layout.activity_menu);
|
setContentView(R.layout.activity_menu);
|
||||||
|
|
||||||
btnNouvellePartie = findViewById(R.id.btnNouvellePartie);
|
btnNouvellePartie = findViewById(R.id.btnNouvellePartie);
|
||||||
btnPartieGraine = findViewById(R.id.btnPartieGraine);
|
btnPartieGraine = findViewById(R.id.btnPartieGraine);
|
||||||
btnOptions = findViewById(R.id.btnOptions);
|
btnOptions = findViewById(R.id.btnOptions);
|
||||||
|
|
||||||
btnNouvellePartie.setOnClickListener(this);
|
btnNouvellePartie.setOnClickListener(this);
|
||||||
btnPartieGraine.setOnClickListener(this);
|
btnPartieGraine.setOnClickListener(this);
|
||||||
|
|||||||
@@ -0,0 +1,91 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:gravity="center"
|
||||||
|
android:padding="48dp"
|
||||||
|
android:background="#1A1A2E">
|
||||||
|
|
||||||
|
<!-- Titre -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Partie terminée !"
|
||||||
|
android:textSize="36sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="#E94560"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginBottom="48dp"/>
|
||||||
|
|
||||||
|
<!-- Score -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Score"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="#AAAACC"
|
||||||
|
android:gravity="center"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvFinScore"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="0"
|
||||||
|
android:textSize="52sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginBottom="32dp"/>
|
||||||
|
|
||||||
|
<!-- Nombre de coups -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Coups joués"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="#AAAACC"
|
||||||
|
android:gravity="center"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvFinCoups"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="0"
|
||||||
|
android:textSize="36sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginBottom="32dp"/>
|
||||||
|
|
||||||
|
<!-- Graine -->
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Graine de la partie"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="#AAAACC"
|
||||||
|
android:gravity="center"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvFinGraine"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="0"
|
||||||
|
android:textSize="20sp"
|
||||||
|
android:textColor="#E2C94E"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginBottom="48dp"/>
|
||||||
|
|
||||||
|
<!-- Bouton retour au menu -->
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnFinMenu"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Retour au menu"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:backgroundTint="#E94560"
|
||||||
|
android:textColor="#FFFFFF"
|
||||||
|
android:padding="16dp"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -5,6 +5,8 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:padding="16dp">
|
android:padding="16dp">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tvScore"
|
android:id="@+id/tvScore"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -20,6 +22,15 @@
|
|||||||
android:text="Coups : 0"
|
android:text="Coups : 0"
|
||||||
android:textSize="18sp"/>
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnMenu"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Menu"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sae.chuzzle.VueGrille
|
<sae.chuzzle.VueGrille
|
||||||
android:id="@+id/vueGrille"
|
android:id="@+id/vueGrille"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -28,10 +28,15 @@
|
|||||||
android:text="Mode daltonien (symboles)"
|
android:text="Mode daltonien (symboles)"
|
||||||
android:textSize="18sp"/>
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
<Switch
|
<CheckBox
|
||||||
android:id="@+id/switchDaltonien"
|
android:id="@+id/checkDaltonien"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"/>
|
android:layout_height="wrap_content"
|
||||||
|
android:scaleX="1.5"
|
||||||
|
android:scaleY="1.5"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:minWidth="48dp"
|
||||||
|
android:minHeight="48dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
@@ -48,11 +53,26 @@
|
|||||||
android:text="Hard mode (verrous)"
|
android:text="Hard mode (verrous)"
|
||||||
android:textSize="18sp"/>
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
<Switch
|
<CheckBox
|
||||||
android:id="@+id/switchHard"
|
android:id="@+id/checkHard"
|
||||||
android:layout_width="50dp"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="50dp"/>
|
android:layout_height="wrap_content"
|
||||||
|
android:scaleX="1.5"
|
||||||
|
android:scaleY="1.5"
|
||||||
|
android:layout_marginEnd="16dp"
|
||||||
|
android:minWidth="48dp"
|
||||||
|
android:minHeight="48dp"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
<Button
|
||||||
|
android:id="@+id/btnBack"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="Retour"
|
||||||
|
android:layout_marginTop="32dp">
|
||||||
|
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|||||||
@@ -27,5 +27,13 @@
|
|||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Jouer"/>
|
android:text="Jouer"/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnBack"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:text="Retour"
|
||||||
|
android:layout_marginTop="32dp"/>
|
||||||
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
</PreferenceScreen>
|
||||||
Reference in New Issue
Block a user