From 6da53ff4bcb28872214c176a43191fdbd251610d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Tue, 17 Jan 2023 12:36:29 +0100 Subject: [PATCH 1/8] Correction de bug : sauvegarde du code en Multi --- Controller/ResoudreGateway.php | 8 ++++++++ Model/UserModel.php | 6 ++---- View/src/JS/dashboard.js | 6 +----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Controller/ResoudreGateway.php b/Controller/ResoudreGateway.php index 2d9ab802..11ced673 100644 --- a/Controller/ResoudreGateway.php +++ b/Controller/ResoudreGateway.php @@ -367,4 +367,12 @@ class ResoudreGateway "classement" => array($playerNumberPerGame, SQLITE3_INTEGER))); } + public function cleanCodeAfterGame(int $idPartie) { + $query = "UPDATE Resoudre + SET code=:code + WHERE partie=:partie"; + $this->con->executeQuery($query, array( + "partie" => array($idPartie, SQLITE3_INTEGER), + "code" => array('', SQLITE3_TEXT))); + } } \ No newline at end of file diff --git a/Model/UserModel.php b/Model/UserModel.php index 7239e266..bab3c204 100644 --- a/Model/UserModel.php +++ b/Model/UserModel.php @@ -205,10 +205,7 @@ class UserModel $points = 0; $result = $this->resoudre_gateway->getAllByPartieAndUtilisateur($mailUtilisateur, $idPartie); foreach ($result as $row){ - if ($row['temps'] == 0){ - $points += 0; - } - else if ($row['ended'] == 0){ + if ($row['temps'] == 0 || $row['ended'] == 0){ $points += 0; } else if ($row['classement'] == 1){ @@ -261,6 +258,7 @@ class UserModel return true; } public function endGame(int $idPartie) { + $this->resoudre_gateway->cleanCodeAfterGame($idPartie); $this->partie_gateway->endGame($idPartie); } diff --git a/View/src/JS/dashboard.js b/View/src/JS/dashboard.js index 7c17b11b..7feb7fa7 100644 --- a/View/src/JS/dashboard.js +++ b/View/src/JS/dashboard.js @@ -33,11 +33,7 @@ interval: 1 }, axisY: { - title: "Point", - titleFontColor: "#6D78AD", - lineColor: "#6D78AD", - gridThickness: 0, - lineThickness: 1, + title: "Point" }, legend: { verticalAlign: "top", From 6ba30e5e8e2448ba90202b4b722ce3218694f6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Tue, 17 Jan 2023 13:27:14 +0100 Subject: [PATCH 2/8] test --- Model/UserModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/UserModel.php b/Model/UserModel.php index bab3c204..5027869b 100644 --- a/Model/UserModel.php +++ b/Model/UserModel.php @@ -206,7 +206,7 @@ class UserModel $result = $this->resoudre_gateway->getAllByPartieAndUtilisateur($mailUtilisateur, $idPartie); foreach ($result as $row){ if ($row['temps'] == 0 || $row['ended'] == 0){ - $points += 0; + $points += 1000; } else if ($row['classement'] == 1){ $points += $this->enigme_gateway->findById($row['enigme'])[0]->getPoints(); From 86e2e9bb9be6caa93700a7f9815ce3f5af32db8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Tue, 17 Jan 2023 13:32:12 +0100 Subject: [PATCH 3/8] test --- Model/UserModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Model/UserModel.php b/Model/UserModel.php index 5027869b..523c013e 100644 --- a/Model/UserModel.php +++ b/Model/UserModel.php @@ -202,7 +202,7 @@ class UserModel public function getPointsAtTheEnd(string $mailUtilisateur, int $idPartie) : int{ global $playerNumberPerGame; - $points = 0; + $points = 10; $result = $this->resoudre_gateway->getAllByPartieAndUtilisateur($mailUtilisateur, $idPartie); foreach ($result as $row){ if ($row['temps'] == 0 || $row['ended'] == 0){ From c512e87a0df1085df7e89408d1be66ece1591148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Tue, 17 Jan 2023 13:48:24 +0100 Subject: [PATCH 4/8] =?UTF-8?q?Correction=20de=20bug=20dans=20le=20calcul?= =?UTF-8?q?=20des=20pints=20en=20cas=20d'=C3=A9nigme=20passer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controller/ResoudreGateway.php | 12 +++++++++--- Model/UserModel.php | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Controller/ResoudreGateway.php b/Controller/ResoudreGateway.php index 11ced673..a41a6b0a 100644 --- a/Controller/ResoudreGateway.php +++ b/Controller/ResoudreGateway.php @@ -342,28 +342,34 @@ class ResoudreGateway $query = "UPDATE Resoudre SET ended=:ended WHERE utilisateur=:utilisateur - AND partie=:partie"; + AND partie=:partie + AND enigme=:enigme"; $this->con->executeQuery($query, array( "utilisateur" => array($mailUtilisateur, SQLITE3_TEXT), "partie" => array($idPartie, SQLITE3_INTEGER), + "enigme" => array($idEnigme, SQLITE3_INTEGER), "ended" => array(1, SQLITE3_INTEGER))); $query = "UPDATE Resoudre SET temps=:temps WHERE utilisateur=:utilisateur - AND partie=:partie"; + AND partie=:partie + AND enigme=:enigme"; $this->con->executeQuery($query, array( "utilisateur" => array($mailUtilisateur, SQLITE3_TEXT), "partie" => array($idPartie, SQLITE3_INTEGER), + "enigme" => array($idEnigme, SQLITE3_INTEGER), "temps" => array(null, SQLITE3_NULL))); $query = "UPDATE Resoudre SET classement=:classement WHERE utilisateur=:utilisateur - AND partie=:partie"; + AND partie=:partie + AND enigme=:enigme"; $this->con->executeQuery($query, array( "utilisateur" => array($mailUtilisateur, SQLITE3_TEXT), "partie" => array($idPartie, SQLITE3_INTEGER), + "enigme" => array($idEnigme, SQLITE3_INTEGER), "classement" => array($playerNumberPerGame, SQLITE3_INTEGER))); } diff --git a/Model/UserModel.php b/Model/UserModel.php index 523c013e..bab3c204 100644 --- a/Model/UserModel.php +++ b/Model/UserModel.php @@ -202,11 +202,11 @@ class UserModel public function getPointsAtTheEnd(string $mailUtilisateur, int $idPartie) : int{ global $playerNumberPerGame; - $points = 10; + $points = 0; $result = $this->resoudre_gateway->getAllByPartieAndUtilisateur($mailUtilisateur, $idPartie); foreach ($result as $row){ if ($row['temps'] == 0 || $row['ended'] == 0){ - $points += 1000; + $points += 0; } else if ($row['classement'] == 1){ $points += $this->enigme_gateway->findById($row['enigme'])[0]->getPoints(); From 8e609c13d7f56c246c5e4ea39bab068d80613cc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Tue, 17 Jan 2023 14:02:49 +0100 Subject: [PATCH 5/8] Maj des droit d'admin --- Controller/AdminController.php | 6 ++++++ Controller/UserController.php | 36 ---------------------------------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/Controller/AdminController.php b/Controller/AdminController.php index 8b7c1538..25220977 100644 --- a/Controller/AdminController.php +++ b/Controller/AdminController.php @@ -122,6 +122,12 @@ class AdminController extends UserController case "goToDashboard": $this->goToDashboard(); break; + case "getPlayersPseudo": + $this->getPlayersPseudo(); + break; + case "getDashboardInfo": + $this->getDashboardInfo(); + break; case "report": $this->report(); break; diff --git a/Controller/UserController.php b/Controller/UserController.php index d8443173..ecf0c7a1 100644 --- a/Controller/UserController.php +++ b/Controller/UserController.php @@ -79,12 +79,6 @@ class UserController case "getPlayersPseudo": $this->getPlayersPseudo(); break; - case "getPlayersEmail": - $this->getPlayersEmail(); - break; - case "getPlayerScore": - $this->getPlayerScore(); - break; case "getDashboardInfo": $this->getDashboardInfo(); break; @@ -466,36 +460,6 @@ class UserController require($rep . $vues['erreur']); } } - public function getPlayersEmail(){ - try { - global $rep, $vues, $error; - $model = new UserModel(); - $idPartie = $_SESSION['idPartie']; - $lesJoueurs = $model->getLesJoueurs($idPartie); - $lesJoueurs = json_encode($lesJoueurs); - echo $lesJoueurs; - } - catch (Exception $e) { - $error = $e->getMessage(); - require($rep . $vues['erreur']); - } - } - public function getPlayerScore(){ - try { - global $rep, $vues, $error; - $model = new UserModel(); - $idPartie = $_SESSION['idPartie']; - $pseudo = $_POST['pseudo']; - $mailUtilisateur = $model->getMailFromPseudo($pseudo); - $score = $model->getPlayerScore($mailUtilisateur, $idPartie); - $score = json_encode($score); - echo $score; - } - catch (Exception $e) { - $error = $e->getMessage(); - require($rep . $vues['erreur']); - } - } public function getDashboardInfo(){ try { global $rep, $vues, $error; From bf75e94ff77beca7ec09897b835ac214346e6fcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Tue, 17 Jan 2023 14:07:48 +0100 Subject: [PATCH 6/8] Style dashboard --- View/src/JS/dashboard.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/View/src/JS/dashboard.js b/View/src/JS/dashboard.js index 7feb7fa7..c2f90868 100644 --- a/View/src/JS/dashboard.js +++ b/View/src/JS/dashboard.js @@ -33,7 +33,9 @@ interval: 1 }, axisY: { - title: "Point" + title: "Point", + gridThickness: 0, + lineThickness: 1, }, legend: { verticalAlign: "top", From dd915c7f4c2052449a0919a4f9ae662a851dbedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Tue, 17 Jan 2023 15:02:05 +0100 Subject: [PATCH 7/8] Orthographe --- View/src/pages/Multijoueur/LobbyEnd.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/View/src/pages/Multijoueur/LobbyEnd.php b/View/src/pages/Multijoueur/LobbyEnd.php index b657d694..1628fa5f 100644 --- a/View/src/pages/Multijoueur/LobbyEnd.php +++ b/View/src/pages/Multijoueur/LobbyEnd.php @@ -18,7 +18,7 @@
-

Vous avez terminer toute les énimges.

+

Vous avez terminé toutes les énigmes.

Votre score est de : points.

Temps restant avant la fin de la partie :

Date: Tue, 17 Jan 2023 15:48:05 +0100 Subject: [PATCH 8/8] Orthographe --- View/src/pages/Multijoueur/GameEnd.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/View/src/pages/Multijoueur/GameEnd.php b/View/src/pages/Multijoueur/GameEnd.php index 35d2ecea..28f661c4 100644 --- a/View/src/pages/Multijoueur/GameEnd.php +++ b/View/src/pages/Multijoueur/GameEnd.php @@ -18,7 +18,7 @@

Partie Terminée !

Gagnant : getPseudo() ?>

-

Bien joué à tous la partie est finis, voici le classement :

+

Bien joué à tous la partie est fini, voici le classement :