feat : page lobby utilisable

pull/37/head
Jeremy DUCOURTHIAL 1 year ago
parent cc60aecd33
commit 4d2e84ca57

@ -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;
}
}

@ -24,7 +24,6 @@ class ControllerUserLobby
$this->mdLobby = new ModelLobby();
$lobbies = $this->mdLobby->getlobbies();
echo $twig->render($vues["lobby"], [
'lobbies' => $lobbies,

@ -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');

@ -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;
}

@ -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
}
}

@ -29,7 +29,7 @@
</h1>
</div>
</a>
<a href="/lobby" class="text-white m-3 container text-center d-flex align-items-center w-75 rounded border border-white text-center" style="background-color:orange;text-decoration: none;color: black;height:20vh;">
<a href="/lobby/list" class="text-white m-3 container text-center d-flex align-items-center w-75 rounded border border-white text-center" style="background-color:orange;text-decoration: none;color: black;height:20vh;">
<div class="container text-center d-flex align-items-center text-center">
<h1 class="mx-auto fs-1">
MULTIJOUEUR

@ -26,7 +26,7 @@
{% for lobby in lobbies %}
<li class="list-group-item d-flex justify-content-between align-items-center">
<h6>{{lobby.name}}</h6>
<h6>{{lobby.nbPlayer}}/6</h6>
<h6>0/{{lobby.nbPlayer}}</h6>
<div class="btn">
<a type="button" class="btn btn-primary" href="">Rejoindre</a>
</div>
@ -37,40 +37,5 @@
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
<div class="modal fade" id="modalquestions">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Ajouter une question</h5>
</div>
<form method="POST" action="/admin/questions/add">
<div class="modal-body">
<div class="form-group">
<label for="name">Contenu de la question :</label>
<input type="text" class="form-control" id="content" name="content">
</div>
<div class="form-group">
<label for="name">Chapitre de la question :</label>
<select class="form-control" id="idChapter" name="idChapter">
{% for chapter in chapters %}
<option value="{{chapter.id}}" >{{chapter.name}}</option>
{% endfor %}
</select>
</div>
<div class="form-group">
<label for="name">Réponse 1 de la question :</label>
<input type="text" class="form-control" id="answer1" name="answer1">
<input type="radio" name="correctAnswer" checked="checked" value="0"> Correct
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Fermer</button>
<button type="submit" class="btn btn-primary">Enregistrer</button>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
Loading…
Cancel
Save