mirror of
https://github.com/kmitresse/Cards-Rush.git
synced 2026-05-13 17:11:49 +00:00
feat: devWeb - add detail on connected users
This commit is contained in:
@@ -192,6 +192,12 @@ public class Player implements Serializable {
|
||||
this.score += points;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return le score maximum possible
|
||||
*/
|
||||
public int getScoreMax(){
|
||||
return game.getNbRounds() * 3; // 2 points par bonne réponse + 1 point pour le clic rapide
|
||||
}
|
||||
/**
|
||||
* @return si le joueur est gagnant
|
||||
*/
|
||||
@@ -328,4 +334,6 @@ public class Player implements Serializable {
|
||||
public void setCurrentClick(ClickChoice currentClick) {
|
||||
this.currentClick = currentClick;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -346,6 +346,18 @@ public class User implements Serializable {
|
||||
return nbWin;
|
||||
}
|
||||
|
||||
public double getScoreRate(){
|
||||
if (getNbPlayedGame() == 0) return 0;
|
||||
int maxScore = 0;
|
||||
int totalScore = 0;
|
||||
for (Player p : playedGames) {
|
||||
System.out.println("Score max : " + p.getScoreMax() + " Score : " + p.getScore());
|
||||
maxScore += p.getScoreMax();
|
||||
totalScore += p.getScore();
|
||||
}
|
||||
return (double) Math.abs(totalScore * 100 / maxScore);
|
||||
}
|
||||
|
||||
/**
|
||||
* Récupère le pourcentage de victoire
|
||||
*
|
||||
|
||||
@@ -8,6 +8,8 @@ public class SimpleUser {
|
||||
|
||||
private final int nbPlayedGames;
|
||||
private final int nbWin;
|
||||
private final double winRate;
|
||||
private final double scoreRate;
|
||||
private final double rigthClickPercentRate;
|
||||
private final double rapidClickPercentRate;
|
||||
|
||||
@@ -16,6 +18,8 @@ public class SimpleUser {
|
||||
this.username = user.getUsername();
|
||||
this.nbPlayedGames = user.getNbPlayedGame();
|
||||
this.nbWin = user.getNbWin();
|
||||
this.winRate = user.getWinRate();
|
||||
this.scoreRate = user.getScoreRate();
|
||||
this.rigthClickPercentRate = user.getRightClickPercentRate();
|
||||
this.rapidClickPercentRate = user.getRapidClickPercentRate();
|
||||
}
|
||||
@@ -36,6 +40,14 @@ public class SimpleUser {
|
||||
return nbWin;
|
||||
}
|
||||
|
||||
public double getWinRate() {
|
||||
return winRate;
|
||||
}
|
||||
|
||||
public double getScoreRate() {
|
||||
return scoreRate;
|
||||
}
|
||||
|
||||
public double getRigthClickPercentRate() {
|
||||
return rigthClickPercentRate;
|
||||
}
|
||||
|
||||
@@ -119,7 +119,10 @@ public class GameWS {
|
||||
player.incrementClickCount();
|
||||
|
||||
// Compteur de clics rapides
|
||||
if (gameClickCount == 1) player.incrementRapidClickCount();
|
||||
if (gameClickCount == 1) {
|
||||
player.incrementRapidClickCount();
|
||||
player.addToScore(1);
|
||||
};
|
||||
|
||||
// Vérifier le choix du joueur et attribuer les points
|
||||
if (game.getDifficulty().equals(Game.Difficulty.EASY)) {
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
<!-- Liste des utilisateurs dans le lobby -->
|
||||
<div id="user-list-modal" class="modal">
|
||||
<div class="modal-background"></div>
|
||||
<div class="modal-card">
|
||||
<div class="modal-card modal-">
|
||||
<header class="modal-card-head">
|
||||
<p class="modal-card-title">Liste des utilisateurs connectés</p>
|
||||
<button class="delete" aria-label="close"></button>
|
||||
@@ -80,6 +80,7 @@
|
||||
<th>Utilisateur</th>
|
||||
<th>Nombre de parties jouées</th>
|
||||
<th>Nombre de victoires</th>
|
||||
<th>Score moyen</th>
|
||||
<th>Clics corrects</th>
|
||||
<th>Clics rapides</th>
|
||||
<th>Action</th>
|
||||
@@ -91,7 +92,7 @@
|
||||
</table>
|
||||
</section>
|
||||
<footer class="modal-card-foot">
|
||||
<button class="button is-primary is-light">Fermer</button>
|
||||
<button class="button is-light">Fermer</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
@@ -136,6 +137,7 @@
|
||||
const $tdUsername = document.createElement('td');
|
||||
const $tdNbPlayedGame = document.createElement('td');
|
||||
const $tdNbWins = document.createElement('td');
|
||||
const $tdScore = document.createElement('td');
|
||||
const $tdRightClick = document.createElement('td');
|
||||
const $tdRapidClick = document.createElement('td');
|
||||
const $tdAction = document.createElement('td');
|
||||
@@ -164,6 +166,7 @@
|
||||
$tdUsername.textContent = user.username;
|
||||
$tdNbPlayedGame.textContent = user.nbPlayedGames;
|
||||
$tdNbWins.textContent = user.nbWin;
|
||||
$tdScore.textContent = user.scoreRate + "%";
|
||||
$tdRightClick.textContent = user.rigthClickPercentRate + "%";
|
||||
$tdRapidClick.textContent = user.rapidClickPercentRate + "%";
|
||||
$tdAction.appendChild($button);
|
||||
@@ -171,6 +174,7 @@
|
||||
$tr.appendChild($tdUsername);
|
||||
$tr.appendChild($tdNbPlayedGame);
|
||||
$tr.appendChild($tdNbWins);
|
||||
$tr.appendChild($tdScore);
|
||||
$tr.appendChild($tdRightClick);
|
||||
$tr.appendChild($tdRapidClick);
|
||||
$tr.appendChild($tdAction);
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<th>Nom d'utilisateur</th>
|
||||
<th>Nombre de parties jouées</th>
|
||||
<th>Nombre de victoires</th>
|
||||
<th>Score moyen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
@@ -37,12 +38,16 @@
|
||||
tdNbGames.textContent = user.nbPlayedGames;
|
||||
const tdNbWin = document.createElement('td');
|
||||
tdNbWin.dataset.id = user.id;
|
||||
tdNbWin.textContent = user.nbWin;
|
||||
tdNbWin.textContent = user.nbWin + " (" + user.winRate + "%)";
|
||||
const tdScoreRate = document.createElement('td');
|
||||
tdScoreRate.dataset.id = user.id;
|
||||
tdScoreRate.textContent = user.scoreRate + "%";
|
||||
|
||||
|
||||
tr.appendChild(tdUsername);
|
||||
tr.appendChild(tdNbGames);
|
||||
tr.appendChild(tdNbWin);
|
||||
tr.appendChild(tdScoreRate);
|
||||
table.appendChild(tr);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2,8 +2,15 @@
|
||||
--bulma-primary-h: 0;
|
||||
--bulma-primary-s: 70%;
|
||||
--bulma-primary-l: 35%;
|
||||
--modal-content-width: 50rem;
|
||||
}
|
||||
|
||||
.hero {
|
||||
background: url("../img/Home.svg") lightgray 50% / cover no-repeat;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 769px) {
|
||||
.modal-card, .modal-content {
|
||||
width: var(--modal-content-width) !important;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user