Ajout Mode de Jeu Solo 3*3

master
yasevret 4 years ago
parent e124a591d8
commit 4c517951a0

@ -346,8 +346,7 @@ function lancerpartie() {
if (selectionDiemension == 0) {
creePartieClassique3_4();
} else if (selectionDiemension == 1) {
ready = false;
window.alert("Mode de Jeu indisponible pour le moment")
creePartieClassique3_3();
} else if (selectionDiemension == 2) {
ready = false;
window.alert("Mode de Jeu indisponible pour le moment")
@ -423,6 +422,112 @@ function redistribuer() {
//================================================================================================================================================================
//Fonction creations de game
function genererTouteslesCartes3_3Possibles() {
deckPartie = [];
carteselect = [];
while (document.getElementById("containcards").firstElementChild != null) {
document.getElementById("containcards").firstElementChild.remove();
}
for (var i = 1; i < 9; i++) {
var AllFigure = [];
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 0, 0));
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
var uneCarte = new Carte(deckPartie.length + 1, AllFigure, 3, 3);
deckPartie.push(uneCarte);
var AllFigure = [];
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 0, 0));
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
var uneCarte = new Carte(deckPartie.length + 1, AllFigure, 3, 3);
deckPartie.push(uneCarte);
}
for (var i = 0; i < 9; i++) {
if (i != 3 && Math.floor(i / 3) != 2) {
var AllFigure = [];
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 0, 1));
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
var uneCarte = new Carte(deckPartie.length + 1, AllFigure, 3, 3);
deckPartie.push(uneCarte);
var AllFigure = [];
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 0, 1));
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
var uneCarte = new Carte(deckPartie.length + 1, AllFigure, 3, 3);
deckPartie.push(uneCarte);
}
}
for (var i = 0; i < 9; i++) {
if (i != 1 && (i % 3) != 2) {
var AllFigure = [];
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 1, 0));
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
var uneCarte = new Carte(deckPartie.length + 1, AllFigure, 3, 3);
deckPartie.push(uneCarte);
var AllFigure = [];
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 1, 0));
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
var uneCarte = new Carte(deckPartie.length + 1, AllFigure, 3, 3);
deckPartie.push(uneCarte);
}
}
for (var i = 0; i < 4; i++) {
if (i != 2) {
var AllFigure = [];
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 1, 1));
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
var uneCarte = new Carte(deckPartie.length + 1, AllFigure, 3, 3);
deckPartie.push(uneCarte);
var AllFigure = [];
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 1, 1));
AllFigure.push(new Figure(new Array(TypeFigure.Moyen), FormeFigure.Rond, i % 3, Math.floor(i / 3)));
var uneCarte = new Carte(deckPartie.length + 1, AllFigure, 3, 3);
deckPartie.push(uneCarte);
}
}
return deckPartie;
}
function creePartieClassique3_3() {
TasDuJEU = genererTouteslesCartes3_3Possibles();
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)
var dejaPresente = false;//Permet de savoir si la carte est deja dans la liste
for (var j = 0; j < deckPartie.length; j++) {
if (TasDuJEU[index].identifiant == deckPartie[j].identifiant) {
dejaPresente = true;
}
}
while (dejaPresente == true) {
index = getRandom(0, TasDuJEU.length - 1)
dejaPresente = false;//Permet de savoir si la carte est deja dans la liste
for (var j = 0; j < deckPartie.length; j++) {
if (TasDuJEU[index].identifiant == deckPartie[j].identifiant) {
dejaPresente = true;
}
}
}
deckPartie.push(copieCarte(TasDuJEU[index]));
}
afficherCartes(deckPartie);
}
function genererTouteslesCartes3_4Possibles() {
deckPartie = [];
carteselect = [];

Loading…
Cancel
Save