From ec26b8b3347cfe2966a8693877c2746e86912cc6 Mon Sep 17 00:00:00 2001 From: kmitresse Date: Wed, 1 May 2024 11:25:23 +0200 Subject: [PATCH] feat: devWeb - display the current round --- .../uppa/project/json/websocket/SimpleGame.java | 6 ++++++ .../project/web/servlet/GameStatisticsServlet.java | 6 ------ .../main/webapp/WEB-INF/pages/game-statistics.jsp | 2 +- .../Projet/src/main/webapp/WEB-INF/pages/game.jsp | 13 ++++++++++++- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/S2/DevWeb/Projet/src/main/java/uppa/project/json/websocket/SimpleGame.java b/S2/DevWeb/Projet/src/main/java/uppa/project/json/websocket/SimpleGame.java index 8821e81..076dfc5 100644 --- a/S2/DevWeb/Projet/src/main/java/uppa/project/json/websocket/SimpleGame.java +++ b/S2/DevWeb/Projet/src/main/java/uppa/project/json/websocket/SimpleGame.java @@ -10,12 +10,14 @@ public class SimpleGame { private final int id; private final ArrayList players; private final Card currentCard; + private final int currentRound; public SimpleGame(Game game, ArrayList playerArrayList) { this.id = game.getId().intValue(); this.players = new ArrayList<>(); for (Player p : playerArrayList) players.add(new SimplePlayer(p, game.getCurrentRound())); this.currentCard = game.getDeck().getCards().get(game.getCurrentRound()); + this.currentRound = game.getCurrentRound(); } public int getId() { @@ -29,4 +31,8 @@ public class SimpleGame { public Card getCurrentCard() { return currentCard; } + + public int getCurrentRound() { + return currentRound; + } } diff --git a/S2/DevWeb/Projet/src/main/java/uppa/project/web/servlet/GameStatisticsServlet.java b/S2/DevWeb/Projet/src/main/java/uppa/project/web/servlet/GameStatisticsServlet.java index 4580d06..e4e61b3 100644 --- a/S2/DevWeb/Projet/src/main/java/uppa/project/web/servlet/GameStatisticsServlet.java +++ b/S2/DevWeb/Projet/src/main/java/uppa/project/web/servlet/GameStatisticsServlet.java @@ -26,12 +26,6 @@ public class GameStatisticsServlet extends HttpServlet { ArrayList players = new ArrayList<>(); for (Player player : game.getPlayers()) players.add(player); request.setAttribute("players", players); - - System.out.println("GameStatisticsServlet.doGet() : game = " + game); - System.out.println("GameStatisticsServlet.doGet() : players = " + players); - -// request.removeAttribute("id"); -// game.sortPlayersByScoreAndRapidity(); request.setAttribute("game", game); request.getRequestDispatcher("/WEB-INF/pages/game-statistics.jsp").forward(request, response); } catch (Exception e) { diff --git a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/game-statistics.jsp b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/game-statistics.jsp index f6a8c55..cae4c9c 100644 --- a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/game-statistics.jsp +++ b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/game-statistics.jsp @@ -7,7 +7,7 @@
-
+
diff --git a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/game.jsp b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/game.jsp index 7e75178..04f56fc 100644 --- a/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/game.jsp +++ b/S2/DevWeb/Projet/src/main/webapp/WEB-INF/pages/game.jsp @@ -50,7 +50,7 @@
-

+

@@ -258,11 +258,16 @@ const deck = document.querySelector('#deck'); // Column const myCard = document.querySelector('#myCard'); // Column const otherCards = document.querySelector('#otherCards'); // Columns + const round = document.querySelector('#round'); // Reset content deck.innerHTML = ""; myCard.innerHTML = ""; otherCards.innerHTML = ""; + round.innerText = ""; + + // Show current round + round.innerText = "Manche " + (currentGame.currentRound+1) // Show other player cards game.players @@ -304,13 +309,19 @@ const choice = document.querySelector('#choice'); const myCard = document.querySelector('#myCard'); // Column const otherCards = document.querySelector('#otherCards'); // Columns + const round = document.querySelector('#round'); + // Reset content deck.innerHTML = ""; myCard.innerHTML = ""; otherCards.innerHTML = ""; + round.innerText = ""; choice.querySelectorAll('button').forEach(button => button.disabled = false); + // Show the current round + round.innerText = "Manche " + (currentGame.currentRound + 1) + // Show other player cards game.players .filter(p => p.user.id !== ${user.id})