mirror of
https://github.com/kmitresse/Cards-Rush.git
synced 2026-05-13 17:11:49 +00:00
feat: devWeb - display the current round
This commit is contained in:
@@ -10,12 +10,14 @@ public class SimpleGame {
|
||||
private final int id;
|
||||
private final ArrayList<SimplePlayer> players;
|
||||
private final Card currentCard;
|
||||
private final int currentRound;
|
||||
|
||||
public SimpleGame(Game game, ArrayList<Player> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,6 @@ public class GameStatisticsServlet extends HttpServlet {
|
||||
ArrayList<Player> 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) {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<layout:base title="Profil">
|
||||
<component:hero>
|
||||
<div class="columns is-centered">
|
||||
<div class="column is-9-tablet is-9-desktop is-9-widescreen">
|
||||
<div class="column is-11-tablet is-11-desktop is-11-widescreen">
|
||||
<component:card title="Statistiques de la partie">
|
||||
<component:game-statistics/>
|
||||
</component:card>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<div class="column is-one-quarter is-justify-content-center" id="choice"
|
||||
style="position: absolute; right: 0; z-index: 9999">
|
||||
<div class="buttons is-flex-direction-column">
|
||||
<p id="round"></p>
|
||||
<p id="round" class="title has-text-white"></p>
|
||||
<button class="button is-fullwidth" data-value="COLOR_VALUE">Même couleur et valeur</button>
|
||||
<button class="button is-fullwidth" data-value="COLOR">Même couleur</button>
|
||||
<button class="button is-fullwidth" data-value="VALUE">Même valeur</button>
|
||||
@@ -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})
|
||||
|
||||
Reference in New Issue
Block a user