Commit Graph

55 Commits

Author SHA1 Message Date
0933644710 Fix gameManager.js syntax errors and add rematches Map to constructor 2025-12-22 17:46:46 +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
6c4aedec1d Add automatic deployment system to fix database disconnection after git pull
- 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
2025-12-22 16:09:19 +11:00
a1d51d6f26 Add production deployment instructions for PostgreSQL migration 2025-12-22 13:48:55 +11:00
0a8ea2b603 Migrate from Supabase to direct PostgreSQL connection
- Replace @supabase/supabase-js with native pg library
- Rewrite database.js to use PostgreSQL connection pool
- Update server.js with PostgreSQL connection testing
- Create postgres-schema.sql with complete database schema
- Add apply-schema.js script for easy schema deployment
- Update all documentation (README.md, DEPLOYMENT.md, deploy.sh)
- Remove Supabase-specific files and references
- Update db.config.example.js with PostgreSQL format
2025-12-22 12:54:36 +11:00
90cf68327a Fix UI overlap by truncating long status messages 2025-12-21 20:51:19 +11:00
79ffb771a8 Enhance UI with ghost piece and board glow effects 2025-12-21 20:41:19 +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
3f9ca7e2f4 Merge status message into top controls panel for better UI 2025-12-21 18:19:46 +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
5a3315ed9d Clean up deployment scripts and documentation
- 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
2025-12-21 17:44:32 +11:00
a869cff76d Add script to fix existing CloudSticks vhost
- Modifies app-connect5.conf instead of creating new file
- Adds proxy rules to existing SSL-enabled vhost
- Removes duplicate connect5-proxy.conf
- Uses correct nginx-cs service name
2025-12-21 17:28:47 +11:00
7f36f039d9 Add script to move proxy config to vhosts.d
- CloudSticks uses /etc/nginx-cs/vhosts.d/ not conf.d
- Moves existing config to correct location
- Restarts Nginx
- Tests endpoints
2025-12-21 17:17:39 +11:00
66fa37b68c Add nginx config diagnostic script 2025-12-21 17:15:00 +11:00
c3d4c9cb4b Fix CloudSticks setup to handle missing nginx command
- Auto-detects nginx binary location
- Falls back to systemctl/service commands
- Better error handling
- More detailed status reporting
2025-12-21 17:07:01 +11:00
14598ac343 Add simple CloudSticks Nginx setup using conf.d
- 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
2025-12-21 17:05:31 +11:00
0cfa72f92a Add fully automated CloudSticks Nginx setup script
- 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
2025-12-21 17:03:33 +11:00
e343f02ffe Add Nginx configuration for CloudSticks Ubuntu 24.04
- 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
2025-12-21 16:56:58 +11:00
9194961fff Add Apache config finder script 2025-12-21 16:41:20 +11:00
bd5f35f15d Add automated Apache setup script
- 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
2025-12-21 16:39:24 +11:00
94e9510ddd Add Apache proxy configuration for production
- 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
2025-12-21 16:13:02 +11:00
d7e9ab3529 Add CloudSticks deployment script without PM2 dependency
- 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
2025-12-21 16:04:24 +11:00
3f82ae04ef Remove git pull from deployment script for CloudSticks
- CloudSticks handles auto-deployment from GitHub
- Removed redundant git pull step
- Updated step numbers accordingly
2025-12-21 16:00:18 +11:00
3c42ed93d4 Fix deployment script path for production server
- Updated PROJECT_DIR to /home/github2/apps/app-connect5
- Matches actual production server directory structure
2025-12-21 15:57:09 +11:00
2f3b975003 Add production deployment script and guide
- Created automated deploy-production.sh script
- Added comprehensive PRODUCTION_DEPLOY.md guide
- Includes troubleshooting and Apache configuration
- Ready for production deployment
2025-12-21 15:50:38 +11:00
054cbf3e77 Migrate database from MySQL to Supabase PostgreSQL
- Added @supabase/supabase-js client library
- Rewrote database.js to use Supabase API
- Updated server.js health check for Supabase
- Updated db.config.example.js with Supabase format
- Created comprehensive SUPABASE_SETUP.md guide
- Added SQL schema files for easy deployment
- Updated README_DB_CONFIG.md for Supabase

Benefits:
- Managed PostgreSQL database
- Built-in Row Level Security
- Real-time capabilities
- Easy monitoring via dashboard
- Free tier for development
2025-12-21 15:40:57 +11:00
5238fc8d22 Enhanced SQL connection monitoring and diagnostics - Added detailed database status monitoring with retry functionality - Improved error handling and logging for SQL connections - Updated UI with connection status indicators and error banners 2025-12-20 15:50:34 +11:00
e7c8d890b9 Add database status bar with connection, latency, and write capability monitoring 2025-12-15 21:20:29 +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
bc76e7aab1 FIX: Prevent multiplayer initialization before game is ready
- Add polling mechanism to wait for window.game initialization
- Disable multiplayer button until game is fully initialized
- Enable button in DOMContentLoaded after game creation
- Prevents 'Game instance not found' error on production

This fixes the critical issue where clicking Multiplayer too quickly
would fail because window.game wasn't ready yet.
2025-12-14 12:07:13 +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
864048ab15 Update README.md 2025-12-13 20:02:06 +11:00
d959102db3 Fix multiplayer connection: Add redundant proxies and Socket.io CDN 2025-12-13 19:54:13 +11:00
3e8eed4eaf Security: Move database credentials to separate config file 2025-12-13 19:29:49 +11:00
858a5e52d4 Fix: Use dynamic server URL for Socket.io connection (production fix) 2025-12-13 19:21:29 +11:00
c4b5473586 Update README.md 2025-12-13 15:29:29 +11:00
930d879c28 Update README.md 2025-12-13 15:24:56 +11:00
a9054e481b Update game description in README.md
Removed a smiley face from the game description.
2025-12-13 15:23:43 +11:00
b8cd4c38ef Fix formatting in README.md 2025-12-13 15:22:19 +11:00
4bdf5ebb1c Fix typo in README.md description 2025-12-13 15:20:08 +11:00
0b24e2b3f6 Remove sensitive database screenshot from README 2025-12-13 15:15:24 +11:00
cb2b9771fe Add Play Online link and remove logo from README 2025-12-13 15:13:52 +11:00
7f4ec626af Add real game screenshots to README 2025-12-13 15:11:46 +11:00