You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
3.9 KiB
88 lines
3.9 KiB
<html>
|
|
<head>
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<script src="selecteur.js"></script>
|
|
Votre score est : <h1 id="points"></h1>
|
|
</br>
|
|
<?php
|
|
$database = new SQLite3("data.db");
|
|
if(stristr($_GET['mode'], "p") === FALSE)
|
|
{
|
|
$sql='select score, player from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].' and score=(select min(score) from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].')';
|
|
}
|
|
else
|
|
{
|
|
$sql='select score, player from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].' and score=(select max(score) from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].')';
|
|
}
|
|
|
|
$result = $database->query($sql);
|
|
$a=$result->fetchArray();
|
|
|
|
if($a==false)
|
|
{
|
|
echo "Vous avez le premier score de ce mode de jeu.";
|
|
}
|
|
else
|
|
{
|
|
$phrase="Le record est ".$a[0].", tenu par ".$a["player"];
|
|
while ($row = $result->fetchArray()) {
|
|
$phrase=$phrase.", ".$row["player"];
|
|
}
|
|
echo $phrase;
|
|
}
|
|
?>
|
|
</br>
|
|
<?php
|
|
if($_GET['pseudo']!="")
|
|
{
|
|
if(stristr($_GET['mode'], "p") === FALSE) // vérification du mode pour afficher le score le plus grand ou le plus petit (- de temps = + de score)
|
|
{ //il n'y a pas "p" dans le mode, donc on cherche le plus haut score
|
|
$sqlScore='select max(score) from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].' and player="'.$_GET['pseudo'].'"';
|
|
}
|
|
else
|
|
{ // on est en points, donc on cherche le temps le plus faible
|
|
$sqlScore='select min(score) from score where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"].' and player="'.$_GET['pseudo'].'"';
|
|
}
|
|
$result = $database->query($sqlScore); // on prend le meilleur score du joueur
|
|
$data = $result->fetchArray()[0];
|
|
|
|
if($data==null) // Le joueur n'a pas encore de score enregistré
|
|
{
|
|
echo "Ceci est votre première partie dans ce mode de jeu.";
|
|
|
|
$sql='select count(*) from game where game_mode="'.$_GET['mode'].'" and difficulty="'.$_GET['diff'].'" and dots_amount='.$_COOKIE["dotsAmount"].' and pause='.$_COOKIE["pause"];
|
|
$result = $database->query($sql);
|
|
|
|
if($result->fetchArray()[0]==0) // Si le mode de jeu 'nest pas déjà dans la base, on l'ajoute
|
|
{
|
|
$sql='insert into game values("'.$_GET['diff'].'","'.$_GET['mode'].'","---",'.$_COOKIE["dotsAmount"].','.$_COOKIE["pause"].')';
|
|
}
|
|
|
|
$sql='insert into score values("'.$_GET['pseudo'].'","'.$_GET['diff'].'","'.$_GET['mode'].'",'.$_COOKIE["dotsAmount"].','.$_COOKIE["pause"].',date("now"),'.$_GET['pts'].')';
|
|
$database->query($sql); // enregistrement du score du joueur
|
|
}
|
|
else // Le joueur a un score enregistré, vérification s'il dépasse son record
|
|
{
|
|
$result = $database->query($sqlScore)->fetchArray()[0];
|
|
//Si le joueur a un meilleur score (selon le critère du mode), mise à jour
|
|
if(($data<$_GET['pts'] && stristr($_GET['mode'], "p") === FALSE) || ($data>$_GET['pts'] && stristr($_GET['mode'], "p") !== FALSE))
|
|
{
|
|
$sql="update score set score=".$_GET['pts'].",date=date('now') where player='".$_GET['pseudo']."' and game_mode='".$_GET['mode']."' and difficulty='".$_GET['diff']."' and dots_amount=".$_COOKIE["dotsAmount"]." and pause=".$_COOKIE["pause"];
|
|
$database->query($sql);
|
|
|
|
$result=$data;
|
|
|
|
}
|
|
echo "Votre record est ".$result;
|
|
}
|
|
}
|
|
?>
|
|
<script>
|
|
document.getElementById("points").innerHTML = get['pts'];
|
|
</script>
|
|
</body>
|
|
</html>
|