102 lines
No EOL
2.7 KiB
PHP
102 lines
No EOL
2.7 KiB
PHP
<h1>Classement général</h1>
|
|
<br/>
|
|
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Nom</th>
|
|
<th>Prénom</th>
|
|
<th>Parties jouées</th>
|
|
<th>Total points</th>
|
|
<th>Moyenne de points</th>
|
|
<th>Rang</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
//On commence par inclure les fichiers nécessaire
|
|
require_once "dao/point_manager.php";
|
|
require_once "dao/bdd.php";
|
|
require_once "metier/ranker.php";
|
|
require_once "metier/sort_manager.php";
|
|
require_once "metier/user.php";
|
|
|
|
//On récupère d'abord tous les joueurs
|
|
$players = point_manager::getAllPlayer();
|
|
|
|
//On créer une variable de stockage
|
|
$storage = array();
|
|
$i = 0;
|
|
|
|
//On charge toutes les données
|
|
foreach ($players as $player)
|
|
{
|
|
$args = array();
|
|
$args["login"] = $player["login"];
|
|
$storage[$i] = new ranker("global", $args);
|
|
$i++;
|
|
}
|
|
|
|
//On trie le tableau selon le nombre de points totals
|
|
usort($storage, "sort_manager::pointsort");
|
|
|
|
|
|
//Affichage finale
|
|
$i = 1;
|
|
|
|
foreach ($storage as $rank)
|
|
{
|
|
//Si la personne n'a joué à aucun jeu, on passe à l'itération suivante
|
|
if ($rank->getNbGame() == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (isset($_SESSION["user"]))
|
|
{
|
|
$user = $_SESSION["user"];
|
|
|
|
if ($user->getLogin() == $rank->getUser()->getLogin())
|
|
{
|
|
echo '<tr class="selected">';
|
|
} else
|
|
{
|
|
echo '<tr>';
|
|
}
|
|
} else
|
|
{
|
|
echo '<tr>';
|
|
}
|
|
|
|
echo "<td>";
|
|
echo $rank->getUser()->getNom();
|
|
echo "</td>";
|
|
echo "<td>";
|
|
echo $rank->getUser()->getPrenom();
|
|
echo '</td>';
|
|
echo "<td>";
|
|
echo $rank->getNbGame();
|
|
echo '</td>';
|
|
echo "<td>";
|
|
echo floor($rank->getPoint());
|
|
echo '</td>';
|
|
echo "<td>";
|
|
echo floor($rank->getPoint() / $rank->getNbGame());
|
|
echo '</td>';
|
|
echo "<td>";
|
|
echo $i;
|
|
echo '</td>';
|
|
echo '</tr>';
|
|
$i++;
|
|
}
|
|
?>
|
|
</tbody>
|
|
</table>
|
|
<br/>
|
|
<br/>
|
|
|
|
<form class="center_item" method="post" action="index.php">
|
|
<fieldset>
|
|
<button type="button" onclick="javascript:navigate('index.php?page=rank')">Retour</button>
|
|
</fieldset>
|
|
</form>
|