using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// GAME 1303 Tier 4 — An ordered group of levels: a sector, a world, a chapter.
/// Create -> GAME1303 -> Level Set.
///
/// Zap Attack: four of these ("Sector 1".."Sector 4"), ten LevelData each, plus a secret set.
/// MythoClash: one per pantheon, three levels each.
/// </summary>
[CreateAssetMenu(menuName = "GAME1303/Level Set", fileName = "NewLevelSet")]
public class LevelSet : ScriptableObject
{
    public string setId = "sector1";
    public string displayName = "Sector 1";
    public Sprite banner;
    public List<LevelData> levels = new List<LevelData>();

    [Header("Set unlock")]
    [Tooltip("Set Ids that must be finished before this whole set opens.")]
    public string[] requiresSetsCleared;
    [Tooltip("How many levels in the PREVIOUS set must be cleared to open this one. 0 = ignore.")]
    public int levelsClearedRequired = 0;

    public bool IsCleared()
    {
        foreach (var l in levels)
            if (l != null && !LevelProgress.IsCleared(l.levelId)) return false;
        return true;
    }

    public int ClearedCount()
    {
        int n = 0;
        foreach (var l in levels) if (l != null && LevelProgress.IsCleared(l.levelId)) n++;
        return n;
    }
}