diff --git a/WEB/Controller/ResoudreGateway.php b/WEB/Controller/ResoudreGateway.php index 6b350325..1e1a3d02 100644 --- a/WEB/Controller/ResoudreGateway.php +++ b/WEB/Controller/ResoudreGateway.php @@ -282,4 +282,14 @@ class ResoudreGateway } return $results[0]['classement']; } + + public function getAllByPartieAndUtilisateur(string $mailUtilisateur, int $idPartie) : array{ + $query = "SELECT * FROM Resoudre + WHERE utilisateur=:utilisateur + AND partie=:partie"; + $this->con->executeQuery($query, array( + "utilisateur" => array($mailUtilisateur, SQLITE3_TEXT), + "partie" => array($idPartie, SQLITE3_INTEGER))); + $results=$this->con->getResults(); + } } \ No newline at end of file diff --git a/WEB/Controller/UserController.php b/WEB/Controller/UserController.php index ded2d137..7982ea95 100644 --- a/WEB/Controller/UserController.php +++ b/WEB/Controller/UserController.php @@ -244,6 +244,7 @@ class UserController $lastIndex = $model->getLastIndex($idPartie); if($lastIndex != 0 && $index == $lastIndex + 1){ $dateDebut = $model->getDateDebut($idPartie); + $points = $model->getPointsAtTheEnd($utilisateur->getEmail(), $idPartie); require($rep . $vues['gameEnd']); } else{ diff --git a/WEB/Model/UserModel.php b/WEB/Model/UserModel.php index e572f807..81e53437 100644 --- a/WEB/Model/UserModel.php +++ b/WEB/Model/UserModel.php @@ -173,4 +173,21 @@ class UserModel public function getDateDebut($idPartie) : DateTime{ return $this->partie_gateway->getDateDebut($idPartie); } + + public function getPointsAtTheEnd(string $mailUtilisateur, int $idPartie) : int{ + $points = 0; + $result = $this->resoudre_gateway->getAllByPartieAndUtilisateur($mailUtilisateur, $idPartie); + foreach ($result as $row){ + if ($row['classement'] == 1){ + $points += $this->enigme_gateway->findById($row['enigme'])[0]->getPoints(); + } + else if ($row['classement'] == 2){ + $points += $this->enigme_gateway->findById($row['enigme'])[0]->getPoints() * 0.75; + } + else{ + $points += $this->enigme_gateway->findById($row['enigme'])[0]->getPoints() * 0.5; + } + } + return $points; + } } \ 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 f09bd8af..73b7f5bc 100644 --- a/WEB/View/src/pages/Multijoueur/GameEnd.php +++ b/WEB/View/src/pages/Multijoueur/GameEnd.php @@ -19,9 +19,9 @@

Vous avez terminer toute les énimges.

+

Votre score est de : points.

Temps restant avant la fin de la partie :

modify('+'. $_SESSION['tpsMaxPartie'] .'seconds'); $now = new DateTime(); $interval = $now->diff($end_time);