From 5ebc49153d7755eafac767983182c1715e7d3b69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Wed, 11 Jan 2023 19:20:23 +0100 Subject: [PATCH] test --- WEB/Controller/ResoudreGateway.php | 19 +++++++++++++++++++ WEB/Controller/UserController.php | 1 - WEB/Model/UserModel.php | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/WEB/Controller/ResoudreGateway.php b/WEB/Controller/ResoudreGateway.php index 6554a9b1..4c28ed7e 100644 --- a/WEB/Controller/ResoudreGateway.php +++ b/WEB/Controller/ResoudreGateway.php @@ -144,6 +144,25 @@ class ResoudreGateway return $results[0]['ended']; } } + public function checkEnigmeIsEndedInPartie(string $mailUtilisateur, int $enigmeId, int $idPartie){ + $query="SELECT * FROM Resoudre + WHERE utilisateur=:utilisateur + AND enigme=:enigme + AND partie=:partie"; + $this->con->executeQuery($query, array( + "utilisateur" => array($mailUtilisateur, SQLITE3_TEXT), + "enigme" => array($enigmeId, SQLITE3_INTEGER), + "partie" => array($idPartie, SQLITE3_INTEGER))); + $results=$this->con->getResults(); + if(empty($results)) + { + return false; + } + else + { + return $results[0]['ended']; + } + } public function checkPartieIsAlreadyCreate(int $enigmeId) : bool{ $query="SELECT * FROM Resoudre diff --git a/WEB/Controller/UserController.php b/WEB/Controller/UserController.php index 6bc67d6e..6bc8b6fa 100644 --- a/WEB/Controller/UserController.php +++ b/WEB/Controller/UserController.php @@ -249,7 +249,6 @@ class UserController $lastIndex = $model->getLastIndex($idPartie); if ($lastIndex != 0 && $index == $lastIndex + 1) { if ($model->checkGameIsEnd($idPartie)) { - echo" end"; $this->endGame(); return; } diff --git a/WEB/Model/UserModel.php b/WEB/Model/UserModel.php index bf7f19ff..9bf24411 100644 --- a/WEB/Model/UserModel.php +++ b/WEB/Model/UserModel.php @@ -219,7 +219,7 @@ class UserModel $lesIdEnigmes = $this->partie_gateway->getLesIdEnigmes($idPartie); foreach ($lesMailJoueurs as $mail){ foreach ($lesIdEnigmes as $idEnigme){ - if ($this->resoudre_gateway->checkEnigmeIsEnded($mail, $idEnigme) == false){ + if ($this->resoudre_gateway->checkEnigmeIsEndedInPartie($mail, $idEnigme, $idPartie) == false){ return false; } }