1.4 KiB
1.4 KiB
Fix Submit Deck Button
Issue
Users reported that "Submit Deck" button was not working.
Root Causes
- Missing Event Handler: The server was not listening for the
player_readyevent emitted by the client. - Incomplete Payload: The client was sending
{ roomId, deck }but the server neededplayerIdto identify who was ready, which was missing from the payload. - Missing State Logic: The
RoomManagerdid not have a concept of "Ready" state or "Playing" status, meaning the transition from Deck Building to Game was not fully implemented.
Fixes
- Client (
DeckBuilderView.tsx): Updatedplayer_readyemission to includeplayerId. - Server (
RoomManager.ts):- Added
readyanddeckproperties toPlayerinterface. - Added
playingtoRoomstatus. - Implemented
setPlayerReadymethod.
- Added
- Server (
index.ts):- Implemented
player_readysocket handler. - Added logic to check if all active players are ready.
- If all ready, automatically transitions room status to
playingand initializes the game usingGameManager, loading the submitted decks. - ensured deck loading uses cached images (
card.image) if available.
- Implemented
Verification
- Draft cards.
- Build deck.
- Click "Submit Deck".
- Server logs should show "All players ready...".
- Client should automatically switch to
GameView(Battlefield).