• Mahmoud Aglan's avatar
    feat: implement 5 global multiplayer systems (DB + PHP + client) · 2ce274f3
    Mahmoud Aglan authored
    ## System 1: Match Lifecycle Manager
    - DB function `cleanup_stale_matches()` auto-abandons zombie matches
      (waiting >5min, in_progress >30min) across all games
    - Cleaned 109 existing zombies (12 ludo, 36 domino, 61 chess)
    - New `match-cleanup.php` endpoint to trigger periodically
    
    ## System 2: Universal Match Completion + Rewards
    - DB function `complete_match(game_key, match_id, winners, reason)`
      awards coins/XP, updates stats, tracks ratings for ANY game
    - Ludo now calls `action: 'complete'` on game end with ordered winners
    - Uses `reward_config` table (ludo_win_coins=40, 2nd=20, 3rd=10, 4th=5)
    - Tracks `abandon_count` on profiles for anti-abuse
    
    ## System 3: Server-Side Turn Timeout
    - Added `last_activity` column + index on ludo/domino matches
    - DB function `enforce_turn_timeout()` checked on every GET poll
    - After 20s of inactivity: marks turn as timed out
    - After 3 consecutive timeouts: flags for permanent bot replacement
    - Client handles `_turn_timed_out` response from server
    
    ## System 4: Connection State Protocol
    - DB function `match_heartbeat(game_key, match_id, player_id)`
    - Tracks per-player last_ping in game_state.connections
    - Returns other players' status: online/weak/disconnected/abandoned
    - Client sends heartbeat every 10s during live matches
    - Works across chess, ludo, domino
    
    ## System 5: Anti-Abuse + RLS Hardening
    - RLS: ludo/domino UPDATE now requires player to be participant
    - Unique index prevents duplicate queue entries per user
    - DB function `can_player_queue()` enforces 5-min cooldown after
      3+ abandons in 24h (resets daily)
    - `handleLudoLeave` now tracks bot replacement as reversible (30s grace)
    Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
    2ce274f3
Name
Last commit
Last update
..
achievements.php Loading commit data...
activity.php Loading commit data...
ads.php Loading commit data...
analysis.php Loading commit data...
auth.php Loading commit data...
avatar.php Loading commit data...
battlepass.php Loading commit data...
bots.php Loading commit data...
branding.php Loading commit data...
challenges.php Loading commit data...
chat.php Loading commit data...
config.php Loading commit data...
daily-reward.php Loading commit data...
domino-match.php Loading commit data...
domino.php Loading commit data...
friends.php Loading commit data...
game.php Loading commit data...
groups.php Loading commit data...
leaderboard.php Loading commit data...
ludo-match.php Loading commit data...
ludo.php Loading commit data...
match-cleanup.php Loading commit data...
match-history.php Loading commit data...
matchmaking.php Loading commit data...
multiplayer.php Loading commit data...
notifications.php Loading commit data...
org-apply.php Loading commit data...
orgs.php Loading commit data...
profile.php Loading commit data...
puzzles.php Loading commit data...
ratings.php Loading commit data...
shop.php Loading commit data...
swiss.php Loading commit data...
theme.php Loading commit data...
tournament-match.php Loading commit data...
tournaments.php Loading commit data...