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

master
yasevret 4 years ago
parent 69a7598549
commit 0dca998b33

@ -43,6 +43,15 @@
z-index: 15;
}
#choosedimension {
height: 4vw;
width: 16vw;
position: absolute;
left: 42vw;
top: 55vh;
z-index: 15;
}
#conteneurmode {
width: 80%;
height: 2vw;
@ -80,6 +89,14 @@
margin: 5% auto 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%;
@ -103,9 +120,11 @@
outline: none;
background-color: transparent;
}
.slider.container {
position: relative;
}
.slider-container .bar {
position: absolute;
z-index: 1;
@ -132,6 +151,7 @@
.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);
}

@ -575,7 +575,7 @@
<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">
@ -636,7 +662,7 @@
</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>

@ -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,18 +329,39 @@ 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();
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() {
document.getElementById("pageAccueil").style.visibility = "visible";
@ -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;
@ -912,7 +984,13 @@ function decompte() {
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