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

namespace VOID.Generic.DynamicValue.Markers
{
    public class BasicResourceMaxMarker : IMarkerGroup
    {
        public string Group() => "BasicResource.Max";
        
        public string[] Markers() =>
            Enum.GetValues(typeof(BasicResourceType))
                .OfType<Enum>()
                .Select(@enum => @enum.ToString())
                .ToArray();

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

        public Type ResultType() => typeof(float);
        
        public Func<string> Getter(object source, string marker)
        {
            var @enum = Enum.Parse<BasicResourceType>(marker, true);
            return () => ((AbstractObject)source).basicData.maxResources.Get(@enum).ToString(CultureInfo.InvariantCulture);
        }
    }
}