Correction bug - Détection fin de jeu
This commit is contained in:
@@ -31,6 +31,11 @@
|
||||
android:name=".MainActivity"
|
||||
android:parentActivityName=".MenuActivity"/>
|
||||
|
||||
<!-- Fin de partie : retour arrière = MenuActivity -->
|
||||
<activity
|
||||
android:name=".FinPartieActivity"
|
||||
android:parentActivityName=".MenuActivity"/>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -2,6 +2,7 @@ package sae.chuzzle;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.RadioButton;
|
||||
@@ -9,6 +10,8 @@ import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Controleur {
|
||||
|
||||
private final Activity activite;
|
||||
@@ -23,6 +26,9 @@ public class Controleur {
|
||||
private final Spinner spinnerIndex;
|
||||
private final Button btnJouer;
|
||||
|
||||
// Hard Mode
|
||||
private final boolean hardMode;
|
||||
|
||||
// -
|
||||
// CONSTRUCTEUR
|
||||
|
||||
@@ -31,7 +37,8 @@ public class Controleur {
|
||||
long graine,
|
||||
TextView tvScore, TextView tvCoups,
|
||||
RadioButton rbLigne, RadioButton rbDroite,
|
||||
Spinner spinnerIndex, Button btnJouer) {
|
||||
Spinner spinnerIndex, Button btnJouer,
|
||||
boolean hardMode) {
|
||||
|
||||
this.activite = activite;
|
||||
this.etatJeu = etatJeu;
|
||||
@@ -43,6 +50,7 @@ public class Controleur {
|
||||
this.rbDroite = rbDroite;
|
||||
this.spinnerIndex = spinnerIndex;
|
||||
this.btnJouer = btnJouer;
|
||||
this.hardMode = hardMode;
|
||||
|
||||
initialiserSpinner();
|
||||
rafraichirAffichage();
|
||||
@@ -82,12 +90,10 @@ public class Controleur {
|
||||
|
||||
if (!accepte) {
|
||||
Toast.makeText(activite, "Coup invalide !", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
if(accepte){
|
||||
Toast.makeText(activite, "Coup valide !", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
rafraichirAffichage();
|
||||
verifierFinDePartie();
|
||||
}
|
||||
@@ -120,4 +126,8 @@ public class Controleur {
|
||||
btnJouer.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void sauvegarderEtat(Bundle out) {
|
||||
// Nettoyé de la logique d'objectifs
|
||||
}
|
||||
}
|
||||
@@ -527,6 +527,10 @@ public class EtatJeu {
|
||||
public boolean aUnCoupValide() {
|
||||
// Teste tous les décalages possibles (1 à N-1) pour les lignes
|
||||
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++) {
|
||||
if (coupCreeSerie(true, i, s)) {
|
||||
return true;
|
||||
@@ -536,6 +540,10 @@ public class EtatJeu {
|
||||
|
||||
// Teste tous les décalages possibles (1 à N-1) pour les colonnes
|
||||
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++) {
|
||||
if (coupCreeSerie(false, j, s)) {
|
||||
return true;
|
||||
@@ -585,4 +593,6 @@ public class EtatJeu {
|
||||
System.arraycopy(sauvegarde[l], 0, grille[l], 0, NB_COLONNES);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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:padding="16dp">
|
||||
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvScore"
|
||||
android:layout_width="match_parent"
|
||||
@@ -20,6 +22,15 @@
|
||||
android:text="Coups : 0"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<Button
|
||||
android:id="@+id/btnMenu"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Menu"/>
|
||||
|
||||
|
||||
|
||||
|
||||
<sae.chuzzle.VueGrille
|
||||
android:id="@+id/vueGrille"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -28,10 +28,15 @@
|
||||
android:text="Mode daltonien (symboles)"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switchDaltonien"
|
||||
<CheckBox
|
||||
android:id="@+id/checkDaltonien"
|
||||
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>
|
||||
|
||||
@@ -48,11 +53,26 @@
|
||||
android:text="Hard mode (verrous)"
|
||||
android:textSize="18sp"/>
|
||||
|
||||
<Switch
|
||||
android:id="@+id/switchHard"
|
||||
android:layout_width="50dp"
|
||||
android:layout_height="50dp"/>
|
||||
<CheckBox
|
||||
android:id="@+id/checkHard"
|
||||
android:layout_width="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>
|
||||
|
||||
<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_height="wrap_content"
|
||||
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>
|
||||
@@ -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