PkmnLibRSharp/PkmnLibRSharp/DynamicData/LearnedMove.cs

64 lines
2.3 KiB
C#

using PkmnLibSharp.StaticData;
using PkmnLibSharp.Utils;
using Interface = PkmnLibSharp.FFI.DynamicData.LearnedMove;
namespace PkmnLibSharp.DynamicData
{
public class LearnedMove : HandleType
{
private LearnedMove(FFIHandle handle) : base(handle){}
public static LearnedMove Create(MoveData moveData, MoveLearnMethod learnMethod)
{
var handle = Interface.learned_move_new(moveData.Handle, learnMethod);
return Resolver.Instance.ResolveLearnedMove(handle.Resolve());
}
private MoveData? _moveData;
/// <summary>
/// The immutable move information of the move.
/// </summary>
public MoveData MoveData => _moveData ??= Resolver.Instance.ResolveMoveData(Interface.learned_move_move_data(Handle).Resolve());
/// <summary>
/// The maximal power points for this move.
/// </summary>
public byte MaxPP => Interface.learned_move_max_pp(Handle);
/// <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(Handle);
private MoveLearnMethod? _learnMethod;
/// <summary>
/// The way the move was learned.
/// </summary>
public MoveLearnMethod LearnMethod => _learnMethod ??= Interface.learned_move_learn_method(Handle);
/// <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(Handle, amount) == 1;
/// <summary>
/// Set the remaining PP to the max amount of PP.
/// </summary>
public void RestoreAllUses() => Interface.learned_move_restore_all_uses(Handle);
/// <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(Handle, amount);
}
public enum MoveLearnMethod : byte
{
/// We do not know the learn method.
Unknown = 0,
/// The move was learned through level up.
Level = 1,
}
}