ajout de la verification de la porte

This commit is contained in:
2026-07-31 03:02:21 +02:00
parent 914dbe2368
commit 81e2623e2a
2 changed files with 26 additions and 0 deletions

View File

@@ -14,6 +14,8 @@ let waitingPlayer = null;
// Sert tous les fichiers du dossier "client"
app.use(express.static(path.join(__dirname, "..", "client")));
const correctDoor = { x : 3, y : 6};
io.on("connection", (socket) => {
console.log("Un client s'est connecte : ${socket.id}");
@@ -42,6 +44,18 @@ io.on("connection", (socket) => {
}
});
socket.on("door_reached", (position) => {
const partnerId = socket.data.partnerId;
const isCorrect = position.x === correctDoor.x && position.y === correctDoor.y;
const result = {correct: isCorrect};
socket.emit("door_result", result);
if (partnerId){
io.to(partnerId).emit("door_result", result);
}
});
socket.on("disconnect", () => {
console.log("Client deconnecte : ${socket.id}");
if (waitingPlayer === socket){