@ -16,27 +16,133 @@ var selectionMode = 0;
var selectionDiemension = 0 ;
var allModeFrench = [ "Match à Point" , "Mode Timer" , "Infini" , "Bac" , "MultiJoueur" ] ; // Défini tout les modes de Jeu en français
var allModeEngl = [ "Point Match" , "Timer mode" , "Infini" , "Bac" , "MultiPlayer" ] ; // Défini tout les modes de Jeu en Anglais
var tab2 = [ ] ;
var modelangue = false ;
var offreSWISH = false ;
var carteselectPos = [ ] ;
var lesPoints = 0 ; //Points du Joueur1
function majSizeCard ( column ) {
var newTailleOrdi = column * 3.3 + 1 ;
var newTailleTablette = newTailleOrdi ;
var newTailleTablette = newTailleOrdi
document . documentElement . style . setProperty ( '--taille' , newTailleOrdi + "vw" ) ;
document . documentElement . style . setProperty ( '--tailleTablette' , newTailleTablette + "vw" ) ;
}
function lancerGameMulti ( ) {
creePartieClassique3 _4 ( ) ;
document . getElementById ( "pageAccueil" ) . style . visibility = "hidden" ;
//document.getElementById("PageLobbyMulti").style.visibility = "hidden";
document . getElementById ( "pageGame" ) . style . visibility = "visible" ;
document . getElementById ( "idGameMulti" ) . style . visibility = "visible" ;
document . getElementById ( "progressbar" ) . style . visibility = "hidden" ;
//Suprimer les paarties précédantes
/ *
$ ( document ) . ready ( function ( ) {
//alert("Clean bases")
$ ( "#div1" ) . load ( 'cleanBase.php' )
} ) ;
* /
//Créer les 16 lignes dans la base pour les 16 cartes de la partie
//Génère l'idPartie
//Envoyer les 16 cartes
listecartes = [ ] ;
for ( var i = 0 ; i < deckPartie . length ; i ++ ) {
var ajt = deckPartie [ i ] . getMatrice [ 0 ] + deckPartie [ i ] . getMatrice [ 1 ] + deckPartie [ i ] . getMatrice [ 2 ] ;
listecartes . push ( ajt ) ;
//console.log(ajt);
}
$ ( document ) . ready ( function ( ) {
var cartestables = listecartes ;
$ . ajax ( {
data : {
cartestables : cartestables
} ,
type : "post" ,
url : "envoyercartes.php" ,
success : function ( data ) {
console . log ( "====Les cartes ont été envoyés (lancerpartie)===" )
}
} ) ;
} ) ;
}
function ConvertInttoCarte ( ListeDesCartes ) {
//console.log("LC",ListeDesCartes);
if ( ListeDesCartes . length == 0 ) {
console . log ( "Vide" ) ;
}
var lescartes = [ ] ; //Liste des cartes
for ( let j = 0 ; j < ListeDesCartes . length ; j ++ ) {
var lesfigure = [ ] ; //Liste figures de la carte
//pb?
for ( let i = 0 ; i < ListeDesCartes [ j ] . length ; i ++ ) {
if ( ListeDesCartes [ j ] [ i ] == 1 ) {
var premierefigure = new Figure ( TypeFigure . Petit , FormeFigure . Rond , Math . floor ( i / 4 ) , ( i % 4 ) ) ;
lesfigure . push ( premierefigure ) ;
//console.log("cc1",j," ",i);
}
else if ( ListeDesCartes [ j ] [ i ] == 2 ) {
var deuxiemefigure = new Figure ( TypeFigure . Moyen , FormeFigure . Rond , Math . floor ( i / 4 ) , ( i % 4 ) ) ;
lesfigure . push ( deuxiemefigure ) ;
//console.log("cc2",j," ",i);
}
}
//pb?
var carte = new Carte ( lescartes . length , lesfigure , 4 , 3 ) ;
//console.log("MAMAN2",j," ",carte);
lescartes . push ( carte ) ;
}
//console.log("LC2",lescartes);
deckPartie = lescartes ;
afficherCartes ( deckPartie ) ;
console . log ( "--Conversion réussie--" ) ;
// console.log("CARTES SELECTS : ",carteselectPos);
reselectCartes ( ) ;
}
function reselectCartes ( ) {
if ( carteselectPos != [ ] && carteselectPos != null ) {
// console.log("cartesPOS: ",carteselectPos);
carteselectPos . forEach ( ( pos ) => {
var lacarte = "card" + pos ;
var numeroCarte = pos ;
//console.log("lacarte: ",lacarte);
//console.log(deckPartie[numeroCarte].get);
document . getElementById ( lacarte ) . style . boxShadow = "0 0 1vw red, 0 0 1vw red" ;
} ) ;
}
else {
for ( var i = 0 ; i < deckPartie . length ; i ++ ) {
var lacarte = "card" + i ;
var numeroCarte = i ;
//console.log("lacarte: ",lacarte);
//console.log(deckPartie[numeroCarte].get);
document . getElementById ( lacarte ) . style . boxShadow = "" ;
}
}
}
function rejoindreGameMulti ( ) {
creePartieClassique3 _4 ( ) ;
document . getElementById ( "pageAccueil" ) . style . visibility = "hidden" ;
//document.getElementById("PageLobbyMulti").style.visibility = "hidden";
document . getElementById ( "pageGame" ) . style . visibility = "visible" ;
document . getElementById ( "idGameMulti" ) . style . visibility = "visible" ;
document . getElementById ( "progressbar" ) . style . visibility = "hidden" ;
}
function modePrec ( ) {
if ( ! modelangue ) {
if ( selectionMode == 0 ) {
selectionMode = allModeFrench . length - 1 ;
}
selectionMode = allModeFrench . length - 1 ;
}
else {
selectionMode -= 1 ;
selectionMode -= 1 ;
}
document . getElementById ( "textmode" ) . textContent = "" + allModeFrench [ selectionMode ]
if ( allModeEngl [ selectionMode ] == "MultiPlayer" || allModeEngl [ selectionMode ] == "MultiJoueur" ) {
@ -47,10 +153,10 @@ function modePrec() {
}
else {
if ( selectionMode == 0 ) {
selectionMode = allModeEngl . length - 1 ;
}
selectionMode = allModeEngl . length - 1 ;
}
else {
selectionMode -= 1 ;
selectionMode -= 1 ;
}
document . getElementById ( "textmode" ) . textContent = "" + allModeEngl [ selectionMode ]
if ( allModeEngl [ selectionMode ] == "MultiJoueur" || allModeEngl [ selectionMode ] == "MultiPlayer" ) {
@ -60,7 +166,7 @@ function modePrec() {
}
}
}
/ * f u n c t i o n m o d e S u i v ( ) {
if ( selectionMode == allMode . length - 1 ) {
@ -81,29 +187,29 @@ function dimensionPrec() {
if ( ! modelangue ) {
if ( selectionMode == 0 ) {
selectionMode = allModeFrench . length - 1 ;
} else {
selectionMode -= 1 ;
}
document . getElementById ( "textmode" ) . textContent = "" + allModeFrench [ selectionMode ]
selectionMode = allModeFrench . length - 1 ;
} else {
selectionMode -= 1 ;
}
document . getElementById ( "textmode" ) . textContent = "" + allModeFrench [ selectionMode ]
}
else {
if ( selectionMode == 0 ) {
selectionMode = allModeEngl . length - 1 ;
} else {
selectionMode -= 1 ;
}
document . getElementById ( "textmode" ) . textContent = "" + allModeEngl [ selectionMode ]
selectionMode = allModeEngl . length - 1 ;
} else {
selectionMode -= 1 ;
}
document . getElementById ( "textmode" ) . textContent = "" + allModeEngl [ selectionMode ]
}
}
function modeSuiv ( ) {
if ( ! modelangue ) {
if ( selectionMode == allModeFrench . length - 1 ) {
selectionMode = 0 ;
selectionMode = 0 ;
} else {
selectionMode += 1 ;
selectionMode += 1 ;
}
document . getElementById ( "textmode" ) . textContent = "" + allModeFrench [ selectionMode ]
if ( allModeEngl [ selectionMode ] == "MultiPlayer" || allModeEngl [ selectionMode ] == "MultiJoueur" ) {
@ -114,9 +220,9 @@ function modeSuiv() {
}
else {
if ( selectionMode == allModeEngl . length - 1 ) {
selectionMode = 0 ;
selectionMode = 0 ;
} else {
selectionMode += 1 ;
selectionMode += 1 ;
}
document . getElementById ( "textmode" ) . textContent = "" + allModeEngl [ selectionMode ]
if ( allModeEngl [ selectionMode ] == "MultiJoueur" || allModeEngl [ selectionMode ] == "MultiPlayer" ) {
@ -125,7 +231,7 @@ function modeSuiv() {
affichageParamMulti ( 0 ) ;
}
}
}
function dimensionPrec ( ) {
@ -155,7 +261,15 @@ class Carte {
this . identifiant = id ;
this . row = nbRow ;
this . column = nbColumn ;
this . Matrice = creaMatrice ( nbRow , nbColumn ) ;
this . Matrice = creaMatriceVierge ( nbRow , nbColumn ) ;
for ( var i = 0 ; i < allFigure . length ; i ++ ) {
if ( allFigure [ i ] . type [ 0 ] == TypeFigure . Petit ) {
this . Matrice [ allFigure [ i ] . X ] [ allFigure [ i ] . Y ] += 1 ;
} else {
this . Matrice [ allFigure [ i ] . X ] [ allFigure [ i ] . Y ] += 2 ;
}
}
this . SesFigures = [ ] ;
for ( var i = 0 ; i < allFigure . length ; i ++ ) {
this . SesFigures . push ( allFigure [ i ] ) ;
@ -176,7 +290,7 @@ class Carte {
divcase . className = "item-form" ;
var ajoute = true ;
for ( var j = 0 ; j < this . SesFigures . length ; j ++ ) {
if ( i == this . SesFigures [ j ] . pos ) {
if ( i == this . SesFigures [ j ] . X + ( this . SesFigures [ j ] . Y * 3 ) ) {
try {
ajoute = false ;
var uneFigure = new Figure ( this . SesFigures [ j ] . type , this . SesFigures [ j ] . forme , this . SesFigures [ j ] . X , this . SesFigures [ j ] . Y ) ;
@ -196,24 +310,55 @@ class Carte {
this . link . onclick = function selectioncarte ( ) {
var macarte = this . id ;
var lacarte = "card" + macarte ;
for ( var i = 0 ; i < deckPartie . length ; i ++ ) {
if ( this . id == deckPartie [ i ] . identifiant ) {
var laCarte = deckPartie [ i ] ; //Carte liee avec le code HTML
if ( carteselectPos . includes ( i ) ) {
carteselectPos . splice ( carteselectPos . indexOf ( i ) , 1 ) ;
} else {
if ( carteselectPos . length < 5 ) {
carteselectPos . push ( i ) ;
}
}
}
}
//console.log("cartesPOS: ",carteselectPos);
var laCarte ;
for ( var i = 0 ; i < deckPartie . length ; i ++ ) {
if ( this . id == deckPartie [ i ] . identifiant ) {
laCarte = deckPartie [ i ] ; //Carte liee avec le code HTML
}
}
//cas où la carte a déjà été cliqué
if ( document . getElementById ( lacarte ) . style . boxShadow != "" ) {
var pos = carteselect . indexOf ( laCarte ) ;
carteselect . splice ( pos , 1 ) ;
document . getElementById ( lacarte ) . style . boxShadow = "" ;
}
//cas où la carte n'a pas déjà été cliqué
else {
if ( carteselect . length < 5 ) {
carteselect . push ( laCarte ) ;
document . getElementById ( lacarte ) . style . boxShadow = "0 0 1vw red, 0 0 1vw red" ;
}
else
window . alert ( "Selection Trop Grande !" ) ;
}
window . alert ( "5 max !" ) ;
} ;
// for( var i =0; i < carteselectPos.length;i++){
// carteselect=[];
// //var carte = tab2[1];
// //console.log(carteselectPos[i]);
// //carteselect.push(carte);
// console.log(tab2[carteselectPos[i]]);
// var slt = ConvertUneCarte(tab2[carteselectPos[i]]);
// console.log("C'est moi",slt.getMatrice);
// }
} ;
}
@ -309,12 +454,12 @@ class Figure {
case TypeFigure . Moyen :
var containInte = document . createElement ( 'div' ) ;
var formeInte = document . createElement ( 'div' ) ;
var formeInte = document . createElement ( 'div' ) ;
var containExte = document . createElement ( 'div' ) ;
var formeExte = document . createElement ( 'div' ) ;
var vidcontainer = document . createElement ( 'div' ) ;
vidcontainer . className = "containform3carte" ;
vidcontainer . className = "containform3carte" ;
formeExte . className = "formeexte" ;
formeExte . classList . add ( 'rondv2' ) ;
@ -324,7 +469,7 @@ class Figure {
formeInte . style . backgroundColor = "var(--lighttercia)" ;
formeExte . style . backgroundColor = "var(--colorbase)" ;
if ( this . couleur != null ) {
if ( this . couleur == CouleurFigure . Couleur1 ) {
formeExte . style . backgroundColor = "var(--colorbase)"
@ -568,7 +713,7 @@ class Figure {
case TypeFigure . Petit :
var containInte = document . createElement ( 'div' ) ;
var formeInte = document . createElement ( 'div' ) ;
var formeInte = document . createElement ( 'div' ) ;
var containExte = document . createElement ( 'div' ) ;
var formeExte = document . createElement ( 'div' ) ;
@ -583,7 +728,7 @@ class Figure {
formeInte . classList . add ( 'rondv2' ) ;
formeInte . style . backgroundColor = "var(--colorbase)" ;
if ( this . couleur != null ) {
if ( this . couleur == CouleurFigure . Couleur1 ) {
formeInte . style . backgroundColor = "var(--colorbase)" ;
@ -912,13 +1057,13 @@ function journuit() {
function lancerpartie ( ) {
lesPoints = 0 ;
goAide ( ) ;
document . getElementById ( "progressbar" ) . style . visibility = "hidden" ;
var ready = true ;
//fonction de creation de partie a changer en fonction du test voulu
if ( selectionMode == 0 ) {
goAide ( ) ;
if ( selectionDiemension == 0 ) {
creePartieClassique3 _4 ( ) ;
majSizeCard ( 3 ) ;
@ -936,12 +1081,13 @@ function lancerpartie() {
else {
window . alert ( "Oops, it seems that this mode is not yet available..." ) ;
}
ready = false ;
}
} else if ( selectionMode == 1 ) {
goAide ( ) ;
document . getElementById ( "progressbar" ) . style . visibility = "visible" ;
decompte ( ) ;
if ( selectionDiemension == 0 ) {
@ -958,6 +1104,7 @@ function lancerpartie() {
majSizeCard ( 2 ) ;
}
} else if ( selectionMode == 2 ) {
goAide ( ) ;
if ( selectionDiemension == 0 ) {
creePartieInfini ( 4 , 3 ) ;
majSizeCard ( 3 ) ;
@ -973,6 +1120,10 @@ function lancerpartie() {
}
} else if ( selectionMode == 3 ) {
bacASable ( ) ;
} else if ( selectionMode == 4 ) {
document . getElementById ( "pageAccueil" ) . style . visibility = "hidden" ;
//document.getElementById("PageLobbyMulti").style.visibility = "visible";
}
if ( ready ) {
document . getElementById ( "pageAccueil" ) . style . visibility = "hidden" ;
@ -997,11 +1148,7 @@ function rechargerGAME() {
function redistribuerPlateau ( ) {
lesPoints -= 5 ;
goAide ( ) ;
document . getElementById ( "affPoints" ) . textContent = 'Score : ' + lesPoints ;
while ( carteselect . length != 0 ) {
carteselect . shift ( ) ;
}
if ( selectionMode == 0 ) {
redistribuer ( ) ;
} else if ( selectionMode == 1 || selectionMode == 2 ) {
@ -1015,9 +1162,82 @@ function redistribuerPlateau() {
}
}
}
if ( selectionMode == 4 ) {
redistribuerMulti ( ) ;
}
afficherCartes ( deckPartie ) ;
}
function redistribuerMulti ( ) {
carteselect = [ ] ;
carteselectPos = [ ] ;
reselectCartes ( ) ;
deckPartie = [ ] ;
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 ] ) ) ;
}
//Envoyer les 16 cartes du plateau
listecartes = [ ] ;
var uneMatrice ;
var ajt ;
/ *
for ( var i = 0 ; i < deckPartie . length ; i ++ ) {
var ajt = deckPartie [ i ] . getMatrice [ 0 ] + deckPartie [ i ] . getMatrice [ 1 ] + deckPartie [ i ] . getMatrice [ 2 ] ;
listecartes . push ( ajt ) ;
console . log ( ajt ) ;
} * /
for ( var j = 0 ; j < deckPartie . length ; j ++ ) { //Pour toutes les cartes de deckPartie
uneMatrice = creaMatriceVierge ( deckPartie [ j ] . row , deckPartie [ j ] . column ) ; //Création d'une matrice vierge ( Tableau 2D avec que des 0)
for ( var i = 0 ; i < deckPartie [ j ] . SesFigures . length ; i ++ ) { //Pour chaque figure présente dans la carte
if ( deckPartie [ j ] . SesFigures [ i ] . type == TypeFigure . Petit ) { //Check de la taille de la figure et adaptation de la valeur dans la matrice
uneMatrice [ deckPartie [ j ] . SesFigures [ i ] . X ] [ deckPartie [ j ] . SesFigures [ i ] . Y ] = 1 ;
} else if ( deckPartie [ j ] . SesFigures [ i ] . type == TypeFigure . Moyen ) {
uneMatrice [ deckPartie [ j ] . SesFigures [ i ] . X ] [ deckPartie [ j ] . SesFigures [ i ] . Y ] = 2 ;
}
}
ajt = uneMatrice [ 0 ] + uneMatrice [ 1 ] + uneMatrice [ 2 ] ; //une fois matrice vierge complétée on transforme ça en data
listecartes . push ( ajt ) ;
//console.log(ajt);
}
//console.log("LISTE BUG2 ",listecartes);
$ ( document ) . ready ( function ( ) {
var cartestables = listecartes ;
$ . ajax ( {
data : {
cartestables : cartestables
} ,
type : "post" ,
url : "envoyercartes.php" ,
success : function ( data ) {
console . log ( "====Les cartes ont été envoyés (redistribuer)===" )
}
} ) ;
} ) ;
}
function redistribuer ( ) {
deckPartie = [ ] ;
for ( var i = 0 ; i < 16 ; i ++ ) {
@ -1297,7 +1517,154 @@ function creePartieInfini3_2(nbRow, nbColum) {
}
}
function MaFonction ( ) {
var copyText = document . getElementById ( "Monidpartie" ) ;
copyText . select ( ) ;
copyText . setSelectionRange ( 0 , 99999 ) ;
document . execCommand ( "copy" ) ;
}
function testerCartesMulti ( ) {
//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 ;
cpt = cpt + 20 * copie . length ;
lesPoints += carteselect . length ;
document . getElementById ( "affPoints" ) . textContent = 'Score : ' + lesPoints ;
var new2Cartes = changerlesCartesDeTasDeJeuMulti ( ) ;
}
}
if ( solution ) {
document . getElementById ( "affSolution" ) . textContent = 'Aucune solution trouvée...' ;
}
if ( ! solution ) {
document . getElementById ( "affSolution" ) . textContent = 'Assemblage de ' + copie . length + ' cartes trouvé ! Il reste encore ' + TasDuJEU . length + ' cartes !' ;
carteselectPos = [ ] ;
carteselect = [ ] ;
reselectCartes ( ) ;
}
}
/ * } c a t c h ( e ) {
window . alert ( e ) ;
} * /
//Envoyer les 16 cartes du plateau
listecartes = [ ] ;
var ajt ;
/ *
for ( var i = 0 ; i < deckPartie . length ; i ++ ) {
var ajt = deckPartie [ i ] . getMatrice [ 0 ] + deckPartie [ i ] . getMatrice [ 1 ] + deckPartie [ i ] . getMatrice [ 2 ] ;
listecartes . push ( ajt ) ;
console . log ( ajt ) ;
} * /
for ( var j = 0 ; j < deckPartie . length ; j ++ ) { //Pour toutes les cartes de deckPartie
var uneMatrice = creaMatriceVierge ( deckPartie [ j ] . row , deckPartie [ j ] . column ) ; //Création d'une matrice vierge ( Tableau 2D avec que des 0)
//CODE A RISQUE
for ( var i = 0 ; i < deckPartie [ j ] . SesFigures . length ; i ++ ) { //Pour chaque figure présente dans la carte
if ( deckPartie [ j ] . SesFigures [ i ] . type [ 0 ] == TypeFigure . Petit ) { //Check de la taille de la figure et adaptation de la valeur dans la matrice
uneMatrice [ deckPartie [ j ] . SesFigures [ i ] . X ] [ deckPartie [ j ] . SesFigures [ i ] . Y ] = 1 ;
} else if ( deckPartie [ j ] . SesFigures [ i ] . type [ 0 ] == TypeFigure . Moyen ) {
uneMatrice [ deckPartie [ j ] . SesFigures [ i ] . X ] [ deckPartie [ j ] . SesFigures [ i ] . Y ] = 2 ;
}
}
//
ajt = uneMatrice [ 0 ] + uneMatrice [ 1 ] + uneMatrice [ 2 ] ; //une fois matrice vierge complétée on transforme ça en data
listecartes . push ( ajt ) ;
//console.log(ajt);
}
//console.log("LISTE BUG1: ",listecartes);
$ ( document ) . ready ( function ( ) {
var cartestables = listecartes ;
$ . ajax ( {
data : {
cartestables : cartestables
} ,
type : "post" ,
url : "envoyercartes.php" ,
success : function ( data ) {
console . log ( "====Les cartes ont été envoyés (valider cartes)===" )
}
} ) ;
} ) ;
}
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 creePartieClassique3 _2 ( ) {
TasDuJEU = genererTouteslesCartes3 _2Possibles ( ) ;
deckPartie = [ ] ;
@ -1495,7 +1862,7 @@ function afficherCartes(Liste) {
document . getElementById ( "containcards" ) . firstElementChild . remove ( ) ;
}
for ( var i = 0 ; i < Liste . length ; i ++ ) {
document . getElementById ( "containcards" ) . appendChild ( Liste[ i ] . link ) ;
document . getElementById ( "containcards" ) . appendChild ( copieCarte( Liste[ i ] ) . link ) ;
}
}
@ -1757,7 +2124,7 @@ function chercherCombinaison() {
else {
window . alert ( "Combination with " + ( N + 2 ) + " cards found : " + recup ) ;
}
}
}
}
@ -1768,7 +2135,7 @@ function chercherCombinaison() {
else {
window . alert ( "Number of combination: " + Cptsolution ) ;
}
}
function testPertinent ( ) {
@ -2016,7 +2383,7 @@ function printCombinations(array, p) {
else {
window . alert ( "end test " + k + " cards" )
}
}
window . alert ( "nb combi :" + Cptsolution ) ;
@ -2049,7 +2416,7 @@ function testCombinaison(DeckTeste, combi, Cptsolution) {
else {
window . alert ( "Combination with " + ( DeckTeste . length ) + " cards found : " + combi ) ;
}
}
return Cptsolution ;
}
@ -2098,9 +2465,9 @@ function chercheCombi2() {
window . alert ( "Combinaison a 2 trouve: " + ( i + 1 ) + " " + ( i + j + 2 ) ) ;
}
else {
window . alert ( "Combination with 2 found: " + ( i + 1 ) + " " + ( i + j + 2 ) ) ;
window . alert ( "Combination with 2 found: " + ( i + 1 ) + " " + ( i + j + 2 ) ) ;
}
}
}
}
@ -2108,9 +2475,9 @@ function chercheCombi2() {
window . alert ( "Nombre de solution a 2 cartes : " + Cptsolution ) ;
}
else {
window . alert ( "Number of solutions with 2 cards : " + Cptsolution ) ;
window . alert ( "Number of solutions with 2 cards : " + Cptsolution ) ;
}
}
//=================================================================================
@ -2198,9 +2565,9 @@ function chercheCombi3() {
window . alert ( "Combinaison a 3 trouve: " + ( i + 1 ) + " " + ( i + j + 2 ) + " " + ( k + j + i + 3 ) ) ;
}
else {
window . alert ( "Combination with 3 found: " + ( i + 1 ) + " " + ( i + j + 2 ) + " " + ( k + j + i + 3 ) ) ;
window . alert ( "Combination with 3 found: " + ( i + 1 ) + " " + ( i + j + 2 ) + " " + ( k + j + i + 3 ) ) ;
}
}
goRefresh ( ) ;
}
@ -2213,15 +2580,15 @@ function chercheCombi3() {
else {
window . alert ( "No solution" ) ;
}
}
if ( ! modelangue ) {
window . alert ( "Nombre de solution a 3 cartes : " + Cptsolution ) ;
}
else {
window . alert ( "Number of solutions with 3 cards : " + Cptsolution ) ;
window . alert ( "Number of solutions with 3 cards : " + Cptsolution ) ;
}
}
//=============================================================================================
//Fonction pour refresh l'affichage
@ -2349,7 +2716,7 @@ function decompte() {
else {
window . alert ( "Game Over" ) ;
}
retour ( ) ;
window . location . reload ( ) ;
clearInterval ( itv ) ;
@ -2369,12 +2736,17 @@ function decompte() {
}
function testerLesCartes ( ) {
goAide ( ) ;
if ( selectionMode == 0 ) {
goAide ( ) ;
testPourJeuClassique ( ) ;
} else if ( selectionMode == 1 || selectionMode == 2 ) {
goAide ( ) ;
testPourJeuInfini ( ) ;
}
if ( selectionMode == 4 ) {
testerCartesMulti ( ) ;
}
}
@ -2387,7 +2759,7 @@ function testPourJeuInfini() {
else {
window . alert ( "Empty selection" ) ;
}
return ;
} else if ( carteselect . length < 2 ) {
if ( ! modelangue ) {
@ -2396,7 +2768,7 @@ function testPourJeuInfini() {
else {
window . alert ( "Selection Too Small" ) ;
}
return ;
} else {
var copie = [ ] ;
@ -2435,7 +2807,7 @@ function testPourJeuInfini() {
else {
document . getElementById ( "affSolution" ) . textContent = 'No solutions found...' ;
}
}
if ( ! solution ) {
if ( ! modelangue ) {
@ -2464,7 +2836,7 @@ function testPourJeuClassique() {
else {
window . alert ( "Selection Empty test for classic game" ) ;
}
return ;
} else if ( carteselect . length < 2 ) {
if ( ! modelangue ) {
@ -2473,7 +2845,7 @@ function testPourJeuClassique() {
else {
window . alert ( "Selection Too Small" ) ;
}
return ;
} else {
var copie = [ ] ;
@ -2502,11 +2874,11 @@ function testPourJeuClassique() {
}
if ( solution ) {
if ( ! modelangue ) {
document . getElementById ( "affSolution" ) . textContent = 'Aucune solution trouvée...' ;
}
else {
document . getElementById ( "affSolution" ) . textContent = 'No solutions found...' ;
}
document . getElementById ( "affSolution" ) . textContent = 'Aucune solution trouvée...' ;
}
else {
document . getElementById ( "affSolution" ) . textContent = 'No solutions found...' ;
}
}
if ( ! solution ) {
@ -2564,7 +2936,7 @@ function copieFigure(uneFigure) {
else {
window . alert ( "Before copying " + uneFigure . CodeHTML )
}
if ( uneFigure == null ) {
return null ;
}
@ -2574,7 +2946,7 @@ function copieFigure(uneFigure) {
else {
window . alert ( "I make the copy" ) ;
}
var copie = new Figure ( uneFigure . type , uneFigure . forme , uneFigure . X , uneFigure . Y ) ;
return copie ;
}
@ -2772,53 +3144,53 @@ function functionLange(){
//window.alert(modelangue);
console . log ( modelangue ) ;
if ( modelangue ) {
modelangue = false ;
modelangue = false ;
//MODE FRANCAIS =======
document . getElementById ( 'flag_top' ) . src = "imgs/flags/flag-france.png" ;
document . getElementById ( 'flag_top2' ) . src = "imgs/flags/flag-france.png" ;
document . getElementById ( 'textjouerr' ) . innerHTML = 'JOUER' ;
//Traduction classement
document . getElementById ( 'classementtxt' ) . textContent = 'Classement - solo' ;
document . getElementById ( 'premier' ) . textContent = '1er' ;
document . getElementById ( 'deuxieme' ) . textContent = '2e' ;
document . getElementById ( 'troisieme' ) . textContent = '3e' ;
//Traduction paramètres
document . getElementById ( 'SettingName' ) . textContent = 'Paramètres' ;
//Tradcution des règles
document . getElementById ( 'lesRegles' ) . textContent = 'Les Règles' ;
document . getElementById ( 'textRules' ) . textContent = 'Swish : Jeu de 60 cartes composé chacun de billes et de cerceaux, de 4 couleurs différentes possibles. 16 cartes sont posés sur une table et le joueur doit faire superposer des cartes de manière que chaque bille soit dans le cerceau de même couleur d’ une autre carte.' ;
document . getElementById ( "textmode" ) . textContent = "" + allModeFrench [ selectionMode ]
document . getElementById ( 'flag_top' ) . src = "imgs/flags/flag-france.png" ;
document . getElementById ( 'flag_top2' ) . src = "imgs/flags/flag-france.png" ;
document . getElementById ( 'textjouerr' ) . innerHTML = 'JOUER' ;
//Traduction classement
document . getElementById ( 'classementtxt' ) . textContent = 'Classement - solo' ;
document . getElementById ( 'premier' ) . textContent = '1er' ;
document . getElementById ( 'deuxieme' ) . textContent = '2e' ;
document . getElementById ( 'troisieme' ) . textContent = '3e' ;
//Traduction paramètres
document . getElementById ( 'SettingName' ) . textContent = 'Paramètres' ;
//Tradcution des règles
document . getElementById ( 'lesRegles' ) . textContent = 'Les Règles' ;
document . getElementById ( 'textRules' ) . textContent = 'Swish : Jeu de 60 cartes composé chacun de billes et de cerceaux, de 4 couleurs différentes possibles. 16 cartes sont posés sur une table et le joueur doit faire superposer des cartes de manière que chaque bille soit dans le cerceau de même couleur d’ une autre carte.' ;
document . getElementById ( "textmode" ) . textContent = "" + allModeFrench [ selectionMode ]
}
else {
modelangue = true ;
//MODE ANGLAIS ========
document . getElementById ( 'flag_top' ) . src = "imgs/flags/flag-uk.png" ;
document . getElementById ( 'flag_top2' ) . src = "imgs/flags/flag-uk.png" ;
document . getElementById ( 'textjouerr' ) . innerHTML = 'PLAY' ;
//Traduction classement
document . getElementById ( 'classementtxt' ) . textContent = 'Ranking - solo' ;
document . getElementById ( 'premier' ) . textContent = '1st' ;
document . getElementById ( 'deuxieme' ) . textContent = '2nd' ;
document . getElementById ( 'troisieme' ) . textContent = '3rd' ;
//Traduction paramètres
document . getElementById ( 'SettingName' ) . textContent = 'Settings' ;
//Traduction des règles
document . getElementById ( 'lesRegles' ) . textContent = 'The Rules' ;
document . getElementById ( 'textRules' ) . textContent = 'Swish : Set of 60 cards each composed of balls and hoops, 4 different colors possible. 16 cards are placed on a table and the player has to lay cards on top of each other in such a way that each ball is in the same color hoop as another card.'
document . getElementById ( "textmode" ) . textContent = "" + allModeEngl [ selectionMode ]
document . getElementById ( 'flag_top' ) . src = "imgs/flags/flag-uk.png" ;
document . getElementById ( 'flag_top2' ) . src = "imgs/flags/flag-uk.png" ;
document . getElementById ( 'textjouerr' ) . innerHTML = 'PLAY' ;
//Traduction classement
document . getElementById ( 'classementtxt' ) . textContent = 'Ranking - solo' ;
document . getElementById ( 'premier' ) . textContent = '1st' ;
document . getElementById ( 'deuxieme' ) . textContent = '2nd' ;
document . getElementById ( 'troisieme' ) . textContent = '3rd' ;
//Traduction paramètres
document . getElementById ( 'SettingName' ) . textContent = 'Settings' ;
//Traduction des règles
document . getElementById ( 'lesRegles' ) . textContent = 'The Rules' ;
document . getElementById ( 'textRules' ) . textContent = 'Swish : Set of 60 cards each composed of balls and hoops, 4 different colors possible. 16 cards are placed on a table and the player has to lay cards on top of each other in such a way that each ball is in the same color hoop as another card.'
document . getElementById ( "textmode" ) . textContent = "" + allModeEngl [ selectionMode ]
}
}