From fb503a7c1dcf930eed5afe9eed303defa6e1e5bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Garnier?= Date: Tue, 10 Jan 2023 15:42:32 +0100 Subject: [PATCH] Calcul et affichage du temps restant --- WEB/Controller/PartieGateway.php | 11 +++++++- WEB/Controller/UserController.php | 1 + WEB/Model/UserModel.php | 4 +++ WEB/View/src/pages/Multijoueur/GameEnd.php | 32 ++++++++++++++++++++-- 4 files changed, 45 insertions(+), 3 deletions(-) diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index 66cf0ff6..35d6f795 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -319,7 +319,16 @@ class PartieGateway $results = $this->con->getResults(); $row = $results[0]; return $row['enigme']; - + } + public function getDateDebut($idPartie) : DateTime{ + $query = "SELECT dateDebut FROM Partie WHERE id = :idPartie"; + $this->con->executeQuery($query, array( + "idPartie" => array($idPartie, SQLITE3_INTEGER) + ) + ); + $results = $this->con->getResults(); + $date = new DateTime ($results[0]['dateDebut']); + return $date; } public function showAll(): void { diff --git a/WEB/Controller/UserController.php b/WEB/Controller/UserController.php index 18030c2f..f61d6912 100644 --- a/WEB/Controller/UserController.php +++ b/WEB/Controller/UserController.php @@ -243,6 +243,7 @@ class UserController $index = $_GET['index']; $lastIndex = $model->getLastIndex($idPartie); if($lastIndex != 0 && $index == $lastIndex + 1){ + $dateDebut = $model->getDateDebut($idPartie); require($rep . $vues['gameEnd']); } else{ diff --git a/WEB/Model/UserModel.php b/WEB/Model/UserModel.php index dca96fc1..09d2f6e5 100644 --- a/WEB/Model/UserModel.php +++ b/WEB/Model/UserModel.php @@ -147,4 +147,8 @@ class UserModel public function getLastOrdre() :int { return $this->enigme_gateway->getLastOrdre(); } + + public function getDateDebut($idPartie) : DateTime{ + return $this->partie_gateway->getDateDebut($idPartie); + } } \ No newline at end of file diff --git a/WEB/View/src/pages/Multijoueur/GameEnd.php b/WEB/View/src/pages/Multijoueur/GameEnd.php index dfd8cafc..a3974740 100644 --- a/WEB/View/src/pages/Multijoueur/GameEnd.php +++ b/WEB/View/src/pages/Multijoueur/GameEnd.php @@ -19,11 +19,39 @@

Vous avez terminer toute les énimges.

-

Temps restant avant la fin de la partie :


-

+

Temps restant avant la fin de la partie :

+ modify('+'. $_SESSION['tpsMaxPartie'] .'minutes'); + $now = new DateTime(); + $interval = $now->diff($end_time); + $remaining_seconds = $interval->days * 24 * 60 * 60 + $interval->h * 60 * 60 + $interval->i * 60 + $interval->s; + ?> +
+