Création de la fonction remplacer les cartes lors de la selection

Golfier
Yannis 4 years ago
parent 9100686038
commit 1a774532df

@ -22,26 +22,6 @@ class Carte {
//lien clicable //lien clicable
this.link = document.createElement('a'); this.link = document.createElement('a');
this.link.id = this.identifiant; this.link.id = this.identifiant;
//fonction de selection
/*this.link.onclick = function selectioncarte() {
window.alert(this.getFigureCreuse)
window.alert(this.getFigureCreuse)
var macarte = this.id;
var lacarte = "card" + macarte;
if (document.getElementById(lacarte).style.boxShadow != "") {
var pos = carteselect.indexOf(this.getIdentifiant);
carteselect.splice(pos, 1);
document.getElementById(lacarte).style.boxShadow = "";
}
else {
if (carteselect.length < 5) {
carteselect.push(this.getIdentifiant);
document.getElementById(lacarte).style.boxShadow = "0 0 1vw red, 0 0 1vw red";
}
else
window.alert("Bonjour !");
}
};*/
//div carte //div carte
var divconteneur = document.createElement('div'); var divconteneur = document.createElement('div');
@ -121,7 +101,6 @@ class Carte {
get getFigureCreuse() { get getFigureCreuse() {
return this.FigCreuse; return this.FigCreuse;
} }
} }
class Figure { class Figure {
@ -190,11 +169,9 @@ class Figure {
} }
} }
} }
get getHTML() { get getHTML() {
return this.CodeHTML; return this.CodeHTML;
} }
get getX() { get getX() {
return this.X; return this.X;
} }
@ -275,6 +252,9 @@ function journuit() {
mode = mode + 1; mode = mode + 1;
} }
//===================================================================================
//FONCTION GESTION DE GAME
function lancerpartie() { function lancerpartie() {
document.getElementById("pageAccueil").style.visibility = "hidden"; document.getElementById("pageAccueil").style.visibility = "hidden";
creePartie(); creePartie();
@ -286,6 +266,17 @@ function retour() {
document.getElementById("pageGame").style.visibility = "hidden"; document.getElementById("pageGame").style.visibility = "hidden";
} }
function rechargerGAME() {
while (document.getElementById("containcards").firstElementChild != null) {
document.getElementById("containcards").firstElementChild.remove();
}
for (var i = 0; i < deckPartie.length; i++) {
document.getElementById("containcards").appendChild(deckPartie[i].getHTML);
}
}
function creePartie() { function creePartie() {
deckPartie = []; deckPartie = [];
carteselect = []; carteselect = [];
@ -302,32 +293,22 @@ function creePartie() {
} }
} }
function CarteToMatrice(idcarte) { function changerlesCartes() {
var laDivEnfantCarte = document.getElementById(idcarte).firstElementChild; while (carteselect.length != 0) {
var cols = 3; remplacerLaCarte(carteselect[0]);
var rows = 4; carteselect.shift();
var myMatrice = new Array();
for (var i = 0; i < cols; i++) {
myMatrice[i] = new Array();
for (var j = 0; j < rows; j++) {
myMatrice[i][j] = 0;
} }
} rechargerGAME();
for (var i = 0; i < laDivEnfantCarte.childNodes.length; i++) { }
function remplacerLaCarte(uneCarte) {
pos = deckPartie.indexOf(uneCarte);
var newCarte = new Carte(pos + 1);
deckPartie[pos] = newCarte;
}
if (laDivEnfantCarte.childNodes[i].childNodes.length != 0) { //====================================================================================
if (laDivEnfantCarte.childNodes[i].childNodes[0].firstChild.className == "anneau") {
myMatrice[i % 3][Math.floor(i / 3)] = 2;
}
if (laDivEnfantCarte.childNodes[i].childNodes[0].firstChild.className == "rond") {
myMatrice[i % 3][Math.floor(i / 3)] = 1;
}
}
}
return myMatrice;
}
function getRandom(min, max) { function getRandom(min, max) {
return Math.round(Math.random() * (max - min) + min) return Math.round(Math.random() * (max - min) + min)
@ -361,22 +342,34 @@ function creaMatrice(row, column) {
return myMatrice; return myMatrice;
} }
//=================================================================================
//FONCTION DE TEST => permet de tester des fonctionnalité via un bouton //FONCTION DE TEST => permet de tester des fonctionnalité via un bouton
function test() {
if (carteselect.length < 2) { function test() {
window.alert("Selection trop petite"); if (carteselect.length == 0) {
window.alert("Selection Vide");
return;
} else if (carteselect.length < 2) {
window.alert("Selection Trop Petite");
return; return;
} else { }/*
else {
var Code = comparaisonDeCarte(carteselect[0], carteselect[1]); var Code = comparaisonDeCarte(carteselect[0], carteselect[1]);
window.alert(Code); window.alert(Code);
}*/
else {
changerlesCartes();
} }
}
//==============================================================================================================================
//FONCTION POUR LISTE
}
//================================================================================================================================
function comparaisonDeCarte(CarteMere, CarteFille) { function comparaisonDeCarte(CarteMere, CarteFille) {
var Code = 0; var Code = 0;
if (CarteMere == null) { if (CarteMere == null) {
@ -408,6 +401,9 @@ function comparaisonDeCarte(CarteMere, CarteFille) {
function ChoisirPseudo() { function ChoisirPseudo() {
let nom = localStorage.getItem('nom'); let nom = localStorage.getItem('nom');
if (nom == null) { if (nom == null) {
@ -417,6 +413,7 @@ function ChoisirPseudo() {
}; };
function EnvoyerNouveauNom() { function EnvoyerNouveauNom() {
let pseudo = document.getElementById('inputpseudo').value; let pseudo = document.getElementById('inputpseudo').value;
localStorage.setItem('nom', pseudo); localStorage.setItem('nom', pseudo);
document.location.reload(true); document.location.reload(true);
@ -458,8 +455,3 @@ function ajouterplayer(event){
} }
*/ */

Loading…
Cancel
Save