• Mahmoud Aglan's avatar
    feat: realtime multiplayer system for Chess and Ludo · e1001508
    Mahmoud Aglan authored
    New core module: realtime.js
    - WebSocket connection to Supabase Realtime
    - Auto-reconnect on disconnect (3s retry)
    - Heartbeat every 30s
    - Subscribe to any table row by filter
    - subscribeMatch(), subscribeLudoMatch(), subscribeQueue() helpers
    - Unsubscribe cleanup on leave
    
    Chess live (logic/live.js) rewritten:
    - startMatchmaking() — joins queue + subscribes for match found
    - joinMatch() — subscribes to match row, fires onMove/onStateChange
    - sendMove() — updates match with fen, move, move_count
    - sendResign(), sendDrawOffer(), sendEmote()
    - Properly increments move_count for realtime detection
    
    Ludo live (logic/live.js) new:
    - joinMatch() — subscribes to ludo_matches row
    - sendRoll() — updates positions, current_turn, dice_value
    - sendEnd() — marks game complete
    
    API game.php updated:
    - handleGameMove now supports: move_count, game_state, time remaining
    - All fields optional (only updates what's sent)
    - updated_at timestamp on every move (triggers realtime broadcast)
    
    Architecture: Player A updates row → Supabase broadcasts → Player B receives
    Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
    e1001508