1.6 KiB
1.6 KiB
Test Deck Feature Implementation
Requirements
- Allow users to "Test Deck" directly from the Cube Manager (Pack Generator).
- Create a randomized deck from the generated pool (approx. 23 spells + 17 lands).
- Start a solo game immediately.
- Enable return to lobby.
Implementation Details
Client-Side Updates
App.tsx: PassedavailableLandstoCubeManagerto allow for proper basic land inclusion in randomized decks.CubeManager.tsx:- Added
handleStartSoloTestfunction. - Logic: Flattens generated packs, separates lands/spells, shuffles and picks 23 spells, adds 17 basic lands (using
availableLandsif available). - Emits
start_solo_testsocket event with the constructed deck. - On success, saves room ID to
localStorageand navigates to the Lobby tab usingonGoToLobby. - Added "Test Solo" button to the UI next to "Play Online".
- Added
LobbyManager.tsx: Existingrejoin_roomlogic (triggered on mount vialocalStorage) handles picking up the active session.
Server-Side Updates
src/server/index.ts:- Updated
rejoin_roomhandler to emitgame_updateif the room status isplaying. This ensures that when the client navigates to the lobby and "rejoins" the solo session, the game board is correctly rendered.
- Updated
User Flow
- User generates packs in Cube Manager.
- User clicks "Test Solo".
- System builds a random deck and creates a solo room on the server.
- UI switches to "Online Lobby" tab.
- Lobby Manager detects the active session and loads the Game Room.
- User plays the game.
- User can click "Leave Room" icon in the sidebar to return to the Lobby creation screen.