implemented game server sync

This commit is contained in:
2025-12-18 17:24:07 +01:00
parent e31323859f
commit a2a45a995c
15 changed files with 708 additions and 146 deletions

View File

@@ -0,0 +1,20 @@
# 2024-12-18 16:45:00 - Implement Game Persistence on Reload
## Description
Updated `LobbyManager.tsx` to ensure that when a user reloads the page and automatically rejoins a room, the active game state (`initialGameState`) is correctly retrieved from the server and passed to the game view components.
## Key Changes
- **Component**: `LobbyManager.tsx`
- **Functionality**:
- Added `initialGameState` state.
- Updated `join_room` and `rejoin_room` response handling to capture `gameState` if present.
- Passed `initialGameState` to the `GameRoom` component.
## Impact
- **User Experience**: If a user is in the middle of a game (battlefield phase) and refreshes the browser, they will now immediately see the battlefield state instead of a loading or broken screen, ensuring continuity.
- **Data Flow**: `GameRoom` uses this prop to initialize its local `gameState` before the first socket update event arrives.
## Status
- [x] Implementation logic complete.
- [ ] User testing required (refresh page during active game).