From 875e07973077757f6a90dc6715ba0051bb3bb2e6 Mon Sep 17 00:00:00 2001 From: sgay Date: Wed, 14 Sep 2022 16:46:12 +0000 Subject: [PATCH] ajoute timeout pour invisible --- traque.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/traque.js b/traque.js index 0283235..e22d1e5 100644 --- a/traque.js +++ b/traque.js @@ -24,6 +24,7 @@ var MSG_BAD = "Code Incorrect"; var MSG_TRACKED = "Vous êtes maintenant traqué.e.s !" var MSG_TRACKER = "Vous pouvez maintenant traquer !"; var MSG_INVISIBLE = "Les autres équipes ne peuvent plus vous voir !"; +var invisible_delay = 3*60*1000; var equipes = []; var admins = []; @@ -121,8 +122,16 @@ io.sockets.on('connection', function(socket){ } else if((d.content in invisi) && invisi[d.content]){ invisi[d.content] = false; + 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); } else { socket.emit('popup', {"content": MSG_BAD}); return;