diff --git a/Website/classes/Lobby.php b/Website/classes/Lobby.php index 32b69cc..8520453 100644 --- a/Website/classes/Lobby.php +++ b/Website/classes/Lobby.php @@ -6,14 +6,14 @@ class Lobby private int $id; private string $name; private string $password; - private int $nbPlayer; + private int $nbPlayers; - public function __construct(int $id, string $name, string $password, int $nbPlayer) + public function __construct(int $id, string $name, string $password, int $nbPlayers) { $this->id = $id; $this->name = $name; $this->password = $password; - $this->nbPlayer = $nbPlayer; + $this->nbPlayer = $nbPlayers; } public function getId(): int @@ -26,12 +26,13 @@ class Lobby return $this->name; } - public function getNbPlayer() + public function getNbPlayers() { - return $this->nbPlayer; + return $this->nbPlayers; } - public function setNbplayer(int $nbPlayer) + + public function setNbplayers(int $nbPlayers) { - $this->nbPlayer = $nbPlayer; + $this->nbPlayer = $nbPlayers; } } diff --git a/Website/controllers/ControllerUserLobby.php b/Website/controllers/ControllerUserLobby.php index e42c2cb..edd9ffb 100644 --- a/Website/controllers/ControllerUserLobby.php +++ b/Website/controllers/ControllerUserLobby.php @@ -24,7 +24,6 @@ class ControllerUserLobby $this->mdLobby = new ModelLobby(); $lobbies = $this->mdLobby->getlobbies(); - echo $twig->render($vues["lobby"], [ 'lobbies' => $lobbies, diff --git a/Website/controllers/FrontController.php b/Website/controllers/FrontController.php index 490501d..d807776 100755 --- a/Website/controllers/FrontController.php +++ b/Website/controllers/FrontController.php @@ -33,7 +33,7 @@ class FrontController $router->map('GET', '/admin/questions', 'ControllerAdminQuestions'); $router->map('POST', '/admin/questions/[a:action]', 'ControllerAdminQuestions'); $router->map('GET', '/admin/questions/[a:action]/[i:id]', 'ControllerAdminQuestions'); - $router->map('GET', '/lobby', 'ControllerUserLobby'); + $router->map('GET', '/lobby/list', 'ControllerUserLobby'); $router->map('POST', '/user/players/[a:action]', 'ControllerUserPlayers'); $router->map('GET', '/user/players/[a:action]/[i:id]', 'ControllerUserPlayers'); diff --git a/Website/gateways/GatewayLobby.php b/Website/gateways/GatewayLobby.php index d79fb36..ab50233 100755 --- a/Website/gateways/GatewayLobby.php +++ b/Website/gateways/GatewayLobby.php @@ -31,12 +31,10 @@ class GatewayLobby public function getLobbies() { - $query = "SELECT * FROM Lobbies;"; + $query = "SELECT * FROM lobbies;"; $this->con->executeQuery($query); $results = $this->con->getResults(); - if ($results == NULL) { - return false; - } + return $results; } diff --git a/Website/models/ModelLobby.php b/Website/models/ModelLobby.php index d20a159..4e5fba1 100644 --- a/Website/models/ModelLobby.php +++ b/Website/models/ModelLobby.php @@ -23,15 +23,17 @@ class ModelLobby { $lobbiesDataArray = $this->gwLobby->getLobbies(); $lobbies = array(); + foreach ($lobbiesDataArray as $lobbyDataArray) { $lobby = new Lobby( intval($lobbyDataArray['id']), $lobbyDataArray['name'], $lobbyDataArray['password'], - intval($lobbyDataArray['nbPlayer']) + intval($lobbyDataArray['nbplayers']) ); $lobbies[] = $lobby; - return $lobbies; } + + return $lobbies; // Move the return statement outside the foreach loop } } \ No newline at end of file diff --git a/Website/templates/home.twig b/Website/templates/home.twig index 4bcb86c..efb6a25 100644 --- a/Website/templates/home.twig +++ b/Website/templates/home.twig @@ -29,7 +29,7 @@ - + MULTIJOUEUR diff --git a/Website/templates/lobby.twig b/Website/templates/lobby.twig index e5cef98..0a34a6e 100644 --- a/Website/templates/lobby.twig +++ b/Website/templates/lobby.twig @@ -26,7 +26,7 @@ {% for lobby in lobbies %} {{lobby.name}} - {{lobby.nbPlayer}}/6 + 0/{{lobby.nbPlayer}} Rejoindre @@ -37,40 +37,5 @@ - - - - - Ajouter une question - - - - - Contenu de la question : - - - - Chapitre de la question : - - {% for chapter in chapters %} - {{chapter.name}} - {% endfor %} - - - - Réponse 1 de la question : - - Correct - - - - - - - -