• Mahmoud Aglan's avatar
    feat: shared multiplayer module — opponent bar, synced emotes, disconnect, rematch, friend add · a220f7d0
    Mahmoud Aglan authored
    New core module: multiplayer.js
    Used by Chess, Ludo, Domino for all common multiplayer features:
    
    1. OPPONENT BAR:
       - Avatar, name, rating, level
       - Green/yellow/red connection dot
       - Tap → popup menu (view profile, add friend, report)
    
    2. SYNCED EMOTES:
       - sendEmote(matchId, type, key) → writes to game_state
       - checkForEmote(gameState, myId) → detects opponent's emote
       - onEmoteReceived(callback) → fires for UI to show floating emote
    
    3. CONNECTION STATUS:
       - Green dot = connected (< 15s since last opponent action)
       - Yellow dot = weak (15-60s)
       - Red dot = disconnected (> 60s → can claim win)
       - startDisconnectWatch / stopDisconnectWatch
    
    4. REMATCH:
       - requestRematch(matchId, type) → writes to game_state
       - checkForRematch(gameState, myId) → detects request
    
    5. FRIEND ADD:
       - addFriendFromGame(opponentId) → sends friend request
       - Accessible from opponent bar tap menu
    
    6. REPORT:
       - reportOpponent(opponentId, reason)
    
    All games can import { renderOpponentBar, sendEmote, ... } from 'core/multiplayer.js'
    Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
    a220f7d0
Name
Last commit
Last update
..
audio.js Loading commit data...
bus.js Loading commit data...
canvas.js Loading commit data...
hud.js Loading commit data...
i18n.js Loading commit data...
input.js Loading commit data...
juice.js Loading commit data...
multiplayer.js Loading commit data...
net.js Loading commit data...
realtime.js Loading commit data...
scene.js Loading commit data...
store.js Loading commit data...
theme.js Loading commit data...
tween.js Loading commit data...