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

master
yasevret 4 years ago
parent 69a7598549
commit 0dca998b33

@ -1,8 +1,8 @@
/*Ecran*/ /*Ecran*/
@media screen and (min-width: 992px) { @media screen and (min-width: 992px) {
:root{ :root {
--taille : 10vw; --taille: 10vw;
} }
/*PARTIE FORMES*/ /*PARTIE FORMES*/
@ -14,7 +14,7 @@
vertical-align: middle; vertical-align: middle;
} }
.containinte{ .containinte {
/*PROBLEME SIZE*/ /*PROBLEME SIZE*/
top: calc((var(--y) - var(--z)) / 2); top: calc((var(--y) - var(--z)) / 2);
left: calc((var(--y) - var(--z)) / 2); left: calc((var(--y) - var(--z)) / 2);
@ -24,7 +24,7 @@
position: absolute; position: absolute;
} }
.cache{ .cache {
top: calc((var(--x) - var(--y)) / 2.8); top: calc((var(--x) - var(--y)) / 2.8);
left: calc((var(--x) - var(--y)) / 2.2); left: calc((var(--x) - var(--y)) / 2.2);
height: calc(var(--y)*1.05); height: calc(var(--y)*1.05);
@ -43,18 +43,27 @@
z-index: 15; z-index: 15;
} }
#conteneurmode{ #choosedimension {
height: 4vw;
width: 16vw;
position: absolute;
left: 42vw;
top: 55vh;
z-index: 15;
}
#conteneurmode {
width: 80%; width: 80%;
height: 2vw; height: 2vw;
left : 10%; left: 10%;
top : 25%; top: 25%;
position: absolute; position: absolute;
margin: 0 auto; margin: 0 auto;
background-color: var(--lightsedonca); background-color: var(--lightsedonca);
border-radius: 5vw; border-radius: 5vw;
} }
#triangleprec{ #triangleprec {
width: 0; width: 0;
height: 0; height: 0;
margin: 0.25vw auto 0 auto; margin: 0.25vw auto 0 auto;
@ -63,7 +72,7 @@
border-bottom: 0.75vw solid transparent; border-bottom: 0.75vw solid transparent;
} }
#trianglesuiv{ #trianglesuiv {
width: 0; width: 0;
height: 0; height: 0;
margin: 0.25vw auto 0 auto; margin: 0.25vw auto 0 auto;
@ -76,12 +85,20 @@
font-family: Lucida Console, Arial Black, Arial; font-family: Lucida Console, Arial Black, Arial;
font-size: 1vw; font-size: 1vw;
color: #707070; color: #707070;
text-align:center; text-align: center;
margin: 5% auto 0 auto; margin: 5% auto 0 auto;
} }
#formSize{ #textdimension {
margin : 0 auto; 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%; width: 100%;
height: 3vw; height: 3vw;
} }
@ -103,9 +120,11 @@
outline: none; outline: none;
background-color: transparent; background-color: transparent;
} }
.slider.container{
.slider.container {
position: relative; position: relative;
} }
.slider-container .bar { .slider-container .bar {
position: absolute; position: absolute;
z-index: 1; z-index: 1;
@ -117,7 +136,7 @@
overflow: hidden; overflow: hidden;
} }
/*Moz*/ /*Moz*/
.slider-container .slider::-moz-range-thumb { .slider-container .slider::-moz-range-thumb {
-webkit-appearance: none; -webkit-appearance: none;
width: 1vw; width: 1vw;
height: 1vw; height: 1vw;
@ -125,27 +144,28 @@
border-radius: 1vw; border-radius: 1vw;
cursor: pointer; cursor: pointer;
outline: none; 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; transition: .3s ease-in-out;
} }
.slider-container .slider::-moz-range-thumb:hover { .slider-container .slider::-moz-range-thumb:hover {
box-shadow: 0 0 0 10px rgba(98,0,238,.1); box-shadow: 0 0 0 10px rgba(98,0,238,.1);
} }
.slider-container .slider:active::-moz-range-thumb { .slider-container .slider:active::-moz-range-thumb {
box-shadow: 0 0 0 20px rgba(98,0,238,.2); box-shadow: 0 0 0 20px rgba(98,0,238,.2);
} }
/*===========================================*/ /*===========================================*/
.logoboutton{ .logoboutton {
font-size: 2vw; font-size: 2vw;
color: var(--lightprima); color: var(--lightprima);
margin: 0.25vw; margin: 0.25vw;
} }
/*Externe*/ /*Externe*/
.bouttonMenuHaut{ .bouttonMenuHaut {
height: 4vw; height: 4vw;
width: 4vw; width: 4vw;
background-color: var(--lightsedonca); background-color: var(--lightsedonca);
@ -170,7 +190,7 @@
margin-right: 1vw; margin-right: 1vw;
} }
.containButtonForm{ .containButtonForm {
height: 2.5vw; height: 2.5vw;
width: 2.5vw; width: 2.5vw;
margin: 0.75vw; margin: 0.75vw;
@ -273,7 +293,7 @@
border-radius: 30px; border-radius: 30px;
} }
.violet{ .violet {
background-color: #B130DE; background-color: #B130DE;
} }
@ -287,7 +307,7 @@
font-size: 2.5vw; font-size: 2.5vw;
margin-top: 0.2vw; margin-top: 0.2vw;
color: var(--lightsedonca); color: var(--lightsedonca);
text-align:center; text-align: center;
width: inherit; width: inherit;
} }
} }

