From 0dca998b333941f477ede7327e0b7a9058a353fb Mon Sep 17 00:00:00 2001 From: yasevret Date: Sun, 7 Feb 2021 10:53:57 +0100 Subject: [PATCH] =?UTF-8?q?Possibilit=C3=A9=20de=20jouer=20en=204*4,3*3,3*?= =?UTF-8?q?2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SwichGIT/src/css/desktops.css | 76 ++++++++----- SwichGIT/src/index.html | 82 +++++++++----- SwichGIT/src/js/main.js | 205 +++++++++++++++++++++++----------- 3 files changed, 244 insertions(+), 119 deletions(-) diff --git a/SwichGIT/src/css/desktops.css b/SwichGIT/src/css/desktops.css index 49d6198..822bfde 100644 --- a/SwichGIT/src/css/desktops.css +++ b/SwichGIT/src/css/desktops.css @@ -1,10 +1,10 @@ /*Ecran*/ @media screen and (min-width: 992px) { - - :root{ - --taille : 10vw; + + :root { + --taille: 10vw; } - + /*PARTIE FORMES*/ .containform3 { position: relative; @@ -14,7 +14,7 @@ vertical-align: middle; } - .containinte{ + .containinte { /*PROBLEME SIZE*/ top: calc((var(--y) - var(--z)) / 2); left: calc((var(--y) - var(--z)) / 2); @@ -24,7 +24,7 @@ position: absolute; } - .cache{ + .cache { top: calc((var(--x) - var(--y)) / 2.8); left: calc((var(--x) - var(--y)) / 2.2); height: calc(var(--y)*1.05); @@ -43,18 +43,27 @@ z-index: 15; } - #conteneurmode{ + #choosedimension { + height: 4vw; + width: 16vw; + position: absolute; + left: 42vw; + top: 55vh; + z-index: 15; + } + + #conteneurmode { width: 80%; height: 2vw; - left : 10%; - top : 25%; + left: 10%; + top: 25%; position: absolute; margin: 0 auto; background-color: var(--lightsedonca); border-radius: 5vw; } - #triangleprec{ + #triangleprec { width: 0; height: 0; margin: 0.25vw auto 0 auto; @@ -63,7 +72,7 @@ border-bottom: 0.75vw solid transparent; } - #trianglesuiv{ + #trianglesuiv { width: 0; height: 0; margin: 0.25vw auto 0 auto; @@ -76,12 +85,20 @@ font-family: Lucida Console, Arial Black, Arial; font-size: 1vw; color: #707070; - text-align:center; + text-align: center; margin: 5% auto 0 auto; } - #formSize{ - margin : 0 auto; + #textdimension { + font-family: Lucida Console, Arial Black, Arial; + font-size: 1vw; + color: #707070; + text-align: center; + margin: 5% auto 0 auto; + } + + #formSize { + margin: 0 auto; width: 100%; height: 3vw; } @@ -103,9 +120,11 @@ outline: none; background-color: transparent; } - .slider.container{ + + .slider.container { position: relative; } + .slider-container .bar { position: absolute; z-index: 1; @@ -117,7 +136,7 @@ overflow: hidden; } /*Moz*/ - .slider-container .slider::-moz-range-thumb { + .slider-container .slider::-moz-range-thumb { -webkit-appearance: none; width: 1vw; height: 1vw; @@ -125,27 +144,28 @@ border-radius: 1vw; cursor: pointer; outline: none; - box-shadow: 0 0 0 0 rgba(98, 0 ,238, .1); + box-shadow: 0 0 0 0 rgba(98, 0,238, .1); transition: .3s ease-in-out; } - .slider-container .slider::-moz-range-thumb:hover { - box-shadow: 0 0 0 10px rgba(98,0,238,.1); - } + .slider-container .slider::-moz-range-thumb:hover { + box-shadow: 0 0 0 10px rgba(98,0,238,.1); + } + .slider-container .slider:active::-moz-range-thumb { box-shadow: 0 0 0 20px rgba(98,0,238,.2); } /*===========================================*/ - - .logoboutton{ - font-size: 2vw; + + .logoboutton { + font-size: 2vw; color: var(--lightprima); - margin: 0.25vw; + margin: 0.25vw; } /*Externe*/ - .bouttonMenuHaut{ + .bouttonMenuHaut { height: 4vw; width: 4vw; background-color: var(--lightsedonca); @@ -170,7 +190,7 @@ margin-right: 1vw; } - .containButtonForm{ + .containButtonForm { height: 2.5vw; width: 2.5vw; margin: 0.75vw; @@ -273,7 +293,7 @@ border-radius: 30px; } - .violet{ + .violet { background-color: #B130DE; } @@ -287,7 +307,7 @@ font-size: 2.5vw; margin-top: 0.2vw; color: var(--lightsedonca); - text-align:center; + text-align: center; width: inherit; } } diff --git a/SwichGIT/src/index.html b/SwichGIT/src/index.html index cbedf04..fb3f26e 100644 --- a/SwichGIT/src/index.html +++ b/SwichGIT/src/index.html @@ -82,7 +82,7 @@

Paramètres

× -
+

@@ -151,7 +151,7 @@ var $slider = $("#slider"); var $fill = $(".bar .fill"); - function setBar(){ + function setBar() { $fill.css("width", $slider.val() + "%"); valRange = $slider.val(); changeContour(valRange); @@ -563,22 +563,22 @@
- -
- +
- +
@@ -586,15 +586,41 @@

Solo

- + +
+
+ +
+
+
+ + +
+
+ +
+ +
+ +
+
+ +
+
+
+ +
+

4 * 3

+
+
- +
- +
@@ -614,45 +640,45 @@
-
+
- - - -
+ + + +
@@ -660,7 +686,7 @@
-
+
diff --git a/SwichGIT/src/js/main.js b/SwichGIT/src/js/main.js index de8d7e1..68ce487 100644 --- a/SwichGIT/src/js/main.js +++ b/SwichGIT/src/js/main.js @@ -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; }