From cba09a47db19fe68859c313c2f35d8f5e89f216a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Thu, 12 Jan 2023 18:22:48 +0100 Subject: [PATCH] =?UTF-8?q?Quitter=20la=20partie=20pendant=20l'attente=20+?= =?UTF-8?q?=20Quitter=20la=20partie=20pendant=20une=20=C3=A9nigme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WEB/Controller/PartieGateway.php | 10 ++++++++++ WEB/Controller/UserController.php | 17 +++++++++++++++++ WEB/Model/UserModel.php | 6 ++++++ WEB/View/src/pages/Multijoueur/FileAttente.php | 5 +++++ WEB/View/src/pages/Multijoueur/Partie.php | 2 +- WEB/View/src/pages/Multijoueur/Queue.php | 16 ---------------- 6 files changed, 39 insertions(+), 17 deletions(-) delete mode 100644 WEB/View/src/pages/Multijoueur/Queue.php 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