using System;
using System.Globalization;
using System.Linq;
using VOID.Generic.Dict;
using VOID.Generic.Objects.Unit;

namespace VOID.Generic.DynamicValue.Markers
{
    public class MainAttributeBaseMarkerGroup : IMarkerGroup
    {
        public string Group() => "MainAttribute.Base";
        
        public string[] Markers() =>
            Enum.GetValues(typeof(MainAttributeType))
                .OfType<Enum>()
                .Select(@enum => @enum.ToString())
                .ToArray();

        public Type SourceType() => typeof(UnitObject);

        public Type ResultType() => typeof(int);
        
        public Func<string> Getter(object source, string marker)
        {
            var @enum = Enum.Parse<MainAttributeType>(marker, true);
            return () => ((UnitObject)source).unitData.baseMainAttributes.Get(@enum).ToString(CultureInfo.InvariantCulture);
        }
    }
}