From 4c517951a0cefe5a2a8d298177ae18d0f877a009 Mon Sep 17 00:00:00 2001 From: yasevret Date: Sat, 13 Feb 2021 14:34:07 +0100 Subject: [PATCH] Ajout Mode de Jeu Solo 3*3 --- SwichGIT/src/js/main.js | 109 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 107 insertions(+), 2 deletions(-) diff --git a/SwichGIT/src/js/main.js b/SwichGIT/src/js/main.js index 87a56c8..bba64b7 100644 --- a/SwichGIT/src/js/main.js +++ b/SwichGIT/src/js/main.js @@ -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 = [];