fixe affichage des mouvements
This commit is contained in:
parent
5b58c6b28a
commit
3b983b5227
1 changed files with 10 additions and 2 deletions
12
server.js
12
server.js
|
|
@ -527,8 +527,16 @@ io.on('connection', (socket) => {
|
||||||
console.error('computeLegalMoves error', e);
|
console.error('computeLegalMoves error', e);
|
||||||
moves = [];
|
moves = [];
|
||||||
}
|
}
|
||||||
// broadcast selection + moves to ALL clients in the room (including sender)
|
// send selection to the selecting client WITH moves, but broadcast selection WITHOUT moves to other clients
|
||||||
io.to(roomId).emit('game:select', { playerId, square, moves });
|
try{
|
||||||
|
// send to selecting socket (include moves)
|
||||||
|
socket.emit('game:select', { playerId, square, moves });
|
||||||
|
// notify other sockets in the room about the selection but without revealing the legal moves
|
||||||
|
socket.to(roomId).emit('game:select', { playerId, square, moves: [] });
|
||||||
|
}catch(e){
|
||||||
|
// fallback: broadcast to all (shouldn't normally happen)
|
||||||
|
io.to(roomId).emit('game:select', { playerId, square, moves: [] });
|
||||||
|
}
|
||||||
cb && cb({ ok: true });
|
cb && cb({ ok: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue