using System;
using PkmnLibSharp.Utilities;

namespace PkmnLibSharp.Battling.Events
{
    public class MoveUseEvent : EventData
    {
        internal MoveUseEvent(EventDataKind kind, IntPtr ptr) : base(kind, ptr)
        {
        }

        public ExecutingMove Move
        {
            get
            {
                if (_move != null) return _move;
                var ptr = Creaturelib.Generated.AttackUseEvent.GetAttack(Ptr);
                if (TryResolvePointer(ptr, out _move))
                    return _move!;
                _move = new ExecutingMove(ptr);
                return _move;
            }
        }

        private ExecutingMove? _move;
        protected override void DeletePtr()
        {
            Creaturelib.Generated.AttackUseEvent.Destruct(Ptr);
        }
    }
}