using PkmnLibSharp.FFI; using PkmnLibSharp.StaticData; using PkmnLibSharp.Utils; using Interface = PkmnLibSharp.FFI.DynamicData.LearnedMove; namespace PkmnLibSharp.DynamicData { public class LearnedMove : ExternPointer { public class CacheData { public MoveData? MoveData { get; internal set; } public MoveLearnMethod? LearnMethod { get; internal set; } } internal LearnedMove(IdentifiablePointer ptr, bool isOwner) : base(ptr, isOwner) { } public LearnedMove(MoveData moveData, MoveLearnMethod learnMethod) { InitializePointer(Interface.learned_move_new(moveData.Ptr, learnMethod), true); } /// /// The immutable move information of the move. /// public MoveData MoveData => Cache.MoveData ??= new MoveData(Interface.learned_move_move_data(Ptr), true); /// /// The maximal power points for this move. /// public byte MaxPP => Interface.learned_move_max_pp(Ptr); /// /// The amount of remaining power points. If this is 0, we can not use the move anymore. /// public byte RemainingPP => Interface.learned_move_remaining_pp(Ptr); /// /// The way the move was learned. /// public MoveLearnMethod LearnMethod => Cache.LearnMethod ??= Interface.learned_move_learn_method(Ptr); /// /// Try and reduce the PP by a certain amount. If the amount is higher than the current remaining uses, /// return false. Otherwise, reduce the PP, and return true. /// public bool TryUse(byte amount) => Interface.learned_move_try_use(Ptr, amount) == 1; /// /// Set the remaining PP to the max amount of PP. /// public void RestoreAllUses() => Interface.learned_move_restore_all_uses(Ptr); /// /// Restore the remaining PP by a certain amount. Will prevent it from going above max PP. /// public void RestoreUses(byte amount) => Interface.learned_move_restore_uses(Ptr, amount); protected override CacheData CreateCache() => new(); protected override void Destructor() => Interface.learned_move_drop(Ptr); ~LearnedMove() { Dispose(); } } public enum MoveLearnMethod : byte { /// We do not know the learn method. Unknown = 0, /// The move was learned through level up. Level = 1, } }