|
|
|
@ -22,26 +22,6 @@ class Carte {
|
|
|
|
|
//lien clicable
|
|
|
|
|
this.link = document.createElement('a');
|
|
|
|
|
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
|
|
|
|
|
var divconteneur = document.createElement('div');
|
|
|
|
@ -121,7 +101,6 @@ class Carte {
|
|
|
|
|
get getFigureCreuse() {
|
|
|
|
|
return this.FigCreuse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class Figure {
|
|
|
|
@ -190,11 +169,9 @@ class Figure {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get getHTML() {
|
|
|
|
|
return this.CodeHTML;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
get getX() {
|
|
|
|
|
return this.X;
|
|
|
|
|
}
|
|
|
|
@ -275,6 +252,9 @@ function journuit() {
|
|
|
|
|
mode = mode + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//===================================================================================
|
|
|
|
|
//FONCTION GESTION DE GAME
|
|
|
|
|
|
|
|
|
|
function lancerpartie() {
|
|
|
|
|
document.getElementById("pageAccueil").style.visibility = "hidden";
|
|
|
|
|
creePartie();
|
|
|
|
@ -286,6 +266,17 @@ function retour() {
|
|
|
|
|
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() {
|
|
|
|
|
deckPartie = [];
|
|
|
|
|
carteselect = [];
|
|
|
|
@ -302,32 +293,22 @@ function creePartie() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function CarteToMatrice(idcarte) {
|
|
|
|
|
var laDivEnfantCarte = document.getElementById(idcarte).firstElementChild;
|
|
|
|
|
var cols = 3;
|
|
|
|
|
var rows = 4;
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
function changerlesCartes() {
|
|
|
|
|
while (carteselect.length != 0) {
|
|
|
|
|
remplacerLaCarte(carteselect[0]);
|
|
|
|
|
carteselect.shift();
|
|
|
|
|
}
|
|
|
|
|
for (var i = 0; i < laDivEnfantCarte.childNodes.length; i++) {
|
|
|
|
|
rechargerGAME();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
return Math.round(Math.random() * (max - min) + min)
|
|
|
|
@ -361,22 +342,34 @@ function creaMatrice(row, column) {
|
|
|
|
|
return myMatrice;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//=================================================================================
|
|
|
|
|
//FONCTION DE TEST => permet de tester des fonctionnalité via un bouton
|
|
|
|
|
function test() {
|
|
|
|
|
|
|
|
|
|
if (carteselect.length < 2) {
|
|
|
|
|
window.alert("Selection trop petite");
|
|
|
|
|
function test() {
|
|
|
|
|
if (carteselect.length == 0) {
|
|
|
|
|
window.alert("Selection Vide");
|
|
|
|
|
return;
|
|
|
|
|
} else if (carteselect.length < 2) {
|
|
|
|
|
window.alert("Selection Trop Petite");
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
}/*
|
|
|
|
|
else {
|
|
|
|
|
var Code = comparaisonDeCarte(carteselect[0], carteselect[1]);
|
|
|
|
|
window.alert(Code);
|
|
|
|
|
}*/
|
|
|
|
|
else {
|
|
|
|
|
changerlesCartes();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//==============================================================================================================================
|
|
|
|
|
|
|
|
|
|
//FONCTION POUR LISTE
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//================================================================================================================================
|
|
|
|
|
|
|
|
|
|
function comparaisonDeCarte(CarteMere, CarteFille) {
|
|
|
|
|
var Code = 0;
|
|
|
|
|
if (CarteMere == null) {
|
|
|
|
@ -408,6 +401,9 @@ function comparaisonDeCarte(CarteMere, CarteFille) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ChoisirPseudo() {
|
|
|
|
|
let nom = localStorage.getItem('nom');
|
|
|
|
|
if (nom == null) {
|
|
|
|
@ -417,6 +413,7 @@ function ChoisirPseudo() {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function EnvoyerNouveauNom() {
|
|
|
|
|
|
|
|
|
|
let pseudo = document.getElementById('inputpseudo').value;
|
|
|
|
|
localStorage.setItem('nom', pseudo);
|
|
|
|
|
document.location.reload(true);
|
|
|
|
@ -458,8 +455,3 @@ function ajouterplayer(event){
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|