using System;
using System.Collections.Generic;
using System.Linq;

namespace FishDice.LuckyDice
{
    public sealed class DiceSetConfig
    {
        public DiceSetConfig(
            string diceSetId,
            DiceSetType setType,
            int diceCount,
            IReadOnlyList<DiceFace> faces,
            int? defaultResultSlotCount)
        {
            if (string.IsNullOrWhiteSpace(diceSetId))
            {
                throw new ArgumentException("Dice set id is required.", nameof(diceSetId));
            }

            if (diceCount <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(diceCount), "Dice count must be greater than zero.");
            }

            if (faces == null || faces.Count == 0)
            {
                throw new ArgumentException("At least one face is required.", nameof(faces));
            }

            DiceSetId = diceSetId;
            SetType = setType;
            DiceCount = diceCount;
            Faces = faces.ToArray();
            DefaultResultSlotCount = defaultResultSlotCount;
        }

        public string DiceSetId { get; }

        public DiceSetType SetType { get; }

        public int DiceCount { get; }

        public IReadOnlyList<DiceFace> Faces { get; }

        public int? DefaultResultSlotCount { get; }
    }
}
