Ajout du menu + MAJ de l'arborescence
@@ -0,0 +1,26 @@
|
|||||||
|
package sae.chuzzle;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry;
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instrumented test, which will execute on an Android device.
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
@RunWith(AndroidJUnit4.class)
|
||||||
|
public class ExampleInstrumentedTest {
|
||||||
|
@Test
|
||||||
|
public void useAppContext() {
|
||||||
|
// Context of the app under test.
|
||||||
|
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||||
|
assertEquals("sae.chuzzle", appContext.getPackageName());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="sae.chuzzle">
|
||||||
|
|
||||||
|
<application
|
||||||
|
android:allowBackup="true"
|
||||||
|
android:label="Chuzzle"
|
||||||
|
android:theme="@android:style/Theme.Light.NoTitleBar">
|
||||||
|
|
||||||
|
<!-- Point d'entrée : le menu principal -->
|
||||||
|
<activity android:name=".MenuActivity"
|
||||||
|
android:exported="true">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
|
</intent-filter>
|
||||||
|
</activity>
|
||||||
|
|
||||||
|
<!-- Partie avec graine : retour arrière = MenuActivity -->
|
||||||
|
<activity
|
||||||
|
android:name=".SeedActivity"
|
||||||
|
android:parentActivityName=".MenuActivity"/>
|
||||||
|
|
||||||
|
<!-- Options : retour arrière = MenuActivity -->
|
||||||
|
<activity
|
||||||
|
android:name=".OptionsActivity"
|
||||||
|
android:parentActivityName=".MenuActivity"/>
|
||||||
|
|
||||||
|
<!-- Jeu : retour arrière = MenuActivity -->
|
||||||
|
<activity
|
||||||
|
android:name=".MainActivity"
|
||||||
|
android:parentActivityName=".MenuActivity"/>
|
||||||
|
|
||||||
|
</application>
|
||||||
|
|
||||||
|
</manifest>
|
||||||
@@ -0,0 +1,483 @@
|
|||||||
|
package sae.chuzzle;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class EtatJeu {
|
||||||
|
|
||||||
|
public static final int NB_LIGNES = 6;
|
||||||
|
public static final int NB_COLONNES = 6;
|
||||||
|
public static final int NB_TYPES = 7;
|
||||||
|
|
||||||
|
private final int[][] grille = new int[NB_LIGNES][NB_COLONNES];
|
||||||
|
private final boolean[][] verrous = new boolean[NB_LIGNES][NB_COLONNES];
|
||||||
|
private final Random aleatoire;
|
||||||
|
|
||||||
|
private int score = 0;
|
||||||
|
private int nbCoups = 0;
|
||||||
|
private boolean partieTerminee = false;
|
||||||
|
private boolean hardMode = false;
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// CONSTRUCTEURS
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
public EtatJeu() {
|
||||||
|
aleatoire = new Random();
|
||||||
|
initialiserGrilleSansTriples();
|
||||||
|
}
|
||||||
|
|
||||||
|
public EtatJeu(long graine, boolean hardMode) {
|
||||||
|
aleatoire = new Random(graine);
|
||||||
|
this.hardMode = hardMode;
|
||||||
|
initialiserGrilleSansTriples();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// GETTERS
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
public int obtenirScore() {
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int obtenirNbCoups() {
|
||||||
|
return nbCoups;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean estTerminee() {
|
||||||
|
return partieTerminee;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int obtenirCase(int ligne, int colonne) {
|
||||||
|
return grille[ligne][colonne];
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[][] obtenirGrille() {
|
||||||
|
int[][] copie = new int[NB_LIGNES][NB_COLONNES];
|
||||||
|
|
||||||
|
for (int l = 0; l < NB_LIGNES; l++) {
|
||||||
|
System.arraycopy(grille[l], 0, copie[l], 0, NB_COLONNES);
|
||||||
|
}
|
||||||
|
|
||||||
|
return copie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean[][] obtenirVerrous() {
|
||||||
|
boolean[][] copie = new boolean[NB_LIGNES][NB_COLONNES];
|
||||||
|
|
||||||
|
for (int l = 0; l < NB_LIGNES; l++) {
|
||||||
|
System.arraycopy(verrous[l], 0, copie[l], 0, NB_COLONNES);
|
||||||
|
}
|
||||||
|
|
||||||
|
return copie;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// INITIALISATION SANS TRIPLES
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
private void initialiserGrilleSansTriples() {
|
||||||
|
for (int ligne = 0; ligne < NB_LIGNES; ligne++) {
|
||||||
|
for (int colonne = 0; colonne < NB_COLONNES; colonne++) {
|
||||||
|
|
||||||
|
int valeur;
|
||||||
|
do {
|
||||||
|
valeur = aleatoire.nextInt(NB_TYPES);
|
||||||
|
} while (creeTriple(ligne, colonne, valeur));
|
||||||
|
|
||||||
|
grille[ligne][colonne] = valeur;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean creeTriple(int ligne, int colonne, int valeur) {
|
||||||
|
|
||||||
|
if (colonne >= 2) {
|
||||||
|
if (grille[ligne][colonne - 1] == valeur &&
|
||||||
|
grille[ligne][colonne - 2] == valeur) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ligne >= 2) {
|
||||||
|
if (grille[ligne - 1][colonne] == valeur &&
|
||||||
|
grille[ligne - 2][colonne] == valeur) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// DECALAGE CIRCULAIRE
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
public void decalerLigne(int ligne, int sens) {
|
||||||
|
int s = ((sens % NB_COLONNES) + NB_COLONNES) % NB_COLONNES;
|
||||||
|
|
||||||
|
for (int etape = 0; etape < s; etape++) {
|
||||||
|
int tmp = grille[ligne][NB_COLONNES - 1];
|
||||||
|
|
||||||
|
for (int c = NB_COLONNES - 1; c > 0; c--) {
|
||||||
|
grille[ligne][c] = grille[ligne][c - 1];
|
||||||
|
}
|
||||||
|
|
||||||
|
grille[ligne][0] = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void decalerColonne(int colonne, int sens) {
|
||||||
|
int s = ((sens % NB_LIGNES) + NB_LIGNES) % NB_LIGNES;
|
||||||
|
|
||||||
|
for (int etape = 0; etape < s; etape++) {
|
||||||
|
int tmp = grille[NB_LIGNES - 1][colonne];
|
||||||
|
|
||||||
|
for (int l = NB_LIGNES - 1; l > 0; l--) {
|
||||||
|
grille[l][colonne] = grille[l - 1][colonne];
|
||||||
|
}
|
||||||
|
|
||||||
|
grille[0][colonne] = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// APPLIQUER UN COUP
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
public boolean appliquerCoup(boolean estLigne, int index, int sens) {
|
||||||
|
if (partieTerminee) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hardMode && estBloque(estLigne, index)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int[][] sauvegarde = copierGrille();
|
||||||
|
|
||||||
|
if (estLigne) {
|
||||||
|
decalerLigne(index, sens);
|
||||||
|
} else {
|
||||||
|
decalerColonne(index, sens);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trouverSeries().isEmpty()) {
|
||||||
|
restaurerGrille(sauvegarde);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
nbCoups++;
|
||||||
|
score += resoudreEtRemplir();
|
||||||
|
|
||||||
|
if (hardMode) {
|
||||||
|
ajouterVerrou();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!aUnCoupValide()) {
|
||||||
|
partieTerminee = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// TROUVER LES SERIES
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
public List<int[]> trouverSeries() {
|
||||||
|
boolean[][] aSupprimer = new boolean[NB_LIGNES][NB_COLONNES];
|
||||||
|
|
||||||
|
for (int l = 0; l < NB_LIGNES; l++) {
|
||||||
|
int c = 0;
|
||||||
|
|
||||||
|
while (c < NB_COLONNES) {
|
||||||
|
int type = grille[l][c];
|
||||||
|
int fin = c + 1;
|
||||||
|
|
||||||
|
while (fin < NB_COLONNES && grille[l][fin] == type) {
|
||||||
|
fin++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fin - c >= 3) {
|
||||||
|
for (int k = c; k < fin; k++) {
|
||||||
|
aSupprimer[l][k] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
c = fin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int col = 0; col < NB_COLONNES; col++) {
|
||||||
|
int l = 0;
|
||||||
|
|
||||||
|
while (l < NB_LIGNES) {
|
||||||
|
int type = grille[l][col];
|
||||||
|
int fin = l + 1;
|
||||||
|
|
||||||
|
while (fin < NB_LIGNES && grille[fin][col] == type) {
|
||||||
|
fin++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fin - l >= 3) {
|
||||||
|
for (int k = l; k < fin; k++) {
|
||||||
|
aSupprimer[k][col] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
l = fin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<int[]> positions = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int l = 0; l < NB_LIGNES; l++) {
|
||||||
|
for (int col = 0; col < NB_COLONNES; col++) {
|
||||||
|
if (aSupprimer[l][col]) {
|
||||||
|
positions.add(new int[]{l, col});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return positions;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// RESOLUTION AVEC CASCADE
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
public int resoudreEtRemplir() {
|
||||||
|
int pointsTotal = 0;
|
||||||
|
int vague = 0;
|
||||||
|
|
||||||
|
List<int[]> series = trouverSeries();
|
||||||
|
|
||||||
|
while (!series.isEmpty()) {
|
||||||
|
|
||||||
|
int pointsBase = calculerPointsBase(series);
|
||||||
|
double multiplicateur = 1.0 + vague * 0.5;
|
||||||
|
pointsTotal += (int) (pointsBase * multiplicateur);
|
||||||
|
|
||||||
|
boolean[][] aSupprimer = new boolean[NB_LIGNES][NB_COLONNES];
|
||||||
|
|
||||||
|
for (int[] pos : series) {
|
||||||
|
aSupprimer[pos[0]][pos[1]] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Libérer les verrous des cases supprimées
|
||||||
|
libererVerrous(aSupprimer);
|
||||||
|
|
||||||
|
for (int col = 0; col < NB_COLONNES; col++) {
|
||||||
|
|
||||||
|
List<Integer> survivants = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int l = NB_LIGNES - 1; l >= 0; l--) {
|
||||||
|
if (!aSupprimer[l][col]) {
|
||||||
|
survivants.add(grille[l][col]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int li = NB_LIGNES - 1;
|
||||||
|
|
||||||
|
for (int val : survivants) {
|
||||||
|
grille[li][col] = val;
|
||||||
|
li--;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (li >= 0) {
|
||||||
|
grille[li][col] = aleatoire.nextInt(NB_TYPES);
|
||||||
|
li--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vague++;
|
||||||
|
series = trouverSeries();
|
||||||
|
}
|
||||||
|
|
||||||
|
return pointsTotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int calculerPointsBase(List<int[]> series) {
|
||||||
|
boolean[][] masque = new boolean[NB_LIGNES][NB_COLONNES];
|
||||||
|
|
||||||
|
for (int[] pos : series) {
|
||||||
|
masque[pos[0]][pos[1]] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int total = 0;
|
||||||
|
|
||||||
|
for (int l = 0; l < NB_LIGNES; l++) {
|
||||||
|
int c = 0;
|
||||||
|
|
||||||
|
while (c < NB_COLONNES) {
|
||||||
|
if (masque[l][c]) {
|
||||||
|
int fin = c + 1;
|
||||||
|
|
||||||
|
while (fin < NB_COLONNES && masque[l][fin]) {
|
||||||
|
fin++;
|
||||||
|
}
|
||||||
|
|
||||||
|
total += pointsPourLongueur(fin - c);
|
||||||
|
c = fin;
|
||||||
|
} else {
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int col = 0; col < NB_COLONNES; col++) {
|
||||||
|
int l = 0;
|
||||||
|
|
||||||
|
while (l < NB_LIGNES) {
|
||||||
|
if (masque[l][col]) {
|
||||||
|
int fin = l + 1;
|
||||||
|
|
||||||
|
while (fin < NB_LIGNES && masque[fin][col]) {
|
||||||
|
fin++;
|
||||||
|
}
|
||||||
|
|
||||||
|
total += pointsPourLongueur(fin - l);
|
||||||
|
l = fin;
|
||||||
|
} else {
|
||||||
|
l++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int pointsPourLongueur(int longueur) {
|
||||||
|
if (longueur == 3) {
|
||||||
|
return 8;
|
||||||
|
} else if (longueur == 4) {
|
||||||
|
return 16;
|
||||||
|
} else if (longueur == 5) {
|
||||||
|
return 32;
|
||||||
|
} else {
|
||||||
|
return 64;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// VERROUS (hard mode)
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
private boolean estBloque(boolean estLigne, int index) {
|
||||||
|
if (estLigne) {
|
||||||
|
for (int col = 0; col < NB_COLONNES; col++) {
|
||||||
|
if (verrous[index][col]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (int lig = 0; lig < NB_LIGNES; lig++) {
|
||||||
|
if (verrous[lig][index]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ajouterVerrou() {
|
||||||
|
int intervalle = Math.max(1, 5 - nbCoups / 10);
|
||||||
|
|
||||||
|
if (nbCoups % intervalle != 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<int[]> casesLibres = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int l = 0; l < NB_LIGNES; l++) {
|
||||||
|
for (int col = 0; col < NB_COLONNES; col++) {
|
||||||
|
if (!verrous[l][col]) {
|
||||||
|
casesLibres.add(new int[]{l, col});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (casesLibres.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int[] caseChoisie = casesLibres.get(aleatoire.nextInt(casesLibres.size()));
|
||||||
|
verrous[caseChoisie[0]][caseChoisie[1]] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void libererVerrous(boolean[][] aSupprimer) {
|
||||||
|
for (int l = 0; l < NB_LIGNES; l++) {
|
||||||
|
for (int col = 0; col < NB_COLONNES; col++) {
|
||||||
|
if (aSupprimer[l][col]) {
|
||||||
|
verrous[l][col] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// DETECTION FIN DE PARTIE
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
public boolean aUnCoupValide() {
|
||||||
|
for (int i = 0; i < NB_LIGNES; i++) {
|
||||||
|
if (coupCreeSerie(true, i, +1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (coupCreeSerie(true, i, -1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int j = 0; j < NB_COLONNES; j++) {
|
||||||
|
if (coupCreeSerie(false, j, +1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (coupCreeSerie(false, j, -1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean coupCreeSerie(boolean estLigne, int index, int sens) {
|
||||||
|
int[][] sauvegarde = copierGrille();
|
||||||
|
|
||||||
|
if (estLigne) {
|
||||||
|
decalerLigne(index, sens);
|
||||||
|
} else {
|
||||||
|
decalerColonne(index, sens);
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean resultat = !trouverSeries().isEmpty();
|
||||||
|
|
||||||
|
restaurerGrille(sauvegarde);
|
||||||
|
|
||||||
|
return resultat;
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// UTILITAIRES PRIVES
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
private int[][] copierGrille() {
|
||||||
|
int[][] copie = new int[NB_LIGNES][NB_COLONNES];
|
||||||
|
|
||||||
|
for (int l = 0; l < NB_LIGNES; l++) {
|
||||||
|
System.arraycopy(grille[l], 0, copie[l], 0, NB_COLONNES);
|
||||||
|
}
|
||||||
|
|
||||||
|
return copie;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void restaurerGrille(int[][] sauvegarde) {
|
||||||
|
for (int l = 0; l < NB_LIGNES; l++) {
|
||||||
|
System.arraycopy(sauvegarde[l], 0, grille[l], 0, NB_COLONNES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
package sae.chuzzle;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
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.Toast;
|
||||||
|
|
||||||
|
import sae.chuzzle.EtatJeu;
|
||||||
|
import sae.chuzzle.VueGrille;
|
||||||
|
|
||||||
|
public class MainActivity extends Activity implements View.OnClickListener {
|
||||||
|
|
||||||
|
private EtatJeu etatJeu;
|
||||||
|
private VueGrille vueGrille;
|
||||||
|
private TextView tvScore;
|
||||||
|
private TextView tvCoups;
|
||||||
|
private RadioButton rbLigne;
|
||||||
|
private RadioButton rbDroite;
|
||||||
|
private Spinner spinnerIndex;
|
||||||
|
private Button btnJouer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
// - Lire la graine et les options
|
||||||
|
long graine = getIntent().getLongExtra("graine", System.currentTimeMillis());
|
||||||
|
boolean daltonien = getSharedPreferences("chuzzle_prefs", MODE_PRIVATE)
|
||||||
|
.getBoolean("daltonien", false);
|
||||||
|
boolean hardMode = getSharedPreferences("chuzzle_prefs", MODE_PRIVATE)
|
||||||
|
.getBoolean("hard_mode", false);
|
||||||
|
|
||||||
|
// - Modèle
|
||||||
|
etatJeu = new EtatJeu(graine, hardMode);
|
||||||
|
|
||||||
|
// - Récupérer les vues depuis le XML
|
||||||
|
tvScore = findViewById(R.id.tvScore);
|
||||||
|
tvCoups = findViewById(R.id.tvCoups);
|
||||||
|
vueGrille = findViewById(R.id.vueGrille);
|
||||||
|
rbLigne = findViewById(R.id.rbLigne);
|
||||||
|
rbDroite = findViewById(R.id.rbDroite);
|
||||||
|
spinnerIndex = findViewById(R.id.spinnerIndex);
|
||||||
|
btnJouer = findViewById(R.id.btnJouer);
|
||||||
|
|
||||||
|
// - Configurer la vue
|
||||||
|
vueGrille.definirGrille(etatJeu.obtenirGrille());
|
||||||
|
vueGrille.definirVerrous(etatJeu.obtenirVerrous());
|
||||||
|
vueGrille.definirModeDaltonien(daltonien);
|
||||||
|
|
||||||
|
// - Configurer le spinner
|
||||||
|
String[] indices = {"0", "1", "2", "3", "4", "5"};
|
||||||
|
ArrayAdapter<String> adaptateur = new ArrayAdapter<>(
|
||||||
|
this,
|
||||||
|
android.R.layout.simple_spinner_item,
|
||||||
|
indices
|
||||||
|
);
|
||||||
|
adaptateur.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
|
spinnerIndex.setAdapter(adaptateur);
|
||||||
|
|
||||||
|
// --- Bouton jouer ---
|
||||||
|
btnJouer.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// GESTION DES CLICS
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (v == btnJouer) {
|
||||||
|
gererCoupJoueur();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// COORDINATION
|
||||||
|
|
||||||
|
|
||||||
|
private void gererCoupJoueur() {
|
||||||
|
boolean estLigne = rbLigne.isChecked();
|
||||||
|
int index = spinnerIndex.getSelectedItemPosition();
|
||||||
|
|
||||||
|
int sens;
|
||||||
|
if (rbDroite.isChecked()) {
|
||||||
|
sens = +1;
|
||||||
|
} else {
|
||||||
|
sens = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean accepte = etatJeu.appliquerCoup(estLigne, index, sens);
|
||||||
|
|
||||||
|
if (!accepte) {
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
"Coup invalide : aucune serie creee !",
|
||||||
|
Toast.LENGTH_SHORT
|
||||||
|
).show();
|
||||||
|
}
|
||||||
|
|
||||||
|
rafraichirAffichage();
|
||||||
|
|
||||||
|
if (etatJeu.estTerminee()) {
|
||||||
|
Toast.makeText(
|
||||||
|
this,
|
||||||
|
"Partie terminee ! Score final : " + etatJeu.obtenirScore(),
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show();
|
||||||
|
btnJouer.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void rafraichirAffichage() {
|
||||||
|
tvScore.setText("Score : " + etatJeu.obtenirScore());
|
||||||
|
tvCoups.setText("Coups : " + etatJeu.obtenirNbCoups());
|
||||||
|
vueGrille.definirGrille(etatJeu.obtenirGrille());
|
||||||
|
vueGrille.definirVerrous(etatJeu.obtenirVerrous());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package sae.chuzzle;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.Button;
|
||||||
|
|
||||||
|
public class MenuActivity extends Activity implements View.OnClickListener {
|
||||||
|
|
||||||
|
private Button btnNouvellePartie;
|
||||||
|
private Button btnPartieGraine;
|
||||||
|
private Button btnOptions;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
setContentView(R.layout.activity_menu);
|
||||||
|
|
||||||
|
btnNouvellePartie = findViewById(R.id.btnNouvellePartie);
|
||||||
|
btnPartieGraine = findViewById(R.id.btnPartieGraine);
|
||||||
|
btnOptions = findViewById(R.id.btnOptions);
|
||||||
|
|
||||||
|
btnNouvellePartie.setOnClickListener(this);
|
||||||
|
btnPartieGraine.setOnClickListener(this);
|
||||||
|
btnOptions.setOnClickListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
if (v == btnNouvellePartie) {
|
||||||
|
long graine = System.currentTimeMillis();
|
||||||
|
Intent intent = new Intent(this, MainActivity.class);
|
||||||
|
intent.putExtra("graine", graine);
|
||||||
|
startActivity(intent);
|
||||||
|
} else if (v == btnPartieGraine) {
|
||||||
|
Intent intent = new Intent(this, SeedActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
} else if (v == btnOptions) {
|
||||||
|
Intent intent = new Intent(this, OptionsActivity.class);
|
||||||
|
startActivity(intent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
package sae.chuzzle;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Paint;
|
||||||
|
import android.view.View;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
public class VueGrille extends View {
|
||||||
|
private boolean[][] verrous = new boolean[NB_LIGNES][NB_COLONNES];
|
||||||
|
|
||||||
|
private static final int NB_LIGNES = 6;
|
||||||
|
private static final int NB_COLONNES = 6;
|
||||||
|
private static final int NB_TYPES = 7;
|
||||||
|
|
||||||
|
// Symboles pour le mode daltonien, un par type
|
||||||
|
private static final String[] SYMBOLES = {"●", "■", "▲", "✚", "★", "♦", "✿"};
|
||||||
|
|
||||||
|
// La VueGrille ne reçoit qu'un tableau int[][] brut, pas un EtatJeu
|
||||||
|
private int[][] grille = new int[NB_LIGNES][NB_COLONNES];
|
||||||
|
private boolean modeDaltonien = false;
|
||||||
|
|
||||||
|
private final Paint pinceauCase = new Paint();
|
||||||
|
private final Paint pinceauSymbole = new Paint();
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// CONSTRUCTEUR
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
public VueGrille(Context contexte) {
|
||||||
|
super(contexte);
|
||||||
|
|
||||||
|
pinceauCase.setAntiAlias(true);
|
||||||
|
pinceauCase.setStyle(Paint.Style.FILL);
|
||||||
|
|
||||||
|
pinceauSymbole.setAntiAlias(true);
|
||||||
|
pinceauSymbole.setColor(0xFF000000);
|
||||||
|
pinceauSymbole.setTextAlign(Paint.Align.CENTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// API PUBLIQUE (appelée par MainActivity uniquement)
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reçoit une copie de la grille depuis MainActivity.
|
||||||
|
* VueGrille ne sait pas d'où viennent ces données,
|
||||||
|
* elle sait juste les dessiner.
|
||||||
|
*/
|
||||||
|
public void definirGrille(int[][] nouvelleGrille) {
|
||||||
|
for (int l = 0; l < NB_LIGNES; l++) {
|
||||||
|
System.arraycopy(nouvelleGrille[l], 0, grille[l], 0, NB_COLONNES);
|
||||||
|
}
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void definirModeDaltonien(boolean actif) {
|
||||||
|
this.modeDaltonien = actif;
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// DESSIN
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDraw(@NonNull Canvas canvas) {
|
||||||
|
super.onDraw(canvas);
|
||||||
|
|
||||||
|
int largeur = getWidth();
|
||||||
|
int hauteur = getHeight();
|
||||||
|
|
||||||
|
float tailleCase = Math.min(
|
||||||
|
largeur / (float) NB_COLONNES,
|
||||||
|
hauteur / (float) NB_LIGNES
|
||||||
|
);
|
||||||
|
|
||||||
|
float margeGauche = (largeur - tailleCase * NB_COLONNES) / 2f;
|
||||||
|
float margeHaut = (hauteur - tailleCase * NB_LIGNES) / 2f;
|
||||||
|
|
||||||
|
pinceauSymbole.setTextSize(tailleCase * 0.4f);
|
||||||
|
|
||||||
|
for (int ligne = 0; ligne < NB_LIGNES; ligne++) {
|
||||||
|
for (int colonne = 0; colonne < NB_COLONNES; colonne++) {
|
||||||
|
|
||||||
|
int type = grille[ligne][colonne];
|
||||||
|
|
||||||
|
float x1 = margeGauche + colonne * tailleCase + 6;
|
||||||
|
float y1 = margeHaut + ligne * tailleCase + 6;
|
||||||
|
float x2 = margeGauche + (colonne + 1) * tailleCase - 6;
|
||||||
|
float y2 = margeHaut + (ligne + 1) * tailleCase - 6;
|
||||||
|
|
||||||
|
// Dessiner la case colorée
|
||||||
|
// Dessiner la case colorée
|
||||||
|
definirCouleur(type);
|
||||||
|
canvas.drawRoundRect(x1, y1, x2, y2, 20, 20, pinceauCase);
|
||||||
|
|
||||||
|
// Assombrir la case si elle est verrouillée
|
||||||
|
if (verrous[ligne][colonne]) {
|
||||||
|
pinceauCase.setARGB(120, 0, 0, 0);
|
||||||
|
canvas.drawRoundRect(x1, y1, x2, y2, 20, 20, pinceauCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dessiner le symbole daltonien
|
||||||
|
if (modeDaltonien) {
|
||||||
|
float cx = (x1 + x2) / 2f;
|
||||||
|
float cy = (y1 + y2) / 2f
|
||||||
|
- (pinceauSymbole.descent() + pinceauSymbole.ascent()) / 2f;
|
||||||
|
canvas.drawText(SYMBOLES[type % NB_TYPES], cx, cy, pinceauSymbole);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dessiner le cadenas par-dessus si verrouillée
|
||||||
|
if (verrous[ligne][colonne]) {
|
||||||
|
float cx = (x1 + x2) / 2f;
|
||||||
|
float cy = (y1 + y2) / 2f
|
||||||
|
- (pinceauSymbole.descent() + pinceauSymbole.ascent()) / 2f;
|
||||||
|
canvas.drawText("🔒", cx, cy, pinceauSymbole);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// =========================================================
|
||||||
|
// UTILITAIRE PRIVE
|
||||||
|
// =========================================================
|
||||||
|
|
||||||
|
private void definirCouleur(int type) {
|
||||||
|
switch (type % NB_TYPES) {
|
||||||
|
case 0: pinceauCase.setARGB(255, 200, 200, 200); break;
|
||||||
|
case 1: pinceauCase.setARGB(255, 255, 105, 180); break;
|
||||||
|
case 2: pinceauCase.setARGB(255, 90, 230, 200); break;
|
||||||
|
case 3: pinceauCase.setARGB(255, 100, 170, 255); break;
|
||||||
|
case 4: pinceauCase.setARGB(255, 255, 220, 90); break;
|
||||||
|
case 5: pinceauCase.setARGB(255, 255, 140, 90); break;
|
||||||
|
case 6: pinceauCase.setARGB(255, 255, 90, 90); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void definirVerrous(boolean[][] nouveauxVerrous) {
|
||||||
|
for (int l = 0; l < NB_LIGNES; l++) {
|
||||||
|
System.arraycopy(nouveauxVerrous[l], 0, verrous[l], 0, NB_COLONNES);
|
||||||
|
}
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:aapt="http://schemas.android.com/aapt"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||||
|
<aapt:attr name="android:fillColor">
|
||||||
|
<gradient
|
||||||
|
android:endX="85.84757"
|
||||||
|
android:endY="92.4963"
|
||||||
|
android:startX="42.9492"
|
||||||
|
android:startY="49.59793"
|
||||||
|
android:type="linear">
|
||||||
|
<item
|
||||||
|
android:color="#44000000"
|
||||||
|
android:offset="0.0" />
|
||||||
|
<item
|
||||||
|
android:color="#00000000"
|
||||||
|
android:offset="1.0" />
|
||||||
|
</gradient>
|
||||||
|
</aapt:attr>
|
||||||
|
</path>
|
||||||
|
<path
|
||||||
|
android:fillColor="#FFFFFF"
|
||||||
|
android:fillType="nonZero"
|
||||||
|
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||||
|
android:strokeWidth="1"
|
||||||
|
android:strokeColor="#00000000" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,170 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="108dp"
|
||||||
|
android:height="108dp"
|
||||||
|
android:viewportWidth="108"
|
||||||
|
android:viewportHeight="108">
|
||||||
|
<path
|
||||||
|
android:fillColor="#3DDC84"
|
||||||
|
android:pathData="M0,0h108v108h-108z" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M9,0L9,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,0L19,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,0L29,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,0L39,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,0L49,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,0L59,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,0L69,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,0L79,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M89,0L89,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M99,0L99,108"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,9L108,9"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,19L108,19"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,29L108,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,39L108,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,49L108,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,59L108,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,69L108,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,79L108,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,89L108,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M0,99L108,99"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,29L89,29"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,39L89,39"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,49L89,49"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,59L89,59"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,69L89,69"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M19,79L89,79"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M29,19L29,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M39,19L39,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M49,19L49,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M59,19L59,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M69,19L69,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
<path
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:pathData="M79,19L79,89"
|
||||||
|
android:strokeWidth="0.8"
|
||||||
|
android:strokeColor="#33FFFFFF" />
|
||||||
|
</vector>
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
<?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:padding="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvScore"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Score : 0"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tvCoups"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Coups : 0"
|
||||||
|
android:textSize="18sp"/>
|
||||||
|
|
||||||
|
<sae.chuzzle.VueGrille
|
||||||
|
android:id="@+id/vueGrille"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"/>
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/rgChoix"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbLigne"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Ligne"
|
||||||
|
android:checked="true"/>
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbColonne"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Colonne"/>
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<Spinner
|
||||||
|
android:id="@+id/spinnerIndex"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"/>
|
||||||
|
|
||||||
|
<RadioGroup
|
||||||
|
android:id="@+id/rgSens"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbDroite"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Droite / Bas (+1)"
|
||||||
|
android:checked="true"/>
|
||||||
|
|
||||||
|
<RadioButton
|
||||||
|
android:id="@+id/rbGauche"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:text="Gauche / Haut (-1)"/>
|
||||||
|
|
||||||
|
</RadioGroup>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnJouer"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Jouer"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
<?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">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Chuzzle"
|
||||||
|
android:textSize="48sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:gravity="center"
|
||||||
|
android:layout_marginBottom="64dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnNouvellePartie"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Nouvelle Partie"
|
||||||
|
android:layout_marginBottom="16dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnPartieGraine"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Partie avec Graine"
|
||||||
|
android:layout_marginBottom="16dp"/>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/btnOptions"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Options"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<background android:drawable="@drawable/ic_launcher_background" />
|
||||||
|
<foreground android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
<monochrome android:drawable="@drawable/ic_launcher_foreground" />
|
||||||
|
</adaptive-icon>
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 982 B |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 2.8 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 7.6 KiB |
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="Theme.Chuzzle" parent="@android:style/Theme.Light.NoTitleBar" />
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<color name="black">#FF000000</color>
|
||||||
|
<color name="white">#FFFFFFFF</color>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
<resources>
|
||||||
|
<string name="app_name">Chuzzle</string>
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<resources>
|
||||||
|
<style name="Theme.Chuzzle" parent="@android:style/Theme.Light.NoTitleBar" />
|
||||||
|
</resources>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample backup rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/guide/topics/data/autobackup
|
||||||
|
for details.
|
||||||
|
Note: This file is ignored for devices older than API 31
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore
|
||||||
|
-->
|
||||||
|
<full-backup-content>
|
||||||
|
<!--
|
||||||
|
<include domain="sharedpref" path="."/>
|
||||||
|
<exclude domain="sharedpref" path="device.xml"/>
|
||||||
|
-->
|
||||||
|
</full-backup-content>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?><!--
|
||||||
|
Sample data extraction rules file; uncomment and customize as necessary.
|
||||||
|
See https://developer.android.com/about/versions/12/backup-restore#xml-changes
|
||||||
|
for details.
|
||||||
|
-->
|
||||||
|
<data-extraction-rules>
|
||||||
|
<cloud-backup>
|
||||||
|
<!-- TODO: Use <include> and <exclude> to control what is backed up.
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
-->
|
||||||
|
</cloud-backup>
|
||||||
|
<!--
|
||||||
|
<device-transfer>
|
||||||
|
<include .../>
|
||||||
|
<exclude .../>
|
||||||
|
</device-transfer>
|
||||||
|
-->
|
||||||
|
</data-extraction-rules>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package sae.chuzzle;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example local unit test, which will execute on the development machine (host).
|
||||||
|
*
|
||||||
|
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||||
|
*/
|
||||||
|
public class ExampleUnitTest {
|
||||||
|
@Test
|
||||||
|
public void addition_isCorrect() {
|
||||||
|
assertEquals(4, 2 + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||