using System;
using System.Runtime.InteropServices;

namespace PkmnLibSharp.Library.GrowthRates
{
    public class ExternGrowthRate : GrowthRate
    {
        public delegate uint CalculateExperienceDelegate(byte level);

        public delegate byte CalculateLevelDelegate(uint experience);

        private ExternGrowthRate(IntPtr ptr) : base(ptr)
        {
        }

        public static ExternGrowthRate Create(CalculateLevelDelegate levelFunc,
            CalculateExperienceDelegate experienceFunc)
        {
            var ptr = IntPtr.Zero;
            Creatureliblibrary.Generated.ExternGrowthRate.Construct(ref ptr,
                Marshal.GetFunctionPointerForDelegate(levelFunc),
                Marshal.GetFunctionPointerForDelegate(experienceFunc)
            );
            return new ExternGrowthRate(ptr);
        }

        protected override void DeletePtr()
        {
            Creatureliblibrary.Generated.ExternGrowthRate.Destruct(Ptr);
        }
    }
}