Restore locked files if not all removed within 60 seconds

Removing one of the 3 AI-virus-protected files now starts a 60-second
window (tracked session-wide via LockedFilesRemovalDeadline). If the
other locked files aren't also removed before it expires, the virus
restores whichever ones were deleted and broadcasts a red warning to
the whole session, forcing players to coordinate the removal instead
of picking them off one at a time.

Also extends the Mercure broadcast payload with an optional 3rd
"messageType" element so pushed messages can render red (virus) or
green (mainframe) instead of always defaulting to green.
This commit is contained in:
Frank
2026-07-11 17:26:59 +02:00
parent f6a0d62017
commit e6ba469ef9
4 changed files with 94 additions and 6 deletions
+2 -6
View File
@@ -14,7 +14,7 @@ function subscribeToMercure(mercurePublicUrl, topic, myScreen) {
const data = JSON.parse(event.data);
console.log('[Mercure][game1] Update:', data);
// data is [sendTo, message]
// data is [sendTo, message, messageType?] - messageType defaults to 'mainframe' (green)
if (Array.isArray(data) && data.length >= 2) {
const sendTo = parseInt(data[0]);
// Filter: 0 means everyone, otherwise must match myScreen
@@ -25,11 +25,7 @@ function subscribeToMercure(mercurePublicUrl, topic, myScreen) {
const messageContainer = document.getElementById('message-container');
if (messageContainer) {
const msgEl = document.createElement('div');
msgEl.className = 'message';
msgEl.textContent = data[1];
msgEl.style.color = '#0F0'; // Green for incoming messages
messageContainer.appendChild(msgEl);
appendResultMessage(messageContainer, data[1], data[2] || 'mainframe');
window.scrollTo(0, document.body.scrollHeight);
if(stillPlayingSound)
playSound();