|
|
|
@ -9,6 +9,8 @@ var darkseconda = "#393939";
|
|
|
|
|
var darktercia = "#606060";
|
|
|
|
|
var carteselect = [];
|
|
|
|
|
var deckPartie = []; //Ensemble des cartes affichées à l'écran
|
|
|
|
|
var TasDuJEU = []; // Ensemble de toutes les cartes présente dans le jeu
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -42,9 +44,13 @@ class Carte {
|
|
|
|
|
var ajouté = true;
|
|
|
|
|
for (var j = 0; j < this.SesFigures.length; j++) {
|
|
|
|
|
if (i == this.SesFigures[j].X + (this.SesFigures[j].Y * 3)) {
|
|
|
|
|
ajouté = false;
|
|
|
|
|
var uneFigure = new Figure(this.SesFigures[j].type[0], this.SesFigures[j].forme, this.SesFigures[j].X, this.SesFigures[j].Y);
|
|
|
|
|
divconteneur.appendChild(uneFigure.CodeHTML);
|
|
|
|
|
try {
|
|
|
|
|
ajouté = false;
|
|
|
|
|
var uneFigure = new Figure(this.SesFigures[j].type, this.SesFigures[j].forme, this.SesFigures[j].X, this.SesFigures[j].Y);
|
|
|
|
|
divconteneur.appendChild(this.SesFigures[j].CodeHTML);
|
|
|
|
|
} catch (e) {
|
|
|
|
|
window.alert(this.SesFigures[j].type.length).length
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (ajouté) {
|
|
|
|
@ -146,7 +152,9 @@ class Figure {
|
|
|
|
|
this.X = Cox;
|
|
|
|
|
this.Y = Coy;
|
|
|
|
|
this.type = [];
|
|
|
|
|
this.type.push(leType);
|
|
|
|
|
for (var i = 0; i < leType.length; i++) {
|
|
|
|
|
this.type.push(leType[i]);
|
|
|
|
|
}
|
|
|
|
|
this.forme = forme;
|
|
|
|
|
var pos = this.X + this.Y * 3;
|
|
|
|
|
var divcase = document.createElement('div');
|
|
|
|
@ -237,9 +245,9 @@ const FormeFigure = {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const TypeFigure = {
|
|
|
|
|
Petit: 'petit',
|
|
|
|
|
Moyen: 'moyen',
|
|
|
|
|
Grand: 'grand'
|
|
|
|
|
Petit: 'p',
|
|
|
|
|
Moyen: 'm',
|
|
|
|
|
Grand: 'g'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -319,36 +327,79 @@ function rechargerGAME() {
|
|
|
|
|
//================================================================================================================================================================
|
|
|
|
|
//Fonction créations de game
|
|
|
|
|
|
|
|
|
|
function genererTouteslesCartes3_4Possibles() {
|
|
|
|
|
function genererTouteslesCartes3_4Possibles(){
|
|
|
|
|
deckPartie = [];
|
|
|
|
|
carteselect = [];
|
|
|
|
|
while (document.getElementById("containcards").firstElementChild != null) {
|
|
|
|
|
document.getElementById("containcards").firstElementChild.remove();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (var k = 0; k < 2; k++) {
|
|
|
|
|
for (var j = 0; j < 2; j++) {
|
|
|
|
|
for (var i = 0; i < 12; i++) {
|
|
|
|
|
var AllFigure = [];
|
|
|
|
|
AllFigure.push(new Figure(TypeFigure.Petit, FormeFigure.Rond, k, j));
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, k, j));
|
|
|
|
|
if (i != k + 3 * j) {
|
|
|
|
|
if (k == 0) {
|
|
|
|
|
AllFigure.push(new Figure(TypeFigure.Moyen, FormeFigure.Rond, i % 3, Math.floor(i / 3)));
|
|
|
|
|
var uneCarte = new Carte(i + 12 * j , AllFigure);
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
|
|
|
|
|
var uneCarte = new Carte(deckPartie.length + 1, AllFigure);
|
|
|
|
|
if (!doublonInterdit(uneCarte)) {
|
|
|
|
|
var unDoublon = copieCarte(uneCarte);
|
|
|
|
|
unDoublon.identifiant += 1;
|
|
|
|
|
deckPartie.push(unDoublon);
|
|
|
|
|
}
|
|
|
|
|
deckPartie.push(uneCarte);
|
|
|
|
|
document.getElementById("containcards").appendChild(uneCarte.link);
|
|
|
|
|
} else if (i != 2 && i != 5 && i != 8 && i != 11) {
|
|
|
|
|
AllFigure.push(new Figure(TypeFigure.Moyen, FormeFigure.Rond, i % 3, Math.floor(i / 3)));
|
|
|
|
|
var uneCarte = new Carte(i + 12 * (1 + k + j), AllFigure);
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
|
|
|
|
|
var uneCarte = new Carte(deckPartie.length + 1, AllFigure);
|
|
|
|
|
if (!doublonInterdit(uneCarte)) {
|
|
|
|
|
var unDoublon = copieCarte(uneCarte);
|
|
|
|
|
unDoublon.identifiant += 1;
|
|
|
|
|
deckPartie.push(unDoublon);
|
|
|
|
|
}
|
|
|
|
|
deckPartie.push(uneCarte);
|
|
|
|
|
document.getElementById("containcards").appendChild(uneCarte.link);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
afficherCartes(deckPartie)
|
|
|
|
|
return deckPartie;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function afficherCartes(Liste) {
|
|
|
|
|
while (document.getElementById("containcards").firstElementChild != null) {
|
|
|
|
|
document.getElementById("containcards").firstElementChild.remove();
|
|
|
|
|
}
|
|
|
|
|
for (var i = 0; i < Liste.length; i++) {
|
|
|
|
|
document.getElementById("containcards").appendChild(Liste[i].link);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creePartieClassique() {
|
|
|
|
|
TasDuJEU = genererTouteslesCartes3_4Possibles();
|
|
|
|
|
deckPartie = [];
|
|
|
|
|
for (var i = 0; i < TasDuJEU.length; i++) {
|
|
|
|
|
CodeRotation = getRandom(0, 3);
|
|
|
|
|
if (CodeRotation == 0) {
|
|
|
|
|
TasDuJEU[i] = TasDuJEU[i];
|
|
|
|
|
} else if (CodeRotation == 1) {
|
|
|
|
|
TasDuJEU[i] = Horizontale(TasDuJEU[i]);
|
|
|
|
|
} else if (CodeRotation == 2) {
|
|
|
|
|
TasDuJEU[i] = Verticale(TasDuJEU[i]);
|
|
|
|
|
} else if (CodeRotation == 3) {
|
|
|
|
|
TasDuJEU[i] = Verticale(TasDuJEU[i]);
|
|
|
|
|
TasDuJEU[i] = Horizontale(TasDuJEU[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (var i = 0; i < 16; i++) {
|
|
|
|
|
var index = getRandom(0, TasDuJEU.length - 1)
|
|
|
|
|
deckPartie.push(copieCarte(TasDuJEU[index]));
|
|
|
|
|
}
|
|
|
|
|
afficherCartes(deckPartie);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function creePartieDeTest() {
|
|
|
|
|
function creePartieInfini() {
|
|
|
|
|
deckPartie = [];
|
|
|
|
|
carteselect = [];
|
|
|
|
|
while (document.getElementById("containcards").firstElementChild != null) {
|
|
|
|
@ -361,7 +412,7 @@ function creePartieDeTest() {
|
|
|
|
|
|
|
|
|
|
Cox1 = getRandom(0, 2);
|
|
|
|
|
Coy1 = getRandom(0, 3);
|
|
|
|
|
AllFigure.push(new Figure(TypeFigure.Petit, FormeFigure.Rond, Cox1, Coy1));
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, Cox1, Coy1));
|
|
|
|
|
|
|
|
|
|
Cox2 = getRandom(0, 2);
|
|
|
|
|
Coy2 = getRandom(0, 3);
|
|
|
|
@ -370,7 +421,7 @@ function creePartieDeTest() {
|
|
|
|
|
Cox2 = getRandom(0, 2);
|
|
|
|
|
Coy2 = getRandom(0, 3);
|
|
|
|
|
}
|
|
|
|
|
AllFigure.push(new Figure(TypeFigure.Moyen, FormeFigure.Rond, Cox2, Coy2));
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, Cox2, Coy2));
|
|
|
|
|
//Code de Génération de Figure
|
|
|
|
|
var uneCarte = new Carte(j, AllFigure);
|
|
|
|
|
|
|
|
|
@ -398,7 +449,7 @@ function remplacerLaCarte(uneCarte) {
|
|
|
|
|
|
|
|
|
|
Cox1 = getRandom(0, 2);
|
|
|
|
|
Coy1 = getRandom(0, 3);
|
|
|
|
|
AllFigure.push(new Figure(TypeFigure.Petit, FormeFigure.Rond, Cox1, Coy1));
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, Cox1, Coy1));
|
|
|
|
|
|
|
|
|
|
Cox2 = getRandom(0, 2);
|
|
|
|
|
Coy2 = getRandom(0, 3);
|
|
|
|
@ -407,7 +458,8 @@ function remplacerLaCarte(uneCarte) {
|
|
|
|
|
Cox2 = getRandom(0, 2);
|
|
|
|
|
Coy2 = getRandom(0, 3);
|
|
|
|
|
}
|
|
|
|
|
AllFigure.push(new Figure(TypeFigure.Moyen, FormeFigure.Rond, Cox2, Coy2));
|
|
|
|
|
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, Cox2, Coy2));
|
|
|
|
|
//Code de Génération de Figure
|
|
|
|
|
var newCarte = new Carte(pos + 1, AllFigure);
|
|
|
|
|
deckPartie[pos] = newCarte;
|
|
|
|
|
}
|
|
|
|
@ -493,8 +545,8 @@ function chercheCombi2() {
|
|
|
|
|
tab.splice(0, DeckTeste.length);
|
|
|
|
|
tabCode.splice(0, DeckTeste.length);
|
|
|
|
|
|
|
|
|
|
DeckTeste.push(deckPartie[i]);
|
|
|
|
|
DeckTeste.push(deckPartie[j + i + 1]);
|
|
|
|
|
DeckTeste.push(copieCarte(deckPartie[i]));
|
|
|
|
|
DeckTeste.push(copieCarte(deckPartie[j + i + 1]));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (var h = 0; h < DeckTeste.length; h++) {
|
|
|
|
@ -592,7 +644,10 @@ function test() {
|
|
|
|
|
window.alert("Selection Vide");
|
|
|
|
|
return;
|
|
|
|
|
} else if (carteselect.length < 2) {
|
|
|
|
|
window.alert("Selection Trop Petite");
|
|
|
|
|
//window.alert("Selection Trop Petite");
|
|
|
|
|
var leCarte = copieCarte(carteselect[0]);
|
|
|
|
|
document.getElementById("containcards").appendChild(leCarte.link);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
var copie = [];
|
|
|
|
@ -618,7 +673,7 @@ function test() {
|
|
|
|
|
if (!solution) {
|
|
|
|
|
window.alert("J'ai une solution chef !!!!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
window.alert(TasDuJEU.length)
|
|
|
|
|
}
|
|
|
|
|
} catch (e) {
|
|
|
|
|
window.alert(e);
|
|
|
|
@ -640,16 +695,11 @@ function copieCarte(uneCarte) {
|
|
|
|
|
if (uneCarte == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
var carte = new Carte(uneCarte.getIdentifiant, uneCarte.SesFigures);
|
|
|
|
|
carte.SesFigures = new Array();
|
|
|
|
|
var AllFigure = [];
|
|
|
|
|
for (var i = 0; i < uneCarte.SesFigures.length; i++) {
|
|
|
|
|
carte.SesFigures.push(new Figure(uneCarte.SesFigures[i].type[0], uneCarte.SesFigures[i].getForme, uneCarte.SesFigures[i].getX, uneCarte.SesFigures[i].getY));
|
|
|
|
|
if (uneCarte.SesFigures[i].type.length > 1) {
|
|
|
|
|
for (var j = 1; j < uneCarte.SesFigures[i].type.length; j++) {
|
|
|
|
|
carte.SesFigures[carte.SesFigures.length - 1].type.push(uneCarte.SesFigures[i].type[j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
carte.Matrice = copieMatrice(uneCarte.Matrice, uneCarte.row, uneCarte.column);
|
|
|
|
|
return carte;
|
|
|
|
|
}
|
|
|
|
@ -711,9 +761,9 @@ function AssemblageARBRE(TasDeCarte, Carte) {
|
|
|
|
|
return tab;
|
|
|
|
|
}
|
|
|
|
|
tab.push(AssemblageARBRE(uneTable, copieCarte(uneTable[0])));
|
|
|
|
|
tab.push(AssemblageARBRE(uneTable, Horizontale(uneTable[0])));
|
|
|
|
|
tab.push(AssemblageARBRE(uneTable, Verticale(uneTable[0])));
|
|
|
|
|
var derniereCarte = Horizontale(Verticale(uneTable[0]));
|
|
|
|
|
tab.push(AssemblageARBRE(uneTable, Horizontale(copieCarte(uneTable[0]))));
|
|
|
|
|
tab.push(AssemblageARBRE(uneTable, Verticale(copieCarte(uneTable[0]))));
|
|
|
|
|
var derniereCarte = Horizontale(Verticale(copieCarte(uneTable[0])));
|
|
|
|
|
tab.push(AssemblageARBRE(uneTable, derniereCarte));
|
|
|
|
|
for (var i = 0; i < tab.length; i++) {
|
|
|
|
|
for (var j = 0; j < tab[i].length; j++) {
|
|
|
|
@ -873,6 +923,24 @@ function ajouterplayer(event){
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
function doublonInterdit(uneCarte) {
|
|
|
|
|
var lesCoPetit = [];
|
|
|
|
|
lesCoPetit.push([1, 1], [1, 1], [1, 2], [1, 2], [1, 1], [2, 2], [1, 1], [2, 1], [1, 2], [2, 2], [1, 2], [2, 1]);
|
|
|
|
|
var lesCoMoyens = [];
|
|
|
|
|
lesCoMoyens.push([2, 1], [3, 3], [1, 1], [3, 4], [2, 3], [1, 4], [1, 2], [1, 1], [2, 3], [1, 3], [2, 4], [1, 3]);
|
|
|
|
|
for (var i = 0; i < lesCoPetit.length; i++) {
|
|
|
|
|
if (uneCarte.SesFigures[0].X == (lesCoPetit[i][0]) - 1) {
|
|
|
|
|
if (uneCarte.SesFigures[0].Y == (lesCoPetit[i][1]) - 1) {
|
|
|
|
|
if (uneCarte.SesFigures[1].X == (lesCoMoyens[i][0]) - 1) {
|
|
|
|
|
if (uneCarte.SesFigures[1].Y == (lesCoMoyens[i][1]) - 1) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|