added 'invisible' code again

This commit is contained in:
Sylvain Gay 2022-09-15 09:45:42 +02:00
parent 64bd22ed5a
commit 094f2419ec

View file

@ -20,6 +20,7 @@ Les messages à transmettre par le serveur :
// Textes d'interaction avec les conscrits // Textes d'interaction avec les conscrits
var PWD_TRACKED = "tracked"; var PWD_TRACKED = "tracked";
var PWD_TRACKER = "tracker"; var PWD_TRACKER = "tracker";
var PWD_INVISIBLE = "invisible";
var MSG_BAD = "Code Incorrect"; var MSG_BAD = "Code Incorrect";
var MSG_TRACKED = "Vous êtes maintenant traqué.e.s !" var MSG_TRACKED = "Vous êtes maintenant traqué.e.s !"
var MSG_TRACKER = "Vous pouvez maintenant traquer !"; 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}); equipes[i].emit('changeColor', {"id": socket.id, "color": d.color});
}); });
socket.on('message', function(d){ socket.on('message', function(d){
d.content = d.content.toLowerCase(); d.content = d.content.toLowerCase();
if(d.content == PWD_TRACKED){ if(d.content == PWD_TRACKED){
d.color = 0; d.color = 0;
socket.emit('popup', {"content": MSG_TRACKED}); socket.emit('popup', {"content": MSG_TRACKED});
} else if(d.content == PWD_TRACKER){ } else if(d.content == PWD_TRACKER){
d.color = 1; d.color = 1;
socket.emit('popup', {"content": MSG_TRACKER}); socket.emit('popup', {"content": MSG_TRACKER});
} } else if(d.content == PWD_INVISIBLE){
else if((d.content in invisi) && invisi[d.content]){ d.color = -1;
socket.emit('popup', {"content": MSG_INVISIBLE});
} else if((d.content in invisi) && invisi[d.content]){
invisi[d.content] = false; invisi[d.content] = false;
old_color = socket.color; old_color = socket.color;
d.color = -1; d.color = -1;
socket.emit('popup', {"content": MSG_INVISIBLE}); socket.emit('popup', {"content": MSG_INVISIBLE});
setTimeout(function(s,c){ setTimeout(function(s,c){
for(i in equipes){ for(i in equipes){
equipes[i].emit('moving', {"id": s.id, "position": s.position}); equipes[i].emit('moving', {"id": s.id, "position": s.position});
equipes[i].emit('changeColor', {"id": s.id, "color": c, "debug": "timeout"}); equipes[i].emit('changeColor', {"id": s.id, "color": c, "debug": "timeout"});
} }
s.color = c; s.color = c;
}, invisible_delay, socket, old_color); }, invisible_delay, socket, old_color);
} else { } else {
socket.emit('popup', {"content": MSG_BAD}); socket.emit('popup', {"content": MSG_BAD});
return; return;