namespace NeonSprawl.Server.Game.Mastery;

/// <summary>
/// Prototype Slice 4 mastery gate (NEO-45), mirrored from <c>scripts/validate_content.py</c>
/// <c>PROTOTYPE_SLICE4_SALVAGE_SKILL_ID</c> / <c>_prototype_slice4_gate</c>.
/// </summary>
public static class PrototypeSlice4MasteryCatalogRules
{
    /// <summary>Keep in sync with <c>scripts/validate_content.py</c> <c>PROTOTYPE_SLICE4_SALVAGE_SKILL_ID</c>.</summary>
    public const string SalvageSkillId = "salvage";

    /// <summary>Returns a human-readable error if the Slice 4 contract fails, otherwise <see langword="null"/>.</summary>
    public static string? TryGetSlice4GateError(IReadOnlyList<string> trackSkillIds)
    {
        if (trackSkillIds.Count != 1)
        {
            return
                "error: prototype Slice 4 expects exactly one MasteryTrack across all mastery files, " +
                $"got {trackSkillIds.Count} track(s) with skillIds [{string.Join(", ", trackSkillIds.Select(s => "'" + s + "'"))}]";
        }

        if (trackSkillIds[0] != SalvageSkillId)
        {
            return
                "error: prototype Slice 4 expects the sole track skillId " +
                $"'{SalvageSkillId}', got '{trackSkillIds[0]}'";
        }

        return null;
    }
}
