diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index 284bbb59..c2173666 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -373,6 +373,16 @@ class PartieGateway ) ); } + public function quitQueue(string $mailUtilisateur,int $idPartie){ + $query = "DELETE FROM Participer + WHERE utilisateur = :mailUtilisateur + AND partie = :idPartie"; + $this->con->executeQuery($query, array( + "mailUtilisateur" => array($mailUtilisateur, SQLITE3_TEXT), + "idPartie" => array($idPartie, SQLITE3_INTEGER) + ) + ); + } public function showAll(): void { $query = "SELECT * FROM Partie"; diff --git a/WEB/Controller/UserController.php b/WEB/Controller/UserController.php index fa0b8f12..5b6b71b3 100644 --- a/WEB/Controller/UserController.php +++ b/WEB/Controller/UserController.php @@ -64,6 +64,9 @@ class UserController case "endGame": $this->endGame(); break; + case "quitQueue": + $this->quitQueue(); + break; default: $error = "Action non valide"; require($rep . $vues['erreur']); @@ -372,4 +375,18 @@ class UserController require($rep . $vues['erreur']); } } + public function quitQueue(){ + try { + global $rep, $vues, $error; + $model = new UserModel(); + $idPartie = $_SESSION['idPartie']; + $utilisateur = $_SESSION['utilisateur']; + $model->quitQueue($utilisateur->getEmail(), $idPartie); + require ($rep . $vues['lobby']); + } + catch (Exception $e) { + $error = $e->getMessage(); + require($rep . $vues['erreur']); + } + } } \ No newline at end of file diff --git a/WEB/Model/UserModel.php b/WEB/Model/UserModel.php index e1269e15..0065e0bf 100644 --- a/WEB/Model/UserModel.php +++ b/WEB/Model/UserModel.php @@ -248,4 +248,10 @@ class UserModel $this->partie_gateway->majDateDebut($idPartie); $_SESSION['tpsMaxPartie'] = $this->calculTpsMaXPartie($idPartie); } + public function quitQueue(string $mailUtilisateur, int $idPartie) { + $this->partie_gateway->quitQueue($mailUtilisateur, $idPartie); + if ($this->partie_gateway->getPlayerNumber($idPartie) == 0){ + $this->partie_gateway->delete($idPartie); + } + } } \ No newline at end of file diff --git a/WEB/View/src/pages/Multijoueur/FileAttente.php b/WEB/View/src/pages/Multijoueur/FileAttente.php index 6047c3e1..6a86005b 100644 --- a/WEB/View/src/pages/Multijoueur/FileAttente.php +++ b/WEB/View/src/pages/Multijoueur/FileAttente.php @@ -31,6 +31,11 @@
+

SCRIPT

RUSH

diff --git a/WEB/View/src/pages/Multijoueur/Partie.php b/WEB/View/src/pages/Multijoueur/Partie.php index 8f42fdb8..c27c7d04 100644 --- a/WEB/View/src/pages/Multijoueur/Partie.php +++ b/WEB/View/src/pages/Multijoueur/Partie.php @@ -26,7 +26,7 @@
- home
diff --git a/WEB/View/src/pages/Multijoueur/Queue.php b/WEB/View/src/pages/Multijoueur/Queue.php deleted file mode 100644 index 8ac60ced..00000000 --- a/WEB/View/src/pages/Multijoueur/Queue.php +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - Scripted - - - - - - Queuing - - Confirmer - \ No newline at end of file