From 094f2419ec01ab01d493f2fa9143c53a0a8d6eb2 Mon Sep 17 00:00:00 2001 From: Sylvain Gay Date: Thu, 15 Sep 2022 09:45:42 +0200 Subject: [PATCH] added 'invisible' code again --- traque.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/traque.js b/traque.js index 52783ce..92648fc 100644 --- a/traque.js +++ b/traque.js @@ -20,6 +20,7 @@ Les messages à transmettre par le serveur : // Textes d'interaction avec les conscrits var PWD_TRACKED = "tracked"; var PWD_TRACKER = "tracker"; +var PWD_INVISIBLE = "invisible"; var MSG_BAD = "Code Incorrect"; var MSG_TRACKED = "Vous êtes maintenant traqué.e.s !" var MSG_TRACKER = "Vous pouvez maintenant traquer !"; @@ -112,26 +113,28 @@ io.sockets.on('connection', function(socket){ equipes[i].emit('changeColor', {"id": socket.id, "color": d.color}); }); socket.on('message', function(d){ - d.content = d.content.toLowerCase(); + d.content = d.content.toLowerCase(); if(d.content == PWD_TRACKED){ d.color = 0; socket.emit('popup', {"content": MSG_TRACKED}); } else if(d.content == PWD_TRACKER){ d.color = 1; socket.emit('popup', {"content": MSG_TRACKER}); - } - else if((d.content in invisi) && invisi[d.content]){ + } else if(d.content == PWD_INVISIBLE){ + d.color = -1; + socket.emit('popup', {"content": MSG_INVISIBLE}); + } else if((d.content in invisi) && invisi[d.content]){ invisi[d.content] = false; - old_color = socket.color; + old_color = socket.color; d.color = -1; socket.emit('popup', {"content": MSG_INVISIBLE}); - setTimeout(function(s,c){ - for(i in equipes){ - equipes[i].emit('moving', {"id": s.id, "position": s.position}); - equipes[i].emit('changeColor', {"id": s.id, "color": c, "debug": "timeout"}); - } - s.color = c; - }, invisible_delay, socket, old_color); + setTimeout(function(s,c){ + for(i in equipes){ + equipes[i].emit('moving', {"id": s.id, "position": s.position}); + equipes[i].emit('changeColor', {"id": s.id, "color": c, "debug": "timeout"}); + } + s.color = c; + }, invisible_delay, socket, old_color); } else { socket.emit('popup', {"content": MSG_BAD}); return;