@ -151,7 +151,7 @@
var $slider = $("#slider"); var $slider = $("#slider");
var $fill = $(".bar .fill"); var $fill = $(".bar .fill");
function setBar(){ function setBar() {
$fill.css("width", $slider.val() + "%"); $fill.css("width", $slider.val() + "%");
valRange = $slider.val(); valRange = $slider.val();
changeContour(valRange); changeContour(valRange);
@ -563,19 +563,19 @@
<div id="containpseudo"> <div id="containpseudo">
<a onclick="lancerpartie()"> <a onclick="lancerpartie()">
<a onclick="lancerpartie(); decompte();"> <a onclick="lancerpartie(); decompte();">
<div id="contourbuttonvalider"> <div id="contourbuttonvalider">
<div class="bouttonvalider violet" > <div class="bouttonvalider violet">
<h1 id="textjouer">JOUER</h1> <h1 id="textjouer">JOUER</h1>
</div>
</div> </div>
</div> </a>
</a>
</div> </div>
<div id="choosemode"> <div id="choosemode">
<div id="conteneurmode"> <div id="conteneurmode">
<a> <a onclick="modePrec()">
<div id="modeprec"> <div id="modeprec">
<div id="triangleprec"> <div id="triangleprec">
@ -586,7 +586,33 @@
<div id="textdumode"> <div id="textdumode">
<h1 id="textmode">Solo</h1> <h1 id="textmode">Solo</h1>
</div> </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="modesuiv">
<div id="trianglesuiv"> <div id="trianglesuiv">
@ -614,7 +640,7 @@
</div> </div>
</div> </div>
<div id="pageGame"> <div id="pageGame">
<div class="menuhaut menu"> <div class="menuhaut menu">
<div class="divmenu"></div> <div class="divmenu"></div>
@ -627,16 +653,16 @@
</div> </div>
<div class="divmenu"> <div class="divmenu">
<p id="affPoints">Score : 0</p> <p id="affPoints">Score : 0</p>
</div> </div>
<div class="divmenu logop2"> <div class="divmenu logop2">
<a onclick="journuit()"> <a onclick="journuit()">
<img src="imgs/swishjour.png" id="imglogo2"> <img src="imgs/swishjour.png" id="imglogo2">
</a> </a>
</div> </div>
<div class="divmenu"> <div class="divmenu">
<a onclick="redistribuer()" class="bouttonMenuHaut"> <a onclick="redistribuerPlateau()" class="bouttonMenuHaut">
<div class="containButtonForm"> <div class="containButtonForm">
<i class="fa fa-redo logoboutton"></i> <i class="fa fa-redo logoboutton"></i>
</div> </div>
@ -650,7 +676,7 @@
</a> </a>
</div> </div>
<div class="divmenu"> <div class="divmenu">
<a onclick="testPourJeuClassique()" id="relancerbtn" class="bouttonMenuHaut"> <a onclick="testerLesCartes()" id="relancerbtn" class="bouttonMenuHaut">
<div class="containButtonForm"> <div class="containButtonForm">
<i class="fa fa-check logoboutton"></i> <i class="fa fa-check logoboutton"></i>
</div> </div>
@ -660,7 +686,7 @@
<div id="progressbar"> <div id="progressbar">
<div id="indicateur"></div> <div id="indicateur"></div>
</div> </div>
<div id="containcards" class="containcards"> <div id="containcards" class="containcards">

@ -10,21 +10,58 @@ var darktercia = "#606060";
var carteselect = []; var carteselect = [];
var deckPartie = []; //Ensemble des cartes affichees a l'ecran var deckPartie = []; //Ensemble des cartes affichees a l'ecran
var TasDuJEU = []; // Ensemble de toutes les cartes presente dans le jeu 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 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 { 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 //Attribut de Classe
this.identifiant = id; this.identifiant = id;
this.row = 4 /*row*/; this.row = nbRow;
this.column = 3 /*column*/; this.column = nbColumn;
this.Matrice = creaMatrice(this.row, this.column); this.Matrice = creaMatrice(nbRow, nbColumn);
this.SesFigures = []; this.SesFigures = [];
for (var i = 0; i < allFigure.length; i++) { for (var i = 0; i < allFigure.length; i++) {
this.SesFigures.push(allFigure[i]); this.SesFigures.push(allFigure[i]);
@ -260,6 +297,7 @@ const TypeFigure = {
function journuit() { function journuit() {
//mode jour //mode jour
mode = mode + 1;
if (mode % 2 == 0) { if (mode % 2 == 0) {
//changer logo swish //changer logo swish
document.getElementById("imglogo").src = "imgs/swishjour.png"; document.getElementById("imglogo").src = "imgs/swishjour.png";
@ -291,17 +329,38 @@ function journuit() {
document.documentElement.style.setProperty('--lightsedonca', darkseconda); document.documentElement.style.setProperty('--lightsedonca', darkseconda);
document.documentElement.style.setProperty('--lighttercia', darktercia); document.documentElement.style.setProperty('--lighttercia', darktercia);
} }
mode = mode + 1;
} }
//=================================================================================== //===================================================================================
//FONCTION GESTION DE GAME //FONCTION GESTION DE GAME
function lancerpartie() { function lancerpartie() {
document.getElementById("pageAccueil").style.visibility = "hidden"; var ready = true;
//fonction de creation de partie a changer en fonction du test voulu //fonction de creation de partie a changer en fonction du test voulu
creePartieClassique(); if (selectionMode == 0) {
document.getElementById("pageGame").style.visibility = "visible"; 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() { 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() { function redistribuer() {
deckPartie = []; deckPartie = [];
for (var i = 0; i < 16; i++) { 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)); AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 0, j));
if (i != 3 * j) { if (i != 3 * j) {
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3))); 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); deckPartie.push(uneCarte);
if (!doublonInterdit(uneCarte)) { if (!doublonInterdit(uneCarte)) {
AllFigure = []; AllFigure = [];
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 0, j)); 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))); 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); deckPartie.push(unDoublon);
} }
} }
@ -379,13 +450,13 @@ function genererTouteslesCartes3_4Possibles() {
if (i != 3 * j + 1) { if (i != 3 * j + 1) {
if (i != 2 && i != 5 && i != 8 && i != 11) { 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))); 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); deckPartie.push(uneCarte);
if (!doublonInterdit(uneCarte)) { if (!doublonInterdit(uneCarte)) {
AllFigure = []; AllFigure = [];
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 1, j)); 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))); 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); deckPartie.push(unDoublon);
} }
} }
@ -404,7 +475,7 @@ function afficherCartes(Liste) {
} }
} }
function creePartieClassique() { function creePartieClassique3_4() {
TasDuJEU = genererTouteslesCartes3_4Possibles(); TasDuJEU = genererTouteslesCartes3_4Possibles();
deckPartie = []; deckPartie = [];
for (var i = 0; i < TasDuJEU.length; i++) { for (var i = 0; i < TasDuJEU.length; i++) {
@ -443,7 +514,7 @@ function creePartieClassique() {
afficherCartes(deckPartie); afficherCartes(deckPartie);
} }
function creePartieInfini() { function creePartieInfini(nbRow, nbColum) {
deckPartie = []; deckPartie = [];
carteselect = []; carteselect = [];
while (document.getElementById("containcards").firstElementChild != null) { while (document.getElementById("containcards").firstElementChild != null) {
@ -454,20 +525,20 @@ function creePartieInfini() {
var AllFigure = []; var AllFigure = [];
var Cox1, Coy1, Cox2, Coy2; var Cox1, Coy1, Cox2, Coy2;
Cox1 = getRandom(0, 2); Cox1 = getRandom(0, nbColum - 1);
Coy1 = getRandom(0, 3); Coy1 = getRandom(0, nbRow - 1);
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, Cox1, Coy1)); AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, Cox1, Coy1));
Cox2 = getRandom(0, 2); Cox2 = getRandom(0, nbColum - 1);
Coy2 = getRandom(0, 3); Coy2 = getRandom(0, nbRow - 1);
while (Cox2 == Cox1 && Coy1 == Coy2) { while (Cox2 == Cox1 && Coy1 == Coy2) {
Cox2 = getRandom(0, 2); Cox2 = getRandom(0, nbColum - 1);
Coy2 = getRandom(0, 3); Coy2 = getRandom(0, nbRow - 1);
} }
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, Cox2, Coy2)); AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, Cox2, Coy2));
//Code de Generation de Figure //Code de Generation de Figure
var uneCarte = new Carte(j, AllFigure); var uneCarte = new Carte(j, AllFigure, nbRow, nbColum);
deckPartie.push(uneCarte); deckPartie.push(uneCarte);
@ -525,20 +596,20 @@ function remplacerLaCarte(uneCarte) {
var AllFigure = []; var AllFigure = [];
var Cox1, Coy1, Cox2, Coy2; var Cox1, Coy1, Cox2, Coy2;
Cox1 = getRandom(0, 2); Cox1 = getRandom(0, uneCarte.column - 1);
Coy1 = getRandom(0, 3); Coy1 = getRandom(0, uneCarte.row - 1);
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, Cox1, Coy1)); AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, Cox1, Coy1));
Cox2 = getRandom(0, 2); Cox2 = getRandom(0, uneCarte.column - 1);
Coy2 = getRandom(0, 3); Coy2 = getRandom(0, uneCarte.row - 1);
while (Cox2 == Cox1 && Coy1 == Coy2) { while (Cox2 == Cox1 && Coy1 == Coy2) {
Cox2 = getRandom(0, 2); Cox2 = getRandom(0, uneCarte.column - 1);
Coy2 = getRandom(0, 3); Coy2 = getRandom(0, uneCarte.row - 1);
} }
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, Cox2, Coy2)); AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, Cox2, Coy2));
//Code de Generation de Figure //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; deckPartie[pos] = newCarte;
} }
@ -584,6 +655,7 @@ function creaMatriceVierge(row, column) {
function creaMatrice(row, column) { function creaMatrice(row, column) {
var myMatrice = creaMatriceVierge(row, column); var myMatrice = creaMatriceVierge(row, column);
//window.alert(myMatrice)
var Cox1, Coy1, Cox2, Coy2; var Cox1, Coy1, Cox2, Coy2;
@ -613,16 +685,16 @@ function chercherCombinaison() {
var Cptsolution = 0; var Cptsolution = 0;
/* /*
Pour toutes les longueurs possible dun tas de carte (N = 0, N<4 ; N++) 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 échantillon de cartes ( i = 0 ; i<16 N ; i ++)
Pour toutes les autres cartes (j=0 ;j<15-i-N ;j++) Pour toutes les autres cartes (j=0 ;j<15-i-N ;j++)
DeckTest = vide ; DeckTest = vide ;
DeckTest.push(DeckPartie[i]) DeckTest.push(DeckPartie[i])
Pour N + 2 cartes (k=1 ;k<2+N ;k++) Pour N + 2 cartes (k=1 ;k<2+N ;k++)
DeckTest.push(DeckPartie[i+k+j]) DeckTest.push(DeckPartie[i+k+j])
Tab = AssemblageArbre(copie(Decktest) , Decktest[0]) Tab = AssemblageArbre(copie(Decktest) , Decktest[0])
Pour toutes les valeurs de tab Pour toutes les valeurs de tab
Si tab[m] == N+2 Si tab[m] == N+2
//Woula jai trouvé*/ //Woula jai trouvé*/
for (var N = 0; N < 4; N++) { for (var N = 0; N < 4; N++) {
for (var i = 0; i < 16 - N; i++) { for (var i = 0; i < 16 - N; i++) {
for (var j = 0; j < 15 - i - N; j++) { 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++) { for (var j = 0; j < combinations.length; j++) {
combTest.push(deckPartie[combinations[j]]); combTest.push(deckPartie[combinations[j]]);
//window.alert("Matrice ajouté num" + j + " :" + deckPartie[combinations[j]].getMatrice); //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("Cartes selectionnées :(en partant de indice 0) :")
console.log(combinations.join(" ")); console.log(combinations.join(" "));
console.log("----- taille :" + combTest.length + " -------"); console.log("----- taille :" + combTest.length + " -------");
@ -698,7 +770,7 @@ function printCombinations(array, p) {
} }
} }
run(0, 0); run(0, 0);
window.alert("fin test " + k + " cartes" ) window.alert("fin test " + k + " cartes")
} }
window.alert("nb combi :" + Cptsolution); window.alert("nb combi :" + Cptsolution);
} }
@ -880,7 +952,7 @@ var itv = 0;
function decompte() { function decompte() {
var progressnum = document.getElementById("progressnum"); var progressnum = document.getElementById("progressnum");
var indicateur = document.getElementById("indicateur"); var indicateur = document.getElementById("indicateur");
if (cpt >= 0) { if (cpt >= 0) {
@ -899,20 +971,26 @@ function decompte() {
clearInterval(itv); clearInterval(itv);
} }
if(cpt < 550) { if (cpt < 550) {
document.getElementById("indicateur").style.backgroundColor = "orange"; document.getElementById("indicateur").style.backgroundColor = "orange";
} }
if(cpt < 366) { if (cpt < 366) {
document.getElementById("indicateur").style.backgroundColor = "red"; document.getElementById("indicateur").style.backgroundColor = "red";
} }
indicateur.style.width = cpt + "px"; indicateur.style.width = cpt + "px";
progressnum.innerHTML = cpt; progressnum.innerHTML = cpt;
} }
function testerLesCartes() {
if (selectionMode == 0) {
testPourJeuClassique();
} else if (selectionMode == 1) {
testPourJeuInfini();
}
}
function testPourJeuInfini() { function testPourJeuInfini() {
@ -938,16 +1016,17 @@ function testPourJeuInfini() {
for (var i = 0; i < tab.length; i++) { for (var i = 0; i < tab.length; i++) {
if (tab[i].code == carteselect.length) { if (tab[i].code == carteselect.length) {
solution = false; solution = false;
lesPoints += carteselect.length;
document.getElementById("affPoints").textContent = 'Score : ' + lesPoints;
changerlesCartes(); changerlesCartes();
} }
} }
if (solution) { if (solution) {
window.alert("Rien trouve chef !!!"); document.getElementById("affSolution").textContent = 'Aucune solution trouvée...';
} }
if (!solution) { 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) { } catch (e) {
window.alert(e); window.alert(e);
@ -986,7 +1065,7 @@ function testPourJeuClassique() {
} }
} }
if (solution) { if (solution) {
document.getElementById("affSolution").textContent = 'Aucune solution trouvée...' document.getElementById("affSolution").textContent = 'Aucune solution trouvée...';
} }
if (!solution) { if (!solution) {
document.getElementById("affSolution").textContent = 'Assemblage de ' + copie.length + ' cartes trouvé ! Il reste encore ' + TasDuJEU.length + ' cartes !'; 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++) { 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)); 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); carte.Matrice = copieMatrice(uneCarte.Matrice, uneCarte.row, uneCarte.column);
return carte; return carte;
} }

Loading…
Cancel
Save