mirror of
https://github.com/kmitresse/Cards-Rush.git
synced 2026-05-14 01:21:49 +00:00
draft(DevWeb): Start game page
This commit is contained in:
@@ -82,6 +82,8 @@ public class Game implements Serializable {
|
||||
* Constructeur par défaut
|
||||
*/
|
||||
public Game() {
|
||||
this.createdAt = new Date();
|
||||
this.players = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,7 +91,7 @@ public class Game implements Serializable {
|
||||
*
|
||||
* @param difficulty la difficulté de la partie
|
||||
* @see Difficulty
|
||||
* @param timer le timer de chaque rounds en seconde
|
||||
* @param timer le timer de chaque round en seconde
|
||||
* @param nbRounds le nombre de tours de la partie
|
||||
* @param nbColors le nombre de couleurs présente dans le deck
|
||||
* @param nbValuesPerColor le nombre de valeurs par couleur
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* MainMenuServlet.java, 20/03/2024
|
||||
* UPPA M1 TI 2023-2024
|
||||
* Pas de copyright, aucun droits
|
||||
*/
|
||||
|
||||
package uppa.project.web.servlet;
|
||||
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.annotation.WebServlet;
|
||||
import jakarta.servlet.http.HttpServlet;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import uppa.project.database.dao.DAO;
|
||||
import uppa.project.database.dao.DAOException;
|
||||
import uppa.project.database.dao.jpa.DAO_JPA_Game;
|
||||
import uppa.project.database.dao.jpa.Game_JPA_DAO_Factory;
|
||||
import uppa.project.database.pojo.Game;
|
||||
|
||||
@WebServlet(name = "gameServlet", value = "/game")
|
||||
public class GameServlet extends HttpServlet {
|
||||
|
||||
public void init() {
|
||||
}
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
|
||||
try {
|
||||
DAO<Game> gameDAO = new Game_JPA_DAO_Factory().getDAOGame();
|
||||
Game game = gameDAO.findById(Integer.parseInt(request.getParameter("id")));
|
||||
request.setAttribute("game", game);
|
||||
|
||||
request.getRequestDispatcher("/WEB-INF/pages/game.jsp").forward(request, response);
|
||||
} catch (DAOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@taglib prefix="layout" tagdir="/WEB-INF/tags/layouts" %>
|
||||
<%@taglib prefix="component" tagdir="/WEB-INF/tags/components" %>
|
||||
|
||||
<layout:base>
|
||||
<component:hero>
|
||||
<div class="columns">
|
||||
<div class="column">
|
||||
<component:card title="Liste des joueurs dans la partie">
|
||||
<jsp:attribute name="footer">
|
||||
<a data-target="#user-list-modal" class="card-footer-item modal-trigger">Ajouter</a>
|
||||
</jsp:attribute>
|
||||
</component:card>
|
||||
</div>
|
||||
<div class="column">
|
||||
<component:card title="Partie n°${pageContext.request.getParameter('id')}">
|
||||
<jsp:useBean id="game" scope="request" type="uppa.project.database.pojo.Game"/>
|
||||
|
||||
<p><strong>Créé le:</strong> ${game.createdAt.toLocaleString()}</p>
|
||||
<p><strong>Difficulté:</strong> ${game.difficulty}</p>
|
||||
<p><strong>Nombre de tours:</strong> ${game.nbRounds}</p>
|
||||
<p><strong>Valeurs par couleur:</strong> ${game.nbValuesPerColor}</p>
|
||||
<p><strong>Nombre de couleurs:</strong> ${game.nbColors}</p>
|
||||
</component:card>
|
||||
</div>
|
||||
</div>
|
||||
</component:hero>
|
||||
|
||||
<!-- Liste des utilisateurs dans le lobby -->
|
||||
<div id="user-list-modal" class="modal">
|
||||
<div class="modal-background"></div>
|
||||
<div class="modal-card">
|
||||
<header class="modal-card-head">
|
||||
<p class="modal-card-title">Liste des utilisateurs connectés</p>
|
||||
<button class="delete" aria-label="close"></button>
|
||||
</header>
|
||||
<section class="modal-card-body">
|
||||
TODO Liste des utilisateurs
|
||||
</section>
|
||||
<footer class="modal-card-foot">
|
||||
<button class="button is-success">Fermer</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script defer type="module">
|
||||
// Modal
|
||||
document.querySelectorAll('.modal-trigger').forEach(($el) => {
|
||||
$el.addEventListener('click', () => {
|
||||
const target = $el.dataset.target;
|
||||
const $target = document.querySelector(target);
|
||||
$target.classList.add('is-active');
|
||||
});
|
||||
});
|
||||
|
||||
const closeModal = ($el) => $el.classList.remove('is-active');
|
||||
const closeAllModals = () => (document.querySelectorAll('.modal') || []).forEach(($modal) => closeModal($modal));
|
||||
|
||||
// Add a click event on various child elements to close the parent modal
|
||||
(document.querySelectorAll('.modal-background, .modal-close, .modal-card-head .delete, .modal-card-foot .button') || []).forEach(($close) => {
|
||||
const $target = $close.closest('.modal');
|
||||
$close.addEventListener('click', () => closeModal($target));
|
||||
});
|
||||
|
||||
// Add a keyboard event to close all modals
|
||||
document.addEventListener('keydown', (event) => {
|
||||
if (event.key === "Escape") closeAllModals();
|
||||
});
|
||||
</script>
|
||||
|
||||
</layout:base>
|
||||
Reference in New Issue
Block a user