From 5d9800309709dc413defa54a0b0de6c91be0be05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Wed, 11 Jan 2023 18:43:21 +0100 Subject: [PATCH] test --- WEB/Controller/UserController.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/WEB/Controller/UserController.php b/WEB/Controller/UserController.php index 310010b4..38215ab3 100644 --- a/WEB/Controller/UserController.php +++ b/WEB/Controller/UserController.php @@ -348,18 +348,25 @@ class UserController } } + public function goToGameEnd(){ + try { + global $rep, $vues, $error; + require ($rep . $vues['gameEnd']); + } catch (Exception $e) { + $error = $e->getMessage(); + require($rep . $vues['erreur']); + } + } + + // A appeler après avoir vérifié que la partie est finie public function endGame(){ try { global $rep, $vues, $error; $model = new UserModel(); $idPartie = $_SESSION['idPartie']; - $etat = $model->getEtatPartie($idPartie); - if ($etat != 2){ - throw new Exception("La partie n'est pas terminée"); - } $lesInfos = $model->getEndGameInfo($idPartie); $model->endGame($idPartie); - require ($rep . $vues['gameEnd']); + $this->goToGameEnd(); } catch (Exception $e) { $error = $e->getMessage();