fix: score display
All checks were successful
Linux arm64 / Build (push) Successful in 28s

This commit is contained in:
2025-02-01 12:54:11 +01:00
parent 02089c649b
commit f22debdf5f
6 changed files with 20 additions and 17 deletions

View File

@@ -63,7 +63,7 @@ public class ServerConnexion extends Connexion {
for (Player p : this.server.getGame().getPlayers().values()) {
if (p.getId() != player.getId()) {
sendPacket(new PlayerJoinPacket(p));
sendPacket(new UpdatePlayerScorePacket(p.getId(), p.getScore()));
sendPacket(new UpdatePlayerScorePacket(p.getId(), p.getRemainingCells()));
}
}
@@ -139,20 +139,20 @@ public class ServerConnexion extends Connexion {
}
if (cell.getSymbolIndex() != Cell.NOSYMBOL && packet.getNewValue() == Cell.NOSYMBOL) {
cell.empty();
this.server.getGame().setPlayerScore(player, player.getScore() + 1);
this.server.broadcastPacket(new UpdatePlayerScorePacket(player.getId(), player.getScore()));
this.server.getGame().setPlayerRemainingCells(player, player.getRemainingCells() + 1);
this.server.broadcastPacket(new UpdatePlayerScorePacket(player.getId(), player.getRemainingCells()));
return;
}
// on rajoute un chiffre à la grille
if (cell.trySetValue(packet.getNewValue())) {
this.server.getGame().setPlayerScore(player, player.getScore() - 1);
this.server.broadcastPacket(new UpdatePlayerScorePacket(player.getId(), player.getScore()));
this.server.getGame().setPlayerRemainingCells(player, player.getRemainingCells() - 1);
this.server.broadcastPacket(new UpdatePlayerScorePacket(player.getId(), player.getRemainingCells()));
}
checkWin();
}
private void checkWin() {
if (this.player.getScore() == 0) {
if (this.player.getRemainingCells() == 0) {
// we don't need to specify the winner since it has to be the first
this.server.broadcastPacket(new EndGamePacket());
this.server.getGame().stopGame();
@@ -162,8 +162,8 @@ public class ServerConnexion extends Connexion {
public void setSudoku(MultiDoku doku) {
this.doku = doku;
assert (player != null);
this.server.getGame().setPlayerScore(player, this.doku.getEmptyCells().size());
this.server.broadcastPacket(new UpdatePlayerScorePacket(player.getId(), player.getScore()));
this.server.getGame().setPlayerRemainingCells(player, this.doku.getEmptyCells().size());
this.server.broadcastPacket(new UpdatePlayerScorePacket(player.getId(), player.getRemainingCells()));
}
}