using System;
using System.Globalization;
using System.Linq;
using VOID.Generic.Dict;
using VOID.Generic.DynamicValue;

namespace VOID.Generic.Objects.Unit.DataCalculator
{
    public class SubAttributeCurrentMarkerGroup : IMarkerGroup
    {
        public string Group() => "SubAttribute.Current";
        
        public string[] Markers() =>
            Enum.GetValues(typeof(SubAttributeType))
                .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<SubAttributeType>(marker, true);
            return () => ((UnitObject)source).unitData.subAttributes.Get(@enum).ToString(CultureInfo.InvariantCulture);
        }
    }
}