• 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
.claude Loading commit data...
ChessPieces Loading commit data...
Connections and docs Loading commit data...
Logo El3ab Loading commit data...
admin Loading commit data...
api Loading commit data...
app icons Loading commit data...
config Loading commit data...
docs Loading commit data...
includes Loading commit data...
ludo-playtest Loading commit data...
promo Loading commit data...
public Loading commit data...
screenshots Loading commit data...
test-screenshots Loading commit data...
.gitignore Loading commit data...
.htaccess Loading commit data...
ARCHITECTURE.md Loading commit data...
ASSET_REGISTRY.json Loading commit data...
ASSET_REGISTRY.md Loading commit data...
BUILD_ORDER.md Loading commit data...
DATABASE_REFERENCE.md Loading commit data...
DESIGN.md Loading commit data...
Dockerfile Loading commit data...
MULTIPLAYER_RULES.md Loading commit data...
PLAN.md Loading commit data...
Stockfishbotsapi.txt Loading commit data...
bell.png Loading commit data...
captain-definition Loading commit data...
index.php Loading commit data...
logof.png Loading commit data...
manifest.json Loading commit data...
package-lock.json Loading commit data...
package.json Loading commit data...
privacy-policy.php Loading commit data...
qr-code.png Loading commit data...
terms.php Loading commit data...
test-tournament-swiss.mjs Loading commit data...
test-tournament-ui.mjs Loading commit data...