From c2217039c195192b957c638d6ae8fb82d5aae14d Mon Sep 17 00:00:00 2001 From: "yvan.calatayud" Date: Wed, 22 Nov 2023 18:01:32 +0100 Subject: [PATCH] fix : score if player not connected --- Website/controllers/ControllerUser.php | 28 ++++++++++++-------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/Website/controllers/ControllerUser.php b/Website/controllers/ControllerUser.php index 1901dc0..07aaf83 100644 --- a/Website/controllers/ControllerUser.php +++ b/Website/controllers/ControllerUser.php @@ -282,17 +282,13 @@ class ControllerUser 'idplayer' => $_SESSION["idPlayerConnected"], 'maxscore' => $_SESSION["Score"] ]; - // var_dump($jouer); - // var_dump($this->mdPlayer->verifyJouer($jouer)); - // var_dump($this->mdPlayer->getMaxScoreByPlayerAndChapter($jouer)); - // var_dump($jouer['maxscore']); - // var_dump($jouer['maxscore'] <= $this->mdPlayer->getMaxScoreByPlayerAndChapter($jouer)); - // var_dump($jouer['maxscore'] >= $this->mdPlayer->getMaxScoreByPlayerAndChapter($jouer)); - - if ($this->mdPlayer->verifyJouer($jouer) == null) { - $this->mdPlayer->addJouer($jouer); - } else if ($jouer['maxscore'] <= $this->mdPlayer->getMaxScoreByPlayerAndChapter($jouer)) { - $this->mdPlayer->updateJouer($jouer); + + if($_SESSION["idPlayerConnected"] != null){ + if ($this->mdPlayer->verifyJouer($jouer) == null) { + $this->mdPlayer->addJouer($jouer); + } else if ($jouer['maxscore'] <= $this->mdPlayer->getMaxScoreByPlayerAndChapter($jouer)) { + $this->mdPlayer->updateJouer($jouer); + } } echo $this->twig->render($this->vues["viewScore"], [ @@ -344,10 +340,12 @@ class ControllerUser 'maxscore' => $_SESSION["Score"] ]; - if ($this->mdPlayer->verifyJouer($jouer) == null) { - $this->mdPlayer->addJouer($jouer); - } else if ($jouer['maxscore'] <= $this->mdPlayer->getMaxScoreByPlayerAndChapter($jouer)) { - $this->mdPlayer->updateJouer($jouer); + if($_SESSION["idPlayerConnected"] != null){ + if ($this->mdPlayer->verifyJouer($jouer) == null) { + $this->mdPlayer->addJouer($jouer); + } else if ($jouer['maxscore'] <= $this->mdPlayer->getMaxScoreByPlayerAndChapter($jouer)) { + $this->mdPlayer->updateJouer($jouer); + } } echo $this->twig->render($this->vues["viewScore"], [