From 1571094ed577ad08c36ad353d8e22b8af8d99888 Mon Sep 17 00:00:00 2001 From: Didictateur Date: Sat, 18 Oct 2025 22:10:56 +0200 Subject: [PATCH] clean click event --- frontend/public/src/game.js | 21 ++------------------- frontend/src/game.js | 21 ++------------------- frontend/src/styles.css | 3 +++ 3 files changed, 7 insertions(+), 38 deletions(-) diff --git a/frontend/public/src/game.js b/frontend/public/src/game.js index 4944138..56c63d6 100644 --- a/frontend/public/src/game.js +++ b/frontend/public/src/game.js @@ -90,26 +90,9 @@ function renderBoardFromState(state, asWhite = null) { cell.appendChild(piece); boardEl.appendChild(cell); - // click to select/move + // clicks on cells should do absolutely nothing (display-only mode) cell.addEventListener('click', () => { - // if no game/socket, ignore - if (!currentGameId) return; - const x = parseInt(cell.dataset.x, 10); - const y = parseInt(cell.dataset.y, 10); - if (!selected) { - selected = { x, y }; - cell.classList.add('selected'); - setMeta('Selected ' + x + ',' + y); - } else { - // send move - const from = selected; - const to = { x, y }; - selected = null; - // clear previously selected class - document.querySelectorAll('.cell.selected').forEach(el => el.classList.remove('selected')); - setMeta('Sending move ' + from.x + ',' + from.y + ' -> ' + to.x + ',' + to.y); - if (socket && myPlayerId && currentGameId) socket.emit('move', { gameId: currentGameId, playerId: myPlayerId, from, to }); - } + // intentionally empty - no selection, no move, no UI changes }); } } diff --git a/frontend/src/game.js b/frontend/src/game.js index c9e951c..a59903f 100644 --- a/frontend/src/game.js +++ b/frontend/src/game.js @@ -60,26 +60,9 @@ function renderBoardFromState(state) { cell.appendChild(piece); boardEl.appendChild(cell); - // click to select/move + // clicks on cells should do absolutely nothing (display-only mode) cell.addEventListener('click', () => { - // if no game/socket, ignore - if (!currentGameId) return; - const x = parseInt(cell.dataset.x, 10); - const y = parseInt(cell.dataset.y, 10); - if (!selected) { - selected = { x, y }; - cell.classList.add('selected'); - setMeta('Selected ' + x + ',' + y); - } else { - // send move - const from = selected; - const to = { x, y }; - selected = null; - // clear previously selected class - document.querySelectorAll('.cell.selected').forEach(el => el.classList.remove('selected')); - setMeta('Sending move ' + from.x + ',' + from.y + ' -> ' + to.x + ',' + to.y); - if (socket && myPlayerId && currentGameId) socket.emit('move', { gameId: currentGameId, playerId: myPlayerId, from, to }); - } + // intentionally empty — do not select, do not emit moves, do not change UI }); } } diff --git a/frontend/src/styles.css b/frontend/src/styles.css index 4715668..92ab72c 100644 --- a/frontend/src/styles.css +++ b/frontend/src/styles.css @@ -19,3 +19,6 @@ main{padding:16px} .piece{width:48px;height:48px} .game-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:8px} .controls button{margin-left:8px} + +/* Ensure selected cells have no visual effect (display-only mode) */ +.cell.selected{outline: none !important; box-shadow: none !important; border-color: inherit !important; background: inherit !important}