diff --git a/WEB/Controller/PartieGateway.php b/WEB/Controller/PartieGateway.php index 1ecac2e6..15ec341f 100644 --- a/WEB/Controller/PartieGateway.php +++ b/WEB/Controller/PartieGateway.php @@ -302,6 +302,20 @@ class PartieGateway } return $lesJoueurs; } + + public function findAllEnigmeIdInPartie($idPartie){ + $query = "SELECT * FROM Contenir WHERE partie = :idPartie"; + $this->con->executeQuery($query, array( + "idPartie" => array($idPartie, SQLITE3_INTEGER) + ) + ); + $results = $this->con->getResults(); + $lesEnigmes = array(); + foreach ($results as $row){ + $lesEnigmes[] = $row['enigme']; + } + return $lesEnigmes; + } public function showAll(): void { $query = "SELECT * FROM Partie"; diff --git a/WEB/Controller/UserController.php b/WEB/Controller/UserController.php index b6f587fb..bb5ba418 100644 --- a/WEB/Controller/UserController.php +++ b/WEB/Controller/UserController.php @@ -190,20 +190,33 @@ class UserController $lesJoueurs = $model->getLesJoueurs($idPartie); if($etat == 1){ // header("Location: index.php?action=launchGame"); - header("Location: index.php?action=goToPresentation"); + $this->goToGame($idPartie); } else{ while ($etat == 0){ sleep(5); $etat = $model->getEtatPartie($idPartie); } - header("Location: index.php?action=goToPresentation"); + $this->goToGame($idPartie); } } catch (Exception $e) { $error = $e->getMessage(); require($rep . $vues['erreur']); } } + + public function goToGame($idPartie){ + try { + global $rep, $vues, $error; + $model = new UserModel(); + $utilisateur = $_SESSION['utilisateur']; + $enigme = $model->getEnigmebyPartieId($idPartie)[0]; + require($rep . $vues['partie']); + } catch (Exception $e) { + $error = $e->getMessage(); + require($rep . $vues['erreur']); + } + } public function launchGame(){ try { global $rep, $vues, $error; diff --git a/WEB/Model/UserModel.php b/WEB/Model/UserModel.php index de336288..5ad85d1a 100644 --- a/WEB/Model/UserModel.php +++ b/WEB/Model/UserModel.php @@ -24,37 +24,6 @@ class UserModel require($rep . $view['erreur']); } } - // public function addToQueue() - // { - // echo '1'; - // $utilisateur = $_SESSION['utilisateur']; - // if ($this->utilisateur_gateway->isAlreadyInqueue($utilisateur)) { - // var_dump($this->utilisateur_gateway->queueFilled()); - // if($this->utilisateur_gateway->queueFilled()) - // { - // header('Location: index.php?action=launchGame'); - // } - // return; - // } - // echo '2'; - // if (!$this->partie_gateway->partieInQueueExists()) { - // echo '3'; - // $tabEnigme = $this->enigme_gateway->findMultiEnigma(); - // $idNewPartie = $this->partie_gateway->findPartieMaxId(); - // $partie = $this->partie_gateway->creerPartieMulti($idNewPartie, $tabEnigme); - // } else { - // echo '4'; - // $idPartieInQueue = $this->partie_gateway->findPartieInQueue(); - // echo '5'; - // $tabEnigme = $this->enigme_gateway->findEnigmaFromPartie($idPartieInQueue); - // echo '6'; - // $partie = $this->partie_gateway->rejoindrePartieMulti($idPartieInQueue, $tabEnigme); - // echo '7'; - // } - // echo '8'; - // $this->utilisateur_gateway->addToQueue($utilisateur, $partie); - // } - public function addToQueue($mailUtilisateur) : array{ $idPartie=$this->partie_gateway->findPartieInQueue(); if ($idPartie == 0){ @@ -153,4 +122,13 @@ class UserModel } return $lesJoueurs; } + + public function getEnigmebyPartieId($idPartie){ + $lesIdEnigmes = $this->partie_gateway->findAllEnigmeIdInPartie($idPartie); + $lesEnigmes = array(); + foreach ($lesIdEnigmes as $id){ + $lesEnigmes[] = $this->enigme_gateway->findById($id)[0]; + } + return $lesEnigmes; + } } \ No newline at end of file diff --git a/WEB/View/src/pages/Multijoueur/Partie.php b/WEB/View/src/pages/Multijoueur/Partie.php index 7dc3ebf1..cc267556 100644 --- a/WEB/View/src/pages/Multijoueur/Partie.php +++ b/WEB/View/src/pages/Multijoueur/Partie.php @@ -1,5 +1,175 @@ - + + + + + + + + <?php + echo $enigme->getNom(); + ?> + + + + + + + + -vous ĂȘtes dans la partie +
+ +
+
+ home +
+
+ <   +
+
+   > +
+ +
+ + + +
+ +
+

+ getNom(); + ?> +

+

+ getEnonce(); + ?> +

+

Rappel

+

+ getRappel(); + ?> +

+

Exemple

+

+ getExemple(); + ?> +

+ + +
+ + + +
+
getPrompt(); + } + else { + echo $code;} + ?>
+
+ + + +
+ + +
+ +
+ +
+
+
+ +
+ +
+ + + + + + + + + getNom() . '.js">'; + ?> + \ No newline at end of file