78 lines
2.6 KiB
C#
78 lines
2.6 KiB
C#
using PkmnLibSharp.FFI;
|
|
using PkmnLibSharp.StaticData;
|
|
using PkmnLibSharp.Utils;
|
|
using Interface = PkmnLibSharp.FFI.DynamicData.LearnedMove;
|
|
|
|
namespace PkmnLibSharp.DynamicData
|
|
{
|
|
public class LearnedMove : ExternPointer<LearnedMove.CacheData>
|
|
{
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// The immutable move information of the move.
|
|
/// </summary>
|
|
public MoveData MoveData => Cache.MoveData ??= new MoveData(Interface.learned_move_move_data(Ptr), true);
|
|
|
|
/// <summary>
|
|
/// The maximal power points for this move.
|
|
/// </summary>
|
|
public byte MaxPP => Interface.learned_move_max_pp(Ptr);
|
|
|
|
/// <summary>
|
|
/// The amount of remaining power points. If this is 0, we can not use the move anymore.
|
|
/// </summary>
|
|
public byte RemainingPP => Interface.learned_move_remaining_pp(Ptr);
|
|
|
|
/// <summary>
|
|
/// The way the move was learned.
|
|
/// </summary>
|
|
public MoveLearnMethod LearnMethod => Cache.LearnMethod ??= Interface.learned_move_learn_method(Ptr);
|
|
|
|
/// <summary>
|
|
/// 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.
|
|
/// </summary>
|
|
public bool TryUse(byte amount) => Interface.learned_move_try_use(Ptr, amount) == 1;
|
|
|
|
/// <summary>
|
|
/// Set the remaining PP to the max amount of PP.
|
|
/// </summary>
|
|
public void RestoreAllUses() => Interface.learned_move_restore_all_uses(Ptr);
|
|
|
|
/// <summary>
|
|
/// Restore the remaining PP by a certain amount. Will prevent it from going above max PP.
|
|
/// </summary>
|
|
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,
|
|
}
|
|
} |