add: ajout de la fonction d'instruction vocale

This commit is contained in:
2026-08-03 22:51:26 +02:00
parent 45ad31d0ae
commit d36c025cf2
2 changed files with 39 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
/*
guideInstruction.js
sert a envoyer au client guide les instructions
*/
const INSTRUCTION_GUIDE = "instruction";
const INSTRUCTION_INTERVAL_MS = 5000;
function startInstructionLoop(wSS, socket, partnerSocket, pairState, getInstructionTexte) {
const interval = setInterval(() => {
if (pairState.gameOver) {
clearInterval(interval);
return;
}
const guideSocket = socket.data.role === "guide" ? socket : partnerSocket;
const texte = getInstructionText();
guideSocket.emit(INSTRUCTION_GUIDE, { texte });
}, INSTRUCTION_INTERVAL_MS);
return () => clearInterval(interval);
}
module.exports = { startInstructionLoop };