|
|
|
@ -10,21 +10,58 @@ var darktercia = "#606060";
|
|
|
|
|
var carteselect = [];
|
|
|
|
|
var deckPartie = []; //Ensemble des cartes affichees a l'ecran
|
|
|
|
|
var TasDuJEU = []; // Ensemble de toutes les cartes presente dans le jeu
|
|
|
|
|
var allMode = ["Solo", "Infini"]; // Défini tout les modes de Jeu
|
|
|
|
|
var allDimension = ["4 * 3", "3 * 3", "3 * 2"];
|
|
|
|
|
var selectionMode = 0;
|
|
|
|
|
var selectionDiemension = 0;
|
|
|
|
|
|
|
|
|
|
var lesPoints = 0; //Points du Joueur1
|
|
|
|
|
|
|
|
|
|
function modePrec() {
|
|
|
|
|
if (selectionMode == 0) {
|
|
|
|
|
selectionMode = allMode.length - 1;
|
|
|
|
|
} else {
|
|
|
|
|
selectionMode -= 1;
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("textmode").textContent = "" + allMode[selectionMode]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function modeSuiv() {
|
|
|
|
|
if (selectionMode == allMode.length - 1) {
|
|
|
|
|
selectionMode = 0;
|
|
|
|
|
} else {
|
|
|
|
|
selectionMode += 1;
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("textmode").textContent = "" + allMode[selectionMode]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function dimensionPrec() {
|
|
|
|
|
if (selectionDiemension == 0) {
|
|
|
|
|
selectionDiemension = allDimension.length - 1;
|
|
|
|
|
} else {
|
|
|
|
|
selectionDiemension -= 1;
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("textdimension").textContent = "" + allDimension[selectionDiemension]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function dimensionSuiv() {
|
|
|
|
|
if (selectionDiemension == allDimension.length - 1) {
|
|
|
|
|
selectionDiemension = 0;
|
|
|
|
|
} else {
|
|
|
|
|
selectionDiemension += 1;
|
|
|
|
|
}
|
|
|
|
|
document.getElementById("textdimension").textContent = "" + allDimension[selectionDiemension]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Carte {
|
|
|
|
|
|
|
|
|
|
constructor(id, allFigure/*,row,column,nbForme*/) { //a decommenter quand il y aura des prametres de partie
|
|
|
|
|
constructor(id, allFigure, nbRow, nbColumn/*,nbForme*/) { //a decommenter quand il y aura des prametres de partie
|
|
|
|
|
//Attribut de Classe
|
|
|
|
|
this.identifiant = id;
|
|
|
|
|
this.row = 4 /*row*/;
|
|
|
|
|
this.column = 3 /*column*/;
|
|
|
|
|
this.Matrice = creaMatrice(this.row, this.column);
|
|
|
|
|
this.row = nbRow;
|
|
|
|
|
this.column = nbColumn;
|
|
|
|
|
this.Matrice = creaMatrice(nbRow, nbColumn);
|
|
|
|
|
this.SesFigures = [];
|
|
|
|
|
for (var i = 0; i < allFigure.length; i++) {
|
|
|
|
|
this.SesFigures.push(allFigure[i]);
|
|
|
|
@ -174,7 +211,7 @@ class Figure {
|
|
|
|
|
var divContainForm = document.createElement('div');
|
|
|
|
|
divContainForm.className = "containform";
|
|
|
|
|
divContainForm.classList.add("ajustementGrandeForme");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var unCercle = document.createElement('div');
|
|
|
|
|
unCercle.className = "anneau";
|
|
|
|
|
unCercle.style.backgroundColor = "var(--colorbase)";
|
|
|
|
@ -260,6 +297,7 @@ const TypeFigure = {
|
|
|
|
|
|
|
|
|
|
function journuit() {
|
|
|
|
|
//mode jour
|
|
|
|
|
mode = mode + 1;
|
|
|
|
|
if (mode % 2 == 0) {
|
|
|
|
|
//changer logo swish
|
|
|
|
|
document.getElementById("imglogo").src = "imgs/swishjour.png";
|
|
|
|
@ -291,17 +329,38 @@ function journuit() {
|
|
|
|
|
document.documentElement.style.setProperty('--lightsedonca', darkseconda);
|
|
|
|
|
document.documentElement.style.setProperty('--lighttercia', darktercia);
|
|
|
|
|
}
|
|
|
|
|
mode = mode + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//===================================================================================
|
|
|
|
|
//FONCTION GESTION DE GAME
|
|
|
|
|
|
|
|
|
|
function lancerpartie() {
|
|
|
|
|
document.getElementById("pageAccueil").style.visibility = "hidden";
|
|
|
|
|
var ready = true;
|
|
|
|
|
//fonction de creation de partie a changer en fonction du test voulu
|
|
|
|
|
creePartieClassique();
|
|
|
|
|
document.getElementById("pageGame").style.visibility = "visible";
|
|
|
|
|
if (selectionMode == 0) {
|
|
|
|
|
if (selectionDiemension == 0) {
|
|
|
|
|
creePartieClassique3_4();
|
|
|
|
|
} else if (selectionDiemension == 1) {
|
|
|
|
|
ready = false;
|
|
|
|
|
window.alert("Mode de Jeu indisponible pour le moment")
|
|
|
|
|
} else if (selectionDiemension == 2) {
|
|
|
|
|
ready = false;
|
|
|
|
|
window.alert("Mode de Jeu indisponible pour le moment")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (selectionMode == 1) {
|
|
|
|
|
if (selectionDiemension == 0) {
|
|
|
|
|
creePartieInfini(4, 3);
|
|
|
|
|
} else if (selectionDiemension == 1) {
|
|
|
|
|
creePartieInfini(3, 3);
|
|
|
|
|
} else if (selectionDiemension == 2) {
|
|
|
|
|
creePartieInfini(3, 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ready) {
|
|
|
|
|
document.getElementById("pageAccueil").style.visibility = "hidden";
|
|
|
|
|
document.getElementById("pageGame").style.visibility = "visible";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function retour() {
|
|
|
|
@ -319,6 +378,18 @@ function rechargerGAME() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function redistribuerPlateau() {
|
|
|
|
|
if (selectionMode == 0) {
|
|
|
|
|
redistribuer();
|
|
|
|
|
} else if (selectionMode == 1) {
|
|
|
|
|
for (var i = 0; i < 16; i++) {
|
|
|
|
|
remplacerLaCarte(deckPartie[i])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
afficherCartes(deckPartie);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function redistribuer() {
|
|
|
|
|
deckPartie = [];
|
|
|
|
|
for (var i = 0; i < 16; i++) {
|
|
|
|
@ -360,13 +431,13 @@ function genererTouteslesCartes3_4Possibles() {
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 0, j));
|
|
|
|
|
if (i != 3 * j) {
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
|
|
|
|
|
var uneCarte = new Carte(deckPartie.length + 1, AllFigure);
|
|
|
|
|
var uneCarte = new Carte(deckPartie.length + 1, AllFigure, 4, 3);
|
|
|
|
|
deckPartie.push(uneCarte);
|
|
|
|
|
if (!doublonInterdit(uneCarte)) {
|
|
|
|
|
AllFigure = [];
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 0, j));
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
|
|
|
|
|
var unDoublon = new Carte(deckPartie.length + 1, AllFigure);
|
|
|
|
|
var unDoublon = new Carte(deckPartie.length + 1, AllFigure, 4, 3);
|
|
|
|
|
deckPartie.push(unDoublon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -379,13 +450,13 @@ function genererTouteslesCartes3_4Possibles() {
|
|
|
|
|
if (i != 3 * j + 1) {
|
|
|
|
|
if (i != 2 && i != 5 && i != 8 && i != 11) {
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
|
|
|
|
|
var uneCarte = new Carte(deckPartie.length + 1, AllFigure);
|
|
|
|
|
var uneCarte = new Carte(deckPartie.length + 1, AllFigure, 4, 3);
|
|
|
|
|
deckPartie.push(uneCarte);
|
|
|
|
|
if (!doublonInterdit(uneCarte)) {
|
|
|
|
|
AllFigure = [];
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 1, j));
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
|
|
|
|
|
var unDoublon = new Carte(deckPartie.length + 1, AllFigure);
|
|
|
|
|
var unDoublon = new Carte(deckPartie.length + 1, AllFigure, 4, 3);
|
|
|
|
|
deckPartie.push(unDoublon);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -404,7 +475,7 @@ function afficherCartes(Liste) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creePartieClassique() {
|
|
|
|
|
function creePartieClassique3_4() {
|
|
|
|
|
TasDuJEU = genererTouteslesCartes3_4Possibles();
|
|
|
|
|
deckPartie = [];
|
|
|
|
|
for (var i = 0; i < TasDuJEU.length; i++) {
|
|
|
|
@ -443,7 +514,7 @@ function creePartieClassique() {
|
|
|
|
|
afficherCartes(deckPartie);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creePartieInfini() {
|
|
|
|
|
function creePartieInfini(nbRow, nbColum) {
|
|
|
|
|
deckPartie = [];
|
|
|
|
|
carteselect = [];
|
|
|
|
|
while (document.getElementById("containcards").firstElementChild != null) {
|
|
|
|
@ -454,20 +525,20 @@ function creePartieInfini() {
|
|
|
|
|
var AllFigure = [];
|
|
|
|
|
var Cox1, Coy1, Cox2, Coy2;
|
|
|
|
|
|
|
|
|
|
Cox1 = getRandom(0, 2);
|
|
|
|
|
Coy1 = getRandom(0, 3);
|
|
|
|
|
Cox1 = getRandom(0, nbColum - 1);
|
|
|
|
|
Coy1 = getRandom(0, nbRow - 1);
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, Cox1, Coy1));
|
|
|
|
|
|
|
|
|
|
Cox2 = getRandom(0, 2);
|
|
|
|
|
Coy2 = getRandom(0, 3);
|
|
|
|
|
Cox2 = getRandom(0, nbColum - 1);
|
|
|
|
|
Coy2 = getRandom(0, nbRow - 1);
|
|
|
|
|
|
|
|
|
|
while (Cox2 == Cox1 && Coy1 == Coy2) {
|
|
|
|
|
Cox2 = getRandom(0, 2);
|
|
|
|
|
Coy2 = getRandom(0, 3);
|
|
|
|
|
Cox2 = getRandom(0, nbColum - 1);
|
|
|
|
|
Coy2 = getRandom(0, nbRow - 1);
|
|
|
|
|
}
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, Cox2, Coy2));
|
|
|
|
|
//Code de Generation de Figure
|
|
|
|
|
var uneCarte = new Carte(j, AllFigure);
|
|
|
|
|
var uneCarte = new Carte(j, AllFigure, nbRow, nbColum);
|
|
|
|
|
|
|
|
|
|
deckPartie.push(uneCarte);
|
|
|
|
|
|
|
|
|
@ -525,20 +596,20 @@ function remplacerLaCarte(uneCarte) {
|
|
|
|
|
var AllFigure = [];
|
|
|
|
|
var Cox1, Coy1, Cox2, Coy2;
|
|
|
|
|
|
|
|
|
|
Cox1 = getRandom(0, 2);
|
|
|
|
|
Coy1 = getRandom(0, 3);
|
|
|
|
|
Cox1 = getRandom(0, uneCarte.column - 1);
|
|
|
|
|
Coy1 = getRandom(0, uneCarte.row - 1);
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, Cox1, Coy1));
|
|
|
|
|
|
|
|
|
|
Cox2 = getRandom(0, 2);
|
|
|
|
|
Coy2 = getRandom(0, 3);
|
|
|
|
|
Cox2 = getRandom(0, uneCarte.column - 1);
|
|
|
|
|
Coy2 = getRandom(0, uneCarte.row - 1);
|
|
|
|
|
|
|
|
|
|
while (Cox2 == Cox1 && Coy1 == Coy2) {
|
|
|
|
|
Cox2 = getRandom(0, 2);
|
|
|
|
|
Coy2 = getRandom(0, 3);
|
|
|
|
|
Cox2 = getRandom(0, uneCarte.column - 1);
|
|
|
|
|
Coy2 = getRandom(0, uneCarte.row - 1);
|
|
|
|
|
}
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, Cox2, Coy2));
|
|
|
|
|
//Code de Generation de Figure
|
|
|
|
|
var newCarte = new Carte(pos + 1, AllFigure);
|
|
|
|
|
var newCarte = new Carte(pos + 1, AllFigure, uneCarte.row, uneCarte.column);
|
|
|
|
|
deckPartie[pos] = newCarte;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -584,6 +655,7 @@ function creaMatriceVierge(row, column) {
|
|
|
|
|
function creaMatrice(row, column) {
|
|
|
|
|
|
|
|
|
|
var myMatrice = creaMatriceVierge(row, column);
|
|
|
|
|
//window.alert(myMatrice)
|
|
|
|
|
|
|
|
|
|
var Cox1, Coy1, Cox2, Coy2;
|
|
|
|
|
|
|
|
|
@ -613,16 +685,16 @@ function chercherCombinaison() {
|
|
|
|
|
var Cptsolution = 0;
|
|
|
|
|
/*
|
|
|
|
|
Pour toutes les longueurs possible d’un tas de carte (N = 0, N<4 ; N++)
|
|
|
|
|
Pour toutes les échantillon de cartes ( i = 0 ; i<16 – N ; i ++)
|
|
|
|
|
Pour toutes les autres cartes (j=0 ;j<15-i-N ;j++)
|
|
|
|
|
DeckTest = vide ;
|
|
|
|
|
DeckTest.push(DeckPartie[i])
|
|
|
|
|
Pour N + 2 cartes (k=1 ;k<2+N ;k++)
|
|
|
|
|
DeckTest.push(DeckPartie[i+k+j])
|
|
|
|
|
Tab = AssemblageArbre(copie(Decktest) , Decktest[0])
|
|
|
|
|
Pour toutes les valeurs de tab
|
|
|
|
|
Si tab[m] == N+2
|
|
|
|
|
//Woula j’ai trouvé*/
|
|
|
|
|
Pour toutes les échantillon de cartes ( i = 0 ; i<16 – N ; i ++)
|
|
|
|
|
Pour toutes les autres cartes (j=0 ;j<15-i-N ;j++)
|
|
|
|
|
DeckTest = vide ;
|
|
|
|
|
DeckTest.push(DeckPartie[i])
|
|
|
|
|
Pour N + 2 cartes (k=1 ;k<2+N ;k++)
|
|
|
|
|
DeckTest.push(DeckPartie[i+k+j])
|
|
|
|
|
Tab = AssemblageArbre(copie(Decktest) , Decktest[0])
|
|
|
|
|
Pour toutes les valeurs de tab
|
|
|
|
|
Si tab[m] == N+2
|
|
|
|
|
//Woula j’ai trouvé*/
|
|
|
|
|
for (var N = 0; N < 4; N++) {
|
|
|
|
|
for (var i = 0; i < 16 - N; i++) {
|
|
|
|
|
for (var j = 0; j < 15 - i - N; j++) {
|
|
|
|
@ -685,9 +757,9 @@ function printCombinations(array, p) {
|
|
|
|
|
for (var j = 0; j < combinations.length; j++) {
|
|
|
|
|
combTest.push(deckPartie[combinations[j]]);
|
|
|
|
|
//window.alert("Matrice ajouté num" + j + " :" + deckPartie[combinations[j]].getMatrice);
|
|
|
|
|
console.log("i"+j +" :"+ combinations[j]);
|
|
|
|
|
console.log("i" + j + " :" + combinations[j]);
|
|
|
|
|
}
|
|
|
|
|
console.log("matrice début ex: "+combTest[0].getMatrice);
|
|
|
|
|
console.log("matrice début ex: " + combTest[0].getMatrice);
|
|
|
|
|
console.log("Cartes selectionnées :(en partant de indice 0) :")
|
|
|
|
|
console.log(combinations.join(" "));
|
|
|
|
|
console.log("----- taille :" + combTest.length + " -------");
|
|
|
|
@ -698,7 +770,7 @@ function printCombinations(array, p) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
run(0, 0);
|
|
|
|
|
window.alert("fin test " + k + " cartes" )
|
|
|
|
|
window.alert("fin test " + k + " cartes")
|
|
|
|
|
}
|
|
|
|
|
window.alert("nb combi :" + Cptsolution);
|
|
|
|
|
}
|
|
|
|
@ -875,15 +947,15 @@ function chercheCombi3() {
|
|
|
|
|
|
|
|
|
|
var cpt = 1100;
|
|
|
|
|
var x;
|
|
|
|
|
var itv = 0;
|
|
|
|
|
var itv = 0;
|
|
|
|
|
|
|
|
|
|
function decompte() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var progressnum = document.getElementById("progressnum");
|
|
|
|
|
var indicateur = document.getElementById("indicateur");
|
|
|
|
|
|
|
|
|
|
var indicateur = document.getElementById("indicateur");
|
|
|
|
|
|
|
|
|
|
if (cpt >= 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cpt--;
|
|
|
|
|
x = setTimeout("decompte()", 100);
|
|
|
|
|
}
|
|
|
|
@ -899,20 +971,26 @@ function decompte() {
|
|
|
|
|
clearInterval(itv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(cpt < 550) {
|
|
|
|
|
if (cpt < 550) {
|
|
|
|
|
document.getElementById("indicateur").style.backgroundColor = "orange";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(cpt < 366) {
|
|
|
|
|
document.getElementById("indicateur").style.backgroundColor = "red";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
indicateur.style.width = cpt + "px";
|
|
|
|
|
progressnum.innerHTML = cpt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cpt < 366) {
|
|
|
|
|
document.getElementById("indicateur").style.backgroundColor = "red";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
indicateur.style.width = cpt + "px";
|
|
|
|
|
progressnum.innerHTML = cpt;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function testerLesCartes() {
|
|
|
|
|
if (selectionMode == 0) {
|
|
|
|
|
testPourJeuClassique();
|
|
|
|
|
} else if (selectionMode == 1) {
|
|
|
|
|
testPourJeuInfini();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function testPourJeuInfini() {
|
|
|
|
@ -938,16 +1016,17 @@ function testPourJeuInfini() {
|
|
|
|
|
for (var i = 0; i < tab.length; i++) {
|
|
|
|
|
if (tab[i].code == carteselect.length) {
|
|
|
|
|
solution = false;
|
|
|
|
|
lesPoints += carteselect.length;
|
|
|
|
|
document.getElementById("affPoints").textContent = 'Score : ' + lesPoints;
|
|
|
|
|
changerlesCartes();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (solution) {
|
|
|
|
|
window.alert("Rien trouve chef !!!");
|
|
|
|
|
document.getElementById("affSolution").textContent = 'Aucune solution trouvée...';
|
|
|
|
|
}
|
|
|
|
|
if (!solution) {
|
|
|
|
|
window.alert("J'ai une solution chef !!!!");
|
|
|
|
|
document.getElementById("affSolution").textContent = 'Assemblage de ' + copie.length + ' cartes trouvé !';
|
|
|
|
|
}
|
|
|
|
|
window.alert(TasDuJEU.length)
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
window.alert(e);
|
|
|
|
@ -986,7 +1065,7 @@ function testPourJeuClassique() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (solution) {
|
|
|
|
|
document.getElementById("affSolution").textContent = 'Aucune solution trouvée...'
|
|
|
|
|
document.getElementById("affSolution").textContent = 'Aucune solution trouvée...';
|
|
|
|
|
}
|
|
|
|
|
if (!solution) {
|
|
|
|
|
document.getElementById("affSolution").textContent = 'Assemblage de ' + copie.length + ' cartes trouvé ! Il reste encore ' + TasDuJEU.length + ' cartes !';
|
|
|
|
@ -1016,7 +1095,7 @@ function copieCarte(uneCarte) {
|
|
|
|
|
for (var i = 0; i < uneCarte.SesFigures.length; i++) {
|
|
|
|
|
AllFigure.push(new Figure(uneCarte.SesFigures[i].type, uneCarte.SesFigures[i].forme, uneCarte.SesFigures[i].X, uneCarte.SesFigures[i].Y));
|
|
|
|
|
}
|
|
|
|
|
var carte = new Carte(uneCarte.getIdentifiant, AllFigure);
|
|
|
|
|
var carte = new Carte(uneCarte.getIdentifiant, AllFigure, uneCarte.row, uneCarte.column);
|
|
|
|
|
carte.Matrice = copieMatrice(uneCarte.Matrice, uneCarte.row, uneCarte.column);
|
|
|
|
|
return carte;
|
|
|
|
|
}
|
|
|
|
|