Première version du Jeu Classique de Swich 60 cartes

master
yasevret 4 years ago
parent 437023ec09
commit 28b0a5a92f

@ -76,9 +76,9 @@
<div class="Mode_Forme">
<div class="titre">
<h3>Mode Forme</h3>
</div>
</div>
@ -146,7 +146,7 @@
<div id="pageGame">
<div class="menuhaut">
<div id="Redistribution">
<a onclick="creePartieInfini()" id="relancerbtn">
<a onclick="redistribuer()" id="relancerbtn">
<div id="contourbuttonvalider">
<div class="bouttonvalider">
<h1 id="textjouer2">RELANCER</h1>
@ -155,7 +155,7 @@
</a>
</div>
<div id="Redistribution2">
<a id="relancerbtn" onclick="test()">
<a id="relancerbtn" onclick="testPourJeuClassique()">
<div id="contourbuttonvalider">
<div class="bouttonvalider2">
<h1 id="btnvalider2">VALIDER</h1>

@ -50,7 +50,7 @@ class Carte {
divconteneur.appendChild(this.SesFigures[j].CodeHTML);
} catch (e) {
window.alert(this.SesFigures[j].type.length).length
}
}
}
}
if (ajouté) {
@ -63,8 +63,11 @@ class Carte {
this.link.onclick = function selectioncarte() {
var macarte = this.id;
var lacarte = "card" + macarte;
var laCarte = deckPartie[this.id - 1]; //Carte liée avec le code HTML
for (var i = 0; i < deckPartie.length; i++) {
if (this.id == deckPartie[i].identifiant) {
var laCarte = deckPartie[i];//Carte liée avec le code HTML
}
}
if (document.getElementById(lacarte).style.boxShadow != "") {
var pos = carteselect.indexOf(laCarte);
carteselect.splice(pos, 1);
@ -307,7 +310,7 @@ function journuit() {
function lancerpartie() {
document.getElementById("pageAccueil").style.visibility = "hidden";
//fonction de création de partie à changer en fonction du test voulu
genererTouteslesCartes3_4Possibles();
creePartieClassique();
document.getElementById("pageGame").style.visibility = "visible";
}
@ -324,46 +327,80 @@ function rechargerGAME() {
document.getElementById("containcards").appendChild(deckPartie[i].getHTML);
}
}
function redistribuer() {
deckPartie = [];
for (var i = 0; i < 16; i++) {
var index = getRandom(0, TasDuJEU.length - 1)
var déjàPrésente = false;//Permet de savoir si la carte est déjà dans la liste
for (var j = 0; j < deckPartie.length; j++) {
if (TasDuJEU[index].identifiant == deckPartie[j].identifiant) {
déjàPrésente = true;
}
}
while (déjàPrésente == true) {
index = getRandom(0, TasDuJEU.length - 1)
déjàPrésente = false;//Permet de savoir si la carte est déjà dans la liste
for (var j = 0; j < deckPartie.length; j++) {
if (TasDuJEU[index].identifiant == deckPartie[j].identifiant) {
déjàPrésente = true;
}
}
}
deckPartie.push(copieCarte(TasDuJEU[index]));
}
afficherCartes(deckPartie);
}
//================================================================================================================================================================
//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(new Array(TypeFigure.Petit), FormeFigure.Rond, k, j));
if (i != k + 3 * j) {
if (k == 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);
if (!doublonInterdit(uneCarte)) {
var unDoublon = copieCarte(uneCarte);
unDoublon.identifiant += 1;
deckPartie.push(unDoublon);
}
deckPartie.push(uneCarte);
} else if (i != 2 && i != 5 && i != 8 && i != 11) {
for (var j = 0; j < 2; j++) {
for (var i = 0; i < 12; i++) {
var AllFigure = [];
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);
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);
deckPartie.push(unDoublon);
}
}
}
}
for (var j = 0; j < 2; j++) {
for (var i = 0; i < 12; i++) {
var AllFigure = [];
AllFigure.push(new Figure(new Array(TypeFigure.Petit), FormeFigure.Rond, 1, j));
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);
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 uneCarte = new Carte(deckPartie.length + 1, AllFigure);
if (!doublonInterdit(uneCarte)) {
var unDoublon = copieCarte(uneCarte);
unDoublon.identifiant += 1;
deckPartie.push(unDoublon);
}
deckPartie.push(uneCarte);
var unDoublon = new Carte(deckPartie.length + 1, AllFigure);
deckPartie.push(unDoublon);
}
}
}
}
}
afficherCartes(deckPartie)
return deckPartie;
}
@ -394,6 +431,22 @@ function creePartieClassique() {
}
for (var i = 0; i < 16; i++) {
var index = getRandom(0, TasDuJEU.length - 1)
var déjàPrésente = false;//Permet de savoir si la carte est déjà dans la liste
for (var j = 0; j < deckPartie.length; j++) {
if (TasDuJEU[index].identifiant == deckPartie[j].identifiant) {
déjàPrésente = true;
}
}
while (déjàPrésente == true) {
index = getRandom(0, TasDuJEU.length - 1)
déjàPrésente = false;//Permet de savoir si la carte est déjà dans la liste
for (var j = 0; j < deckPartie.length; j++) {
if (TasDuJEU[index].identifiant == deckPartie[j].identifiant) {
déjàPrésente = true;
}
}
}
deckPartie.push(copieCarte(TasDuJEU[index]));
}
afficherCartes(deckPartie);
@ -432,7 +485,41 @@ function creePartieInfini() {
}
//========================================================================================================================================================
//Changer les cartes
//Changer les cartes et Changer les cartes de Tas de jeu
function changerlesCartesDeTasDeJeu() {
while (carteselect.length != 0) {
var unIndex = TasDuJEU.indexOf(carteselect[0]);
TasDuJEU.splice(unIndex, 1);
if (TasDuJEU.length > 16) {
var index2 = getRandom(0, TasDuJEU.length - 1)
var déjàPrésente = false;//Permet de savoir si la carte est déjà dans la liste
for (var j = 0; j < deckPartie.length; j++) {
if (TasDuJEU[index2].identifiant == deckPartie[j].identifiant) {
déjàPrésente = true;
}
}
while (déjàPrésente == true) {
index2 = getRandom(0, TasDuJEU.length - 1)
déjàPrésente = false;//Permet de savoir si la carte est déjà dans la liste
for (var j = 0; j < deckPartie.length; j++) {
if (TasDuJEU[index2].identifiant == deckPartie[j].identifiant) {
déjàPrésente = true;
}
}
}
unIndex = deckPartie.indexOf(carteselect[0]);
deckPartie[unIndex] = TasDuJEU[index2];
} else {
unIndex = deckPartie.indexOf(carteselect[0]);
deckPartie.splice(unIndex, 1);
}
carteselect.shift();
}
afficherCartes(deckPartie);
}
function changerlesCartes() {
while (carteselect.length != 0) {
@ -569,7 +656,7 @@ function chercheCombi2() {
}
if (!solution) {
Cptsolution++;
window.alert("Combinaison a 2 trouvé: " + (i+1) + " " + (i + j + 2));
window.alert("Combinaison a 2 trouvé: " + (i + 1) + " " + (i + j + 2));
}
}
}
@ -638,24 +725,21 @@ function chercheCombi3() {
//=================================================================================
//FONCTION DE TEST => permet de tester des fonctionnalité via le bouton VALIDER
function test() {
function testPourJeuInfini() {
try {
if (carteselect.length == 0) {
window.alert("Selection Vide");
return;
} else if (carteselect.length < 2) {
//window.alert("Selection Trop Petite");
var leCarte = copieCarte(carteselect[0]);
document.getElementById("containcards").appendChild(leCarte.link);
window.alert("Selection Trop Petite");
return;
} else {
var copie = [];
for (var i = 0; i < carteselect.length; i++) {
copie.push(carteselect[i]);
copie.push(copieCarte(carteselect[i]));
}
var tab = [];
tab = AssemblageARBRE(copieListeDeCarte(copie), carteselect[0]);
tab = AssemblageARBRE(copieListeDeCarte(copie), copieCarte(carteselect[0]));
var solution = true;
var tabCode = [];
for (var i = 0; i < tab.length; i++) {
@ -680,6 +764,47 @@ function test() {
}
}
//Fonction de test mias pour le jeu classique
function testPourJeuClassique() {
//try {
if (carteselect.length == 0) {
window.alert("Selection Vide test pour jeu classique");
return;
} else if (carteselect.length < 2) {
window.alert("Selection Trop Petite");
return;
} else {
var copie = [];
for (var i = 0; i < carteselect.length; i++) {
copie.push(copieCarte(carteselect[i]));
}
var tab = [];
tab = AssemblageARBRE(copie, copieCarte(carteselect[0]));
var solution = true;
var tabCode = [];
for (var i = 0; i < tab.length; i++) {
tabCode.push(tab[i].code);
}
for (var i = 0; i < tab.length; i++) {
if (tab[i].code == carteselect.length) {
solution = false;
changerlesCartesDeTasDeJeu();
}
}
if (solution) {
window.alert("Rien trouvé chef !!!");
}
if (!solution) {
window.alert("J'ai une solution chef !!!!");
}
window.alert(TasDuJEU.length)
}
/*} catch (e) {
window.alert(e);
}*/
}
//===================================================================================
//Function de copie diverse

Loading…
Cancel
Save