package com.tiedup.remake.minigame;

import com.tiedup.remake.core.TiedUpMod;
import java.util.UUID;

/**
 * Lightweight facade over {@link LockpickSessionManager} and
 * {@link StruggleSessionManager}.
 *
 * <p>After the M15 split, this class only delegates cross-cutting concerns
 * (cleanup on disconnect, aggregate session count). Callers that need a
 * specific session type should use the sub-manager directly.
 */
public class MiniGameSessionManager {

    private static final MiniGameSessionManager INSTANCE =
        new MiniGameSessionManager();

    private MiniGameSessionManager() {}

    public static MiniGameSessionManager getInstance() {
        return INSTANCE;
    }

    /**
     * Clean up all sessions for a player (called on disconnect).
     * Delegates to both sub-managers.
     *
     * @param playerId The player UUID
     */
    public void cleanupPlayer(UUID playerId) {
        LockpickSessionManager.getInstance().cleanupPlayer(playerId);
        StruggleSessionManager.getInstance().cleanupPlayer(playerId);
        TiedUpMod.LOGGER.debug(
            "[MiniGameSessionManager] Cleaned up all sessions for player {}",
            playerId.toString().substring(0, 8)
        );
    }

    /**
     * Get count of active sessions across both sub-managers (for debugging).
     */
    public int getActiveSessionCount() {
        return (
            LockpickSessionManager.getInstance().getActiveSessionCount() +
            StruggleSessionManager.getInstance().getActiveSessionCount()
        );
    }
}
