feat: Enhance draft system with 4-player 'pick 2' rules, minimum player count, and fix pack duplication by ensuring unique pack instances.
All checks were successful
Build and Deploy / build (push) Successful in 1m25s

This commit is contained in:
2025-12-16 18:41:43 +01:00
parent 58641b34a5
commit 6163869a17
6 changed files with 90 additions and 5 deletions

View File

@@ -87,7 +87,13 @@ io.on('connection', (socket) => {
// Just rejoin the socket channel if validation passes (not fully secure yet)
socket.join(roomId);
const room = roomManager.getRoom(roomId);
if (room) socket.emit('room_update', room);
if (room) {
socket.emit('room_update', room);
if (room.status === 'drafting') {
const draft = draftManager.getDraft(roomId);
if (draft) socket.emit('draft_update', draft);
}
}
});
socket.on('send_message', ({ roomId, sender, text }) => {
@@ -100,6 +106,13 @@ io.on('connection', (socket) => {
socket.on('start_draft', ({ roomId }) => {
const room = roomManager.getRoom(roomId);
if (room && room.status === 'waiting') {
const activePlayers = room.players.filter(p => p.role === 'player');
if (activePlayers.length < 4) {
// Emit error to the host or room
socket.emit('draft_error', { message: 'Draft cannot start. It requires at least 4 players.' });
return;
}
// Create Draft
// All packs in room.packs need to be flat list or handled
// room.packs is currently JSON.