- 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
- Re-added handleSurrender, sendRematch, acceptRematch, declineRematch methods
- Fixed to use activeGames instead of games Map
- Fixed to use correct property names (player1Id not player1_id)
- This fixes the issue where surrender would hang indefinitely
- Added opponentId field to both game_started socket emissions in acceptChallenge
- This allows client to properly track opponent for rematch requests
- Fixes surrender button not showing issue (client needs opponentId to enable features)
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
- 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
- Create post-merge git hook for auto service restart
- Add setup-auto-deploy.sh for easy installation
- Hook detects PM2, systemd, or manual process management
- Automatically runs npm install if package.json changes
- Eliminates need to manually run deploy.sh after updates
- 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
- Removed all unused/deprecated deployment scripts
- Created single unified deploy.sh script
- Added comprehensive DEPLOYMENT.md guide
- Updated README.md for Supabase migration
- Script prompts for project directory or uses current
- Auto-detects web server (Nginx/Apache/CloudSticks)
- Fully automated deployment process
- Creates separate config file in /etc/nginx-cs/conf.d/
- Avoids modifying main nginx.conf
- Simpler and safer approach
- Complete server block with SSL and proxy rules
- Hardcoded /etc/nginx-cs/ path for CloudSticks
- No user input required
- Auto-detects SSL server block
- Backs up config before changes
- Tests and reloads Nginx
- Starts Node.js if needed
- Tests both local and production endpoints
- Created setup-nginx.sh automated setup script
- Added NGINX_SETUP.md with manual instructions
- Replaces Apache config (CloudSticks uses Nginx)
- Configures proxy for /api and /socket.io
- Includes WebSocket support for multiplayer
- Created setup-apache.sh for one-command configuration
- Auto-detects Apache config file
- Enables required modules
- Adds proxy rules
- Backs up original config
- Tests and restarts Apache
- Verifies Node.js server is running
- Tests API endpoint
- Created apache-config.conf with proxy rules
- Added APACHE_FIX.md with step-by-step instructions
- Fixes 404 errors on /api and /socket.io endpoints
- Enables WebSocket support for multiplayer
- Created deploy-cloudsticks.sh for CloudSticks environment
- Works with systemd, PM2, or direct node execution
- Added CLOUDSTICKS_DEPLOY.md with specific instructions
- Handles case where PM2 is not installed