multi propre

master
theo 4 years ago
parent ff76f4de1b
commit faef66e02d

@ -712,14 +712,16 @@ require("ConnexionBDD.php");
<div id="idGameMulti"> <div id="idGameMulti">
<h2 class='php' id='ids'>Identifiant partie : <strong>$idpartie</strong></h2> <h2 class='php' id='ids'>Identifiant partie : <strong>$idpartie</strong></h2>
<script> <script>
//écriture dans la base
$(document).ready(function(){ $(document).ready(function(){
setInterval(function(){ setInterval(function(){
$("#ids").load('ActualiserIDPartie.php'); $("#ids").load('ActualiserIDPartie.php');
}, 1000); }, 500);
}); });
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
function helloWorld(){ function helloWorld(){
//lecture dans la base
tabcomplet=[]; tabcomplet=[];
var jar = []; var jar = [];
const xhr = new XMLHttpRequest(); const xhr = new XMLHttpRequest();
@ -762,7 +764,7 @@ require("ConnexionBDD.php");
} }
} }
} }
t = setInterval(helloWorld,2000); t = setInterval(helloWorld,550);
</script> </script>

@ -129,7 +129,7 @@ class Carte {
} }
} }
} }
console.log("cartesPOS: ",carteselectPos); //console.log("cartesPOS: ",carteselectPos);
var laCarte; var laCarte;
for (var i = 0; i < deckPartie.length; i++) { for (var i = 0; i < deckPartie.length; i++) {
if (this.id == deckPartie[i].identifiant) { if (this.id == deckPartie[i].identifiant) {
@ -439,7 +439,7 @@ function lancerGameMulti() {
for (var i = 0; i < deckPartie.length; i++) { for (var i = 0; i < deckPartie.length; i++) {
var ajt = deckPartie[i].getMatrice[0] + deckPartie[i].getMatrice[1] + deckPartie[i].getMatrice[2]; var ajt = deckPartie[i].getMatrice[0] + deckPartie[i].getMatrice[1] + deckPartie[i].getMatrice[2];
listecartes.push(ajt); listecartes.push(ajt);
console.log(ajt); //console.log(ajt);
} }
$(document).ready(function () { $(document).ready(function () {
@ -487,7 +487,7 @@ function convertCarteToData() {
ajt = uneMatrice[0] + '' + uneMatrice[1] + '' + uneMatrice[2];//une fois matrice vierge complétée on transforme ça en data ajt = uneMatrice[0] + '' + uneMatrice[1] + '' + uneMatrice[2];//une fois matrice vierge complétée on transforme ça en data
listecartes.push(ajt); listecartes.push(ajt);
console.log(ajt); //console.log(ajt);
} }
$(document).ready(function () { $(document).ready(function () {
@ -541,7 +541,7 @@ function ConvertUneCarte(carte){
function ConvertInttoCarte(ListeDesCartes){ function ConvertInttoCarte(ListeDesCartes){
console.log("LC",ListeDesCartes); //console.log("LC",ListeDesCartes);
if(ListeDesCartes.length==0){ if(ListeDesCartes.length==0){
console.log("Vide"); console.log("Vide");
} }
@ -555,21 +555,21 @@ function ConvertInttoCarte(ListeDesCartes){
if(ListeDesCartes[j][i]==1){ if(ListeDesCartes[j][i]==1){
var premierefigure= new Figure(TypeFigure.Petit,FormeFigure.Rond,Math.floor(i/4),(i%4)); var premierefigure= new Figure(TypeFigure.Petit,FormeFigure.Rond,Math.floor(i/4),(i%4));
lesfigure.push(premierefigure); lesfigure.push(premierefigure);
console.log("cc1",j," ",i); //console.log("cc1",j," ",i);
} }
else if(ListeDesCartes[j][i]==2){ else if(ListeDesCartes[j][i]==2){
var deuxiemefigure = new Figure(TypeFigure.Moyen,FormeFigure.Rond,Math.floor(i/4),(i%4)); var deuxiemefigure = new Figure(TypeFigure.Moyen,FormeFigure.Rond,Math.floor(i/4),(i%4));
lesfigure.push(deuxiemefigure); lesfigure.push(deuxiemefigure);
console.log("cc2",j," ",i); //console.log("cc2",j," ",i);
} }
} }
//pb? //pb?
var carte= new Carte(lescartes.length,lesfigure,4,3); var carte= new Carte(lescartes.length,lesfigure,4,3);
console.log("MAMAN2",j," ",carte); //console.log("MAMAN2",j," ",carte);
lescartes.push(carte); lescartes.push(carte);
} }
console.log("LC2",lescartes); //console.log("LC2",lescartes);
deckPartie = lescartes; deckPartie = lescartes;
afficherCartes(deckPartie); afficherCartes(deckPartie);
console.log("--Conversion réussie--"); console.log("--Conversion réussie--");
@ -583,8 +583,8 @@ function reselectCartes() {
carteselectPos.forEach((pos) => { carteselectPos.forEach((pos) => {
var lacarte = "card"+pos; var lacarte = "card"+pos;
var numeroCarte = pos; var numeroCarte = pos;
console.log("lacarte: ",lacarte); //console.log("lacarte: ",lacarte);
console.log(deckPartie[numeroCarte].get); //console.log(deckPartie[numeroCarte].get);
document.getElementById(lacarte).style.boxShadow = "0 0 1vw red, 0 0 1vw red"; document.getElementById(lacarte).style.boxShadow = "0 0 1vw red, 0 0 1vw red";
}); });
} }
@ -592,8 +592,8 @@ function reselectCartes() {
for (var i=0; i<deckPartie.length;i++) { for (var i=0; i<deckPartie.length;i++) {
var lacarte = "card"+i; var lacarte = "card"+i;
var numeroCarte = i; var numeroCarte = i;
console.log("lacarte: ",lacarte); //console.log("lacarte: ",lacarte);
console.log(deckPartie[numeroCarte].get); //console.log(deckPartie[numeroCarte].get);
document.getElementById(lacarte).style.boxShadow = ""; document.getElementById(lacarte).style.boxShadow = "";
} }
} }
@ -679,9 +679,9 @@ function redistribuerMulti() {
ajt = uneMatrice[0]+uneMatrice[1]+uneMatrice[2];//une fois matrice vierge complétée on transforme ça en data ajt = uneMatrice[0]+uneMatrice[1]+uneMatrice[2];//une fois matrice vierge complétée on transforme ça en data
listecartes.push(ajt); listecartes.push(ajt);
console.log(ajt); //console.log(ajt);
} }
console.log("LISTE BUG2 ",listecartes); //console.log("LISTE BUG2 ",listecartes);
$(document).ready(function () { $(document).ready(function () {
var cartestables = listecartes; var cartestables = listecartes;
@ -895,7 +895,57 @@ function changerlesCartesDeTasDeJeu() {
return new2cartes; return new2cartes;
} }
function changerlesCartesDeTasDeJeuMulti() {
var new2cartes = [];
// Pour toutes les cartes selectionnées
while (carteselectPos.length != 0) {
// //Enlever la carte dans le tas du jeu
// var unIndex = TasDuJEU.indexOf(carteselect[0]);
// TasDuJEU.splice(unIndex, 1);
//si il reste plus de 16 cartes
if (TasDuJEU.length > 16) {
//On prend une autre carte aléatoire dans tas du jeu
var index2 = 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[index2].identifiant == deckPartie[j].identifiant) {
// dejaPresente = true;
// }
// }
deckPartie[carteselectPos[0]]=TasDuJEU[index2];
TasDuJEU.splice(index2,1);
//on recommmence jusqu'à obtenri une carte pas dans le tas de jeu
// while (dejaPresente == true) {
// index2 = 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[index2].identifiant == deckPartie[j].identifiant) {
// dejaPresente = true;
// }
// }
// }
// unIndex = deckPartie.indexOf(carteselect[0]);
// deckPartie[unIndex] = TasDuJEU[index2];
// new2cartes.push(TasDuJEU[index2]);
} else {
// si il y a moins de 16 cartes on enlève juste
deckPartie.splice(carteselect[0],1);
// unIndex = deckPartie.indexOf(carteselect[0]);
// deckPartie.splice(unIndex, 1);
}
carteselectPos.shift();
carteselect.shift();
}
afficherCartes(deckPartie);
return new2cartes;
}
function changerlesCartes() { function changerlesCartes() {
while (carteselect.length != 0) { while (carteselect.length != 0) {
@ -966,7 +1016,7 @@ function creaMatriceVierge(row, column) {
myMatrice2[i][j] = 0; myMatrice2[i][j] = 0;
} }
} }
console.log("BUG1 ",myMatrice2); //console.log("BUG1 ",myMatrice2);
//var cartecopie = copieMatrice(myMatrice,myMatrice.length,myMatrice[0].length) //var cartecopie = copieMatrice(myMatrice,myMatrice.length,myMatrice[0].length)
return myMatrice2; return myMatrice2;
} }
@ -1335,13 +1385,14 @@ function testerCartesMulti() {
for (var i = 0; i < tab.length; i++) { for (var i = 0; i < tab.length; i++) {
tabCode.push(tab[i].code); tabCode.push(tab[i].code);
} }
for (var i = 0; i < tab.length; i++) { for (var i = 0; i < tab.length; i++) {
if (tab[i].code == carteselect.length) { if (tab[i].code == carteselect.length) {
solution = false; solution = false;
cpt = cpt + 20 * copie.length; cpt = cpt + 20 * copie.length;
lesPoints += carteselect.length; lesPoints += carteselect.length;
document.getElementById("affPoints").textContent = 'Score : ' + lesPoints; document.getElementById("affPoints").textContent = 'Score : ' + lesPoints;
var new2Cartes=changerlesCartesDeTasDeJeu(); var new2Cartes=changerlesCartesDeTasDeJeuMulti();
} }
} }
if (solution) { if (solution) {
@ -1385,7 +1436,7 @@ function testerCartesMulti() {
ajt = uneMatrice[0]+uneMatrice[1]+uneMatrice[2];//une fois matrice vierge complétée on transforme ça en data ajt = uneMatrice[0]+uneMatrice[1]+uneMatrice[2];//une fois matrice vierge complétée on transforme ça en data
listecartes.push(ajt); listecartes.push(ajt);
console.log(ajt); //console.log(ajt);
} }
//console.log("LISTE BUG1: ",listecartes); //console.log("LISTE BUG1: ",listecartes);

Binary file not shown.
Loading…
Cancel
Save