using System.Collections.Generic;
using UnityEngine;
using YachtDice.Dice;

namespace YachtDice.Categories
{
    /// <summary>
    /// Категория «Шанс»: суммирует все дайсы без условий.
    /// </summary>
    [CreateAssetMenu(fileName = "SumAllCategory", menuName = "YachtDice/Categories/Sum All (Chance)")]
    public class SumAllCategory : CategoryDefinition
    {
        public override int Calculate(IReadOnlyList<IDie> dice)
        {
            int sum = 0;
            for (int i = 0; i < dice.Count; i++)
                sum += dice[i].Value;
            return sum;
        }

#if UNITY_EDITOR
        public static SumAllCategory CreateForTest(string id, string displayName)
        {
            var so = CreateInstance<SumAllCategory>();
            so.SetTestData(id, displayName);
            return so;
        }
#endif
    }
}
