Correction de bug +
continuous-integration/drone/push Build is passing Details

checkUserIsInPartie
ServeurDeTest
Noé GARNIER 2 years ago
parent e2335a92e4
commit 9db6eaf7fd

@ -350,6 +350,18 @@ class PartieGateway
$this->con->executeQuery($query,array(
'partie' => array($idPartie,SQLITE3_INTEGER)));
}
public function checkUserIsInPartie(string $mailUtilisateur) : bool {
$query = "SELECT * FROM Participer WHERE utilisateur = :mailUtilisateur";
$this->con->executeQuery($query, array(
"mailUtilisateur" => array($mailUtilisateur, SQLITE3_TEXT)
)
);
$results = $this->con->getResults();
if(count($results) == 0 || $results == null){
return false;
}
return true;
}
public function showAll(): void
{
$query = "SELECT * FROM Partie";

@ -239,6 +239,9 @@ class UserController
global $rep, $vues, $error;
$model = new UserModel();
$utilisateur = $_SESSION['utilisateur'];
if ($model->checkUserIsInPartie($utilisateur->getEmail())){
throw new Exception("Vous êtes déjà dans une partie");
}
$idPartie = $model->addToQueue($utilisateur->getEmail());
$_SESSION['idPartie'] = $idPartie;
require($rep . $vues['queue']);
@ -279,7 +282,6 @@ class UserController
public function logout()
{
session_destroy();
// $_SESSION['role'] = 'visitor';
header('Location: index.php');
}

@ -230,4 +230,8 @@ class UserModel
public function endGame(int $idPartie) {
$this->partie_gateway->endGame($idPartie);
}
public function checkUserIsInPartie(string $mailUtilisateur) : bool{
return $this->partie_gateway->checkUserIsInPartie($mailUtilisateur);
}
}

@ -1,21 +0,0 @@
function displayWaiting(){
document.getElementById("waiting").innerHTML = "Waiting for Coders...";
document.getElementsByClassName("btn").style.display = "none"
}
function checkIsReady() {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://82.165.180.114/Scripted/WEB/index.php?action=waiting', true);
xhr.responseType = 'text';
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function () {
if (xhr.responseText == "1") {
window.location.href = 'http://82.165.180.114/Scripted/WEB/index.php?action=goToGame&idPartie=" . $idPartie . "&index=1"'
}
};
xhr.send(null);
}
function waiting(){
displayWaiting();
var countdownTimer = setInterval('checkIsReady()', 1000);
}

@ -14,7 +14,7 @@
</head>
<body class="m-5">
<a name="" id="" class="btn btn-primary" href="index.ph?action=goToHome" role="button">Retour</a>
<a name="" id="" class="btn btn-primary" href="index.php?action=goToHome" role="button">Retour</a>
<h1>Partie Terminée !</h1>
<h2>Gagnant : <?php echo $lesInfos[3]->getPseudo() ?></h2>
<p>Bien joué à tous la partie est finis, voici le classement :</p>

Loading…
Cancel
Save