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 ExternGrowthRate(CalculateLevelDelegate levelFunc,
            CalculateExperienceDelegate experienceFunc)
        {
            var ptr = IntPtr.Zero;
            Creaturelib.Generated.ExternGrowthRate.Construct(ref ptr,
                Marshal.GetFunctionPointerForDelegate(levelFunc),
                Marshal.GetFunctionPointerForDelegate(experienceFunc)
            );
            Initialize(ptr);
        }

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