Commit Graph

19 Commits

Author SHA1 Message Date
d1bcf36887 Feat: Add 5-second delay and winning move highlight for game over 2025-12-23 20:34:50 +11:00
69dc70ee06 Reliability: Fix disconnect logic, add game restoration, and prevent race conditions
- gameManager.js:
  - Added disconnectTimeouts Map to track/clear pending timeouts correctly
  - Updated handleDisconnect to not abandon game if player reconnects
  - Updated registerPlayer to clear timeouts and restore active game state
  - Added race condition checks to handleSurrender and acceptRematch

- multiplayer.js:
  - Updated handleRegistration to resume active game if data provided
  - Updated startMultiplayerGame to restore board state from server data
2025-12-22 19:25:15 +11:00
a9d1327d77 Add surrender and rematch functionality - Part 2 (Complete)
Client-side (multiplayer.js):
- Add socket listeners for rematch events
- Update startMultiplayerGame to show surrender button and track opponent ID
- Update handleGameEnded to show game-over modal with stats
- Add handleRematchRequest method
- Add global helper functions for rematch acceptance/decline

Server-side (gameManager.js):
- Add rematches Map to track rematch requests
- Add handleSurrender method
- Add sendRematch, acceptRematch, declineRematch methods
- Handle surrender stats updates and game cleanup

Server (server.js):
- Add socket listeners for: surrender, send_rematch, accept_rematch, decline_rematch

Features now fully functional:
- Players can surrender during active games
- Players can request rematches after games end
- Opponents receive rematch notifications
- Game-over modal shows stats and rematch option
2025-12-22 17:42:14 +11:00
622a7e4094 Add surrender and rematch UI - Part 1
- Add surrender button to game controls
- Add game-over modal with stats and rematch option
- Add surrender confirmation modal
- Add all CSS styling for new modals and buttons
- Add surrender-rematch.js with global helper functions
- Update multiplayer.js constructor to track opponent for rematch
2025-12-22 17:39:43 +11:00
acf32d0418 Redesign status bar to split Turn Info (left) and Player Identity (right) 2025-12-21 20:15:46 +11:00
91535dc8fc Merge status and turn indicator into single UI bar 2025-12-21 20:08:33 +11:00
481de45276 Merge turn indicator with player indicator at top
- Added ID to turn label for easier updates
- Updated multiplayer.js to use turnLabel ID
- Reset turn label when switching modes or resetting game
- Improved UX by keeping player/turn info together
2025-12-21 17:52:12 +11:00
bcf3b0a032 FEATURE: Migrate username storage from localStorage to IndexedDB
- Created storage.js wrapper with IndexedDB support
- Automatic fallback to localStorage if IndexedDB unavailable
- Updated all username storage calls to use async API
- Better performance and more storage capacity
- Improved PWA compatibility

Benefits:
- 50MB+ storage vs 5-10MB localStorage
- Async API doesn't block main thread
- Better for future features (game history, stats, etc.)
2025-12-14 12:15:16 +11:00
8b275de519 CRITICAL FIX: Resolve race condition in socket listener setup
- Set up all socket listeners BEFORE connection completes
- Remove nested 'connect' listener that caused race condition
- Add comprehensive logging for registration flow
- Update all listeners to use socket parameter
- Fix window.multiplayerClient reference in retry link

This fixes the 'Registering...' stuck state issue.
2025-12-13 21:35:47 +11:00
831aa0856d Add debug logging and fix registerPlayer UI feedback 2025-12-13 20:55:30 +11:00
b57611f0c4 Fix variable scope: Ensure global access to game and multiplayer client 2025-12-13 20:34:07 +11:00
dbc3f40019 Fix Join Multiplayer race condition: Save username before socket ready 2025-12-13 20:18:44 +11:00
0739ab6257 Improve UX: Prompt for username immediately in multiplayer 2025-12-13 20:17:23 +11:00
2d34ceb8bd Fix production connection: Remove bad proxies, add UI feedback 2025-12-13 20:13:29 +11:00
d959102db3 Fix multiplayer connection: Add redundant proxies and Socket.io CDN 2025-12-13 19:54:13 +11:00
858a5e52d4 Fix: Use dynamic server URL for Socket.io connection (production fix) 2025-12-13 19:21:29 +11:00
e06ab2457d Fix auto-login loading players bug 2025-12-13 15:06:18 +11:00
a7f3bf9b9e Add localStorage username persistence for auto-login 2025-12-13 15:02:30 +11:00
9465409b2f Add complete multiplayer system with real-time gameplay, challenge system, and 50x50 board option 2025-12-13 14:59:44 +11:00