using System;
using Sirenix.OdinInspector;
using VOID.Generic.Dict;

namespace VOID.Generic.Objects.Unit.Data
{
    [Serializable]
    public record MainAttributes
    {
        [MinValue(1f)] public int strength = 5;
        [MinValue(1f)] public int dexterity = 5;
        [MinValue(1f)] public int intelligence = 5;
        [MinValue(1f)] public int constitution = 5;
        [MinValue(1f)] public int speed = 5;
        [MinValue(1f)] public int perception = 5;
        
        public int Get(MainAttributeType type)
        {
            return type switch
            {
                MainAttributeType.Strength => strength,
                MainAttributeType.Dexterity => dexterity,
                MainAttributeType.Intelligence => intelligence,
                MainAttributeType.Constitution => constitution,
                MainAttributeType.Speed => speed,
                MainAttributeType.Perception => perception,
                _ => throw new ArgumentOutOfRangeException(nameof(type), type, null)
            };
        }
        
        public void Set(MainAttributeType type, int value)
        {
            switch(type)
            {
                case MainAttributeType.Strength: strength = value; return;
                case MainAttributeType.Dexterity: dexterity = value; return;
                case MainAttributeType.Intelligence: intelligence = value; return;
                case MainAttributeType.Constitution: constitution = value; return;
                case MainAttributeType.Speed: speed = value; return;
                case MainAttributeType.Perception: perception = value; return;
                default: throw new ArgumentOutOfRangeException(nameof(type), type, null);
            };
        }
    }
}