fix: synced timer
All checks were successful
Linux arm64 / Build (push) Successful in 26s

This commit is contained in:
2025-02-01 11:22:59 +01:00
parent 3863c812c8
commit caf6569409
7 changed files with 50 additions and 24 deletions

View File

@@ -2,6 +2,7 @@ package network.server;
import java.io.IOException;
import java.net.ServerSocket;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
@@ -69,11 +70,12 @@ public class Server {
}
public void startGame(MultiDoku doku) {
this.game.startGame(doku);
Instant now = Instant.now();
this.game.startGame(doku, now);
for (ServerConnexion connexion : this.connexions) {
connexion.setSudoku(doku.clone());
}
broadcastPacket(new StartGamePacket(SudokuSerializer.serializeSudoku(doku).toString()));
broadcastPacket(new StartGamePacket(SudokuSerializer.serializeSudoku(doku).toString(), now));
}
}

View File

@@ -3,6 +3,7 @@ package network.server;
import java.io.IOException;
import java.net.Socket;
import game.Game;
import game.Player;
import game.Game.GameState;
import network.Connexion;
@@ -69,10 +70,13 @@ public class ServerConnexion extends Connexion {
this.server.broadcastPacket(new PlayerJoinPacket(player));
sendPacket(new ConnexionInfoPacket(player.getId()));
if (this.server.getGame().getGameState() == GameState.GameGoing) {
setSudoku(this.server.getGame().getDoku().clone());
Game game = this.server.getGame();
if (game.getGameState() == GameState.GameGoing) {
setSudoku(game.getDoku().clone());
sendPacket(
new StartGamePacket(SudokuSerializer.serializeSudoku(this.server.getGame().getDoku()).toString()));
new StartGamePacket(SudokuSerializer.serializeSudoku(game.getDoku()).toString(),
game.getStartTime()));
}
}