Ajout d'une page de classement basique
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nigel Sheldon 2021-01-01 15:58:35 +01:00 committed by Gitea
parent dcb0eaf50d
commit 7c3999c5cd
4 changed files with 73 additions and 1 deletions

View File

@ -200,7 +200,9 @@ if (isset($SESS) && !(empty($SESS->values["connected"]) && empty($SESS->values['
case "alliances":
include("game/alliance.php");
break;
case "classement":
include("server/classement.php");
break;
case "rename":
include("game/rename.php");
break;

View File

@ -0,0 +1,29 @@
<?php
class Serveur
{
/**
* Constructeur
*
* @return void
* @access public
*/
public function Serveur()
{
return ;
}
public function classement($race = "all")
{
global $table_user;
$bdd = new BDD();
$get_race = "";
if ($race === "humain" || $race === "covenant") {
$get_race = "WHERE race = '$race'";
}
$classement = $bdd->query("SELECT id, pseudo, place_points, points, race FROM $table_user $get_race ORDER BY place_points ASC LIMIT 100;");
$bdd->deconnexion();
return $classement;
}
}

View File

@ -0,0 +1,19 @@
<?php
if (!defined('ONYX')) {
exit;
}
$titre = 'Classement';
$page = $p;
//Récupération et vérification de la race voulue ou définition d'une race par défaut
if (empty($_GET['r']) || (gpc('r') != 'humain' && gpc('r') != 'covenant')) {
$_GET['r'] = "global";
}
$race = gpc('r');
require_once("Class/serveur.php");
$serveur = new Serveur();
$classement = $serveur->classement($race);
$template->assign('joueurs', $classement);
$template->assign('user', $planete->id_user);
$template->assign('raceAff', $race);

View File

@ -0,0 +1,22 @@
{include file='game/header.tpl'}
<h2>Classement</h2>
Race : <a href="{$menu.classement}">Global</a> - <a href="{$menu.classement}&amp;r=humain">Humains</a> - <a href="{$menu.classement}&amp;r=covenant">Covenants</a>
<table>
<tr>
<th>Rang</th>
<th>Pseudo</th>
<th>Race</th>
<th>Points</th>
</tr>
{foreach from=$joueurs item=joueur}
<tr {if $joueur.id == $user}style="font-weight:bold;"{/if}>
<th>#{$joueur.place_points}</th>
<td>{$joueur.pseudo}</td>
<td>{$joueur.race}</td>
<td>{$joueur.points}</td>
</tr>
{/foreach}
</table>
{include file='game/footer.tpl'}