// Pronostics des joueurs $pronostic = new Pronostic($db); $pronostic->jeu_id = $jeu->jeu_id; $stmtPronostics = $pronostic->litPronostics(); $listePronostics = $stmtPronostics->fetchAll(PDO::FETCH_ASSOC); $nbJoueurs = 0; for ($j = 0; $j < sizeof($listeJoueurs); $j++) { $joueur_id = $listeJoueurs[$j]["joueur_id"]; if ($listePronostics) { $prono = getPronoJoueur($listePronostics, $joueur_id); } if ($debug && isset($prono)) { echo "Joueur {$joueur_id} a le prono " . getPronostic($prono, 1) . " pour le premier match<br>\n"; } // Pas de pronostic ou alors pronostic vide (car effacé) if (!isset($prono) || isset($prono) && getPronostic($prono, 1) == "") { $nbJoueurs++; } } if ($nbJoueurs == 0) { $json["resultat"] = $jeu->bloque(); } else { $json["resultat"] = "Il manque " . $nbJoueurs . " pronostic(s)."; } } } else { $json["resultat"] = "Paramètre inconnu"; } } } else { $json["resultat"] = "Il manque des paramètres";
function MAJStatistiquesJeu($debug, $statistique, $resultats, $listeJoueurs, $pronostics) { $jeu_id = $statistique->jeu_id; $saison_id = $statistique->saison_id; if ($debug) { echo "MAJStatistiquesJournee : Saison id :" . $saison_id . ", Stat jeu :" . $jeu_id . "\n"; } // Purge la table des statistiques avec ce jeu if ($statistique->efface() != true) { return false; } // Si pas de résultat sur le premier match, on n'intègre pas ce jeu dans la table des statistiques ! if (sizeof($resultats) == 0 || getResultat($resultats, 1) == "") { return false; } // initialisation des variables $ListeresultatOk = array(); $NbMatchsJoues = array(); // Pour ce jeu, on va rechercher calculer la moyenne de tous les joueurs $meilleur = 0; $mauvais = 100; for ($j = 0; $j < sizeof($listeJoueurs); $j++) { $joueur = $listeJoueurs[$j]; $joueur_id = $joueur["joueur_id"]; $joueur_nom = $joueur["nom"]; $pronostic = getPronosticJoueur($joueur_id, $pronostics); $flash = $pronostic["flash"]; // Initialisation des bons résultats à 0 $ListeresultatOk[$j] = 0; // Initialisation du nombre de matchs joués à 0 $NbMatchsJoues[$j] = 0; // Pour ce joueur et ce jeu, on va lire tous les pronostics pour les comparer aux résultats for ($k = 1; $k <= 15; $k++) { // Résultat de ce match pour ce jeu $resultatJeu = getResultat($resultats, $k); // Pronostic du joueur pour ce match pour ce jeu $pronosticJeu = getPronostic($pronostic, $k); // Le résultat est bon ? on incrémente le nombre de résultat bon pour ce joueur et ce jeu $posresultat = isResultatBon($pronosticJeu, $resultatJeu); if ($posresultat) { $ListeresultatOk[$j] = $ListeresultatOk[$j] + 1; } // Le joueur a joué ce match ? on incrémente son nombre de match joués if ($pronosticJeu) { $NbMatchsJoues[$j] = $NbMatchsJoues[$j] + 1; } } if ($debug) { echo "Nombre de Matchs : " . $NbMatchsJoues[$j] . "\n"; } // Calcul de sa moyenne if ($NbMatchsJoues[$j]) { $moyenne = $ListeresultatOk[$j] / $NbMatchsJoues[$j] * 100; $moyenne = round($moyenne, 1); // Enregistrement en base de la moyenne de ce joueur pour ce jeu $statistique->joueur_id = $joueur_id; $statistique->valeur = $moyenne; $statistique->flash = $flash; $retour = $statistique->ajoute(); if ($debug) { echo "Statistique mis à jour avec la moyenne de " . $moyenne . "\n"; } //setMiseAJourStat($saison_id, $jeu_id, $joueur_id, $moyenne, $flash); //echo "<h2>Joueur:".$joueur_nom.", moyenne:".$moyenne."</h2>"; } } return true; }
if ($i == 7) { echo "<tr class='impaire' style='border-bottom:1px dotted blue'>"; } else { echo "<tr class='impaire' >"; } } else { echo "<tr>"; } // Retrouve si la colonne 1, 2 et 3 est pronostiqué par le joueur $jeuColonne1 = getPronosticEstJoue($pronostic, $i, '1'); $jeuColonne2 = getPronosticEstJoue($pronostic, $i, 'N'); $jeuColonne3 = getPronosticEstJoue($pronostic, $i, '2'); // Colonne 1 : Numéro du match echo "<td><img src='img/" . $i . ".png' alt='img/" . $i . "' /></td>\n"; // Colonne suivante : Equipe qui reçoit $pronosticOrdi = getPronostic($i); if ($pronosticOrdi == '1' or $pronosticOrdi == 'N') { echo "<td class=\"eqd pronostic\">" . $equiped . "</td>"; } else { echo "<td class=\"eqd\">" . $equiped . "</td>"; } // Colonne suivante : Les trois choix echo "<td class=\"choix\"><span id=\"vl" . $i . "c1\" class=\""; if ($jeuColonne1) { echo "choixs"; } else { echo "choix1"; } echo "\" onclick=\"Change('l" . $i . "c1','P');\" /></td>\n"; echo "<td class=\"choix\"><span id=\"vl" . $i . "c2\" class=\""; if ($jeuColonne2) {
$maxPassage = $maxPassage + 1; } // Jeu à 14 ou 15 matchs ? $nbMatchsDeCeJeu = getNbMatchsDeCeJeu($jeu); // echo "<div style=\"height:1.5cm\"> </div>"; $numjoueur = ($nbpassage - 1) * $nbColonneMax; // Affiche tous les matchs for ($i = 1; $i <= $nbMatchsDeCeJeu; $i++) { // Affichage du premier résultat des tous les joueurs, du deuxième résultat, du troisième, ... $nbJoueursQuiOntJoués = 0; $nbjoueurtraite = 0; for ($ii = $numjoueur; $ii < sizeof($listeJoueurs); $ii++) { $nbjoueurtraite = $nbjoueurtraite + 1; if (isset($ListepronosticJoueur[$ii])) { $pronostic = $ListepronosticJoueur[$ii]; $pronosticJeu = getPronostic($pronostic, $i); // Affichage du pronostic if ($pronosticJeu == "1") { echo $car . "<span style=\"font-size:0.2em;\"> </span>"; } else { if ($pronosticJeu == "N") { echo "<span style=\"font-size:0.2em;\"> </span>" . $car . "<span style=\"font-size:0.2em;\"> </span>"; } else { if ($pronosticJeu == "2") { echo "<span style=\"font-size:0.2em;\"> </span>" . $car . "<span style=\"font-size:0.2em;\"> </span>"; } else { echo "<span style=\"font-size:0.2em;\"> </span><span style=\"font-size:0.1em;\"> </span>"; } } } if ($nbjoueurtraite == $nbColonneMax) {