2.4 KiB
2.4 KiB
implementation_plan - Lobby Improvements and Kick Functionality
This plan addresses user feedback regarding the draft resumption experience, exit button placement, and host management controls.
User Objectives
- Resume Draft on Re-entry: Ensure that manually joining a room (after exiting) correctly restores the draft view if a draft is in progress.
- Exit Button Placement: Move the "Exit Room" button to be near the player's name in the lobby sidebar.
- Kick Player: Allow the Host to kick players from the room.
Proposed Changes
1. Server-Side: Kick Functionality
File: src/server/managers/RoomManager.ts
- Method:
kickPlayer(roomId, playerId) - Logic:
- Remove the player from
room.players. - If the game is active (drafting/playing), this is a destructive action. We will assume for now it removes them completely (or marks offline? "Kick" usually implies removal).
- Decision: If kicked, they are removed. If the game breaks, that's the host's responsibility.
- Remove the player from
File: src/server/index.ts
- Event:
kick_player - Logic:
- Verify requester is Host.
- Call
roomManager.kickPlayer. - Broadcast
room_update. - Emit
kickedevent to the target socket (to force them to client-side exit).
2. Client-Side: Re-entry Logic Fix
File: src/client/src/modules/lobby/GameRoom.tsx
- Logic: Ensure
GameRoomcorrectly initializes or updatesdraftStatewhen receiving new props. - Add a
useEffectto update localdraftStateifinitialDraftStateprop changes (thoughkeychange on component might be better, we'll useuseEffect).
3. Client-Side: UI Updates
File: src/client/src/modules/lobby/GameRoom.tsx
- Sidebar:
- Update the player list rendering.
- If
p.id === currentPlayerId, show an Exit/LogOut button next to the name. - If
isMeHostandp.id !== me, show a Kick/Ban button next to the name.
- Handlers:
handleKick(targetId): Warning confirmation -> Emitkick_player.handleExit(): Trigger the existingonExit.
Verification Plan
- Test Kick: Host kicks a player. Player should be removed from list and client should revert to lobby (via socket event).
- Test Exit: Click new Exit button in sidebar. Should leave room.
- Test Re-join: Join the room code again. Should immediately load the Draft View (not the Lobby View).