Create Ending
All checks were successful
Publish Docker image / Push Docker image to Docker Hub (push) Successful in 1m36s
All checks were successful
Publish Docker image / Push Docker image to Docker Hub (push) Successful in 1m36s
This commit is contained in:
@@ -109,6 +109,23 @@ module.exports = (io) => (socket) => {
|
||||
io.to(roomId).emit('round-results', results);
|
||||
};
|
||||
|
||||
const handleNextRound = async (roomId) => {
|
||||
try {
|
||||
const result = await gameController.startNewRound(roomId);
|
||||
|
||||
if (result.gameEnd) {
|
||||
const finalData = gameController.getFinalScores(roomId);
|
||||
io.to(roomId).emit('game-ended', finalData);
|
||||
return;
|
||||
}
|
||||
|
||||
handleRoundStart(roomId);
|
||||
} catch (error) {
|
||||
console.error("Error starting next round:", error);
|
||||
socket.emit("error", { message: "Failed to start next round due to an error" });
|
||||
}
|
||||
};
|
||||
|
||||
socket.on("disconnect", () => {
|
||||
const roomId = roomController.getUserRoom(socket.id);
|
||||
if (roomId) {
|
||||
@@ -298,17 +315,7 @@ module.exports = (io) => (socket) => {
|
||||
return socket.emit("error", { message: "At least 2 players are required" });
|
||||
}
|
||||
|
||||
try {
|
||||
const success = await gameController.startNewRound(roomId);
|
||||
if (success) {
|
||||
handleRoundStart(roomId);
|
||||
} else {
|
||||
socket.emit("error", { message: "Failed to start next round" });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error starting next round:", error);
|
||||
socket.emit("error", { message: "Failed to start next round due to an error" });
|
||||
}
|
||||
await handleNextRound(roomId);
|
||||
});
|
||||
|
||||
socket.on("get-current-frequency", () => {
|
||||
|
Reference in New Issue
Block a user