1.0 KiB
1.0 KiB
2025-12-16 - Reconnection and Auto-Pick
Reconnection Logic
- Use
localStorage.setItem('active_room_id', roomId)inLobbyManagerto persist connection state. - Upon page load, if a saved room ID exists, attempted to automatically reconnect via
rejoin_roomsocket event. - Updated
socket.on('join_room')andrejoin_roomon the server to update the player's socket ID mapping, canceling any pending "disconnect" timers.
Disconnection Handling
- Updated
RoomManagerto tracksocketIdandisOfflinestatus for each player. - In
index.ts,socket.on('disconnect'):- Marks player as offline.
- Starts a 30-second timer.
- If timer expires (user did not reconnect):
- Triggers
draftManager.autoPick(roomId, playerId). autoPickselects a random card from the active pack to unblock the draft flow.
- Triggers
Auto-Pick Implementation
- Added
autoPicktoDraftManager:- Checks if player has an active pack.
- Selects random index.
- Calls
pickCardinternally to process the pick (add to pool, pass pack, etc.).