Possibilité de jouer en 4*4,3*3,3*2

master
yasevret 4 years ago
parent 69a7598549
commit 0dca998b33

@ -1,8 +1,8 @@
/*Ecran*/
@media screen and (min-width: 992px) {
:root{
--taille : 10vw;
:root {
--taille: 10vw;
}
/*PARTIE FORMES*/
@ -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{
.logoboutton {
font-size: 2vw;
color: var(--lightprima);
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;
}
}

@ -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,19 +563,19 @@
<div id="containpseudo">
<a onclick="lancerpartie()">
<a onclick="lancerpartie(); decompte();">
<div id="contourbuttonvalider">
<div class="bouttonvalider violet" >
<h1 id="textjouer">JOUER</h1>
<a onclick="lancerpartie(); decompte();">
<div id="contourbuttonvalider">
<div class="bouttonvalider violet">
<h1 id="textjouer">JOUER</h1>
</div>
</div>
</div>
</a>
</a>
</div>
<div id="choosemode">
<div id="conteneurmode">
<a>
<a onclick="modePrec()">
<div id="modeprec">
<div id="triangleprec">
@ -586,7 +586,33 @@
<div id="textdumode">
<h1 id="textmode">Solo</h1>
</div>
<a>
<a onclick="modeSuiv()">
<div id="modesuiv">
<div id="trianglesuiv">
</div>
</div>
</a>
</div>
</div>
<div id="choosedimension">
<div id="conteneurmode">
<a onclick="dimensionPrec()">
<div id="modeprec">
<div id="triangleprec">
</div>
</div>
</a>
<div id="textdumode">
<h1 id="textdimension">4 * 3</h1>
</div>
<a onclick="dimensionSuiv()">
<div id="modesuiv">
<div id="trianglesuiv">
@ -614,7 +640,7 @@
</div>
</div>
<div id="pageGame">
<div id="pageGame">
<div class="menuhaut menu">
<div class="divmenu"></div>
@ -627,16 +653,16 @@
</div>
<div class="divmenu">
<p id="affPoints">Score : 0</p>
</div>
<p id="affPoints">Score : 0</p>
</div>
<div class="divmenu logop2">
<a onclick="journuit()">
<img src="imgs/swishjour.png" id="imglogo2">
</a>
</div>
<a onclick="journuit()">
<img src="imgs/swishjour.png" id="imglogo2">
</a>
</div>
<div class="divmenu">
<a onclick="redistribuer()" class="bouttonMenuHaut">
<a onclick="redistribuerPlateau()" class="bouttonMenuHaut">
<div class="containButtonForm">
<i class="fa fa-redo logoboutton"></i>
</div>
@ -650,7 +676,7 @@
</a>
</div>
<div class="divmenu">
<a onclick="testPourJeuClassique()" id="relancerbtn" class="bouttonMenuHaut">
<a onclick="testerLesCartes()" id="relancerbtn" class="bouttonMenuHaut">
<div class="containButtonForm">
<i class="fa fa-check logoboutton"></i>
</div>
@ -660,7 +686,7 @@
<div id="progressbar">
<div id="indicateur"></div>
<div id="indicateur"></div>
</div>
<div id="containcards" class="containcards">

@ -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]);
@ -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 dun 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 jai 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 jai 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);
}
@ -880,7 +952,7 @@ var itv = 0;
function decompte() {
var progressnum = document.getElementById("progressnum");
var indicateur = document.getElementById("indicateur");
var indicateur = document.getElementById("indicateur");
if (cpt >= 0) {
@ -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";
}
if (cpt < 366) {
document.getElementById("indicateur").style.backgroundColor = "red";
}
indicateur.style.width = cpt + "px";
progressnum.innerHTML = cpt;
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;
}

Loading…
Cancel
Save