2020-07-18 14:49:11 +00:00
|
|
|
using System;
|
2020-07-31 12:19:21 +00:00
|
|
|
using Creaturelib;
|
|
|
|
using Creaturelib.Generated;
|
2020-07-18 14:49:11 +00:00
|
|
|
using PkmnLibSharp.Library.Moves;
|
|
|
|
using PkmnLibSharp.Utilities;
|
|
|
|
|
|
|
|
namespace PkmnLibSharp.Battling
|
|
|
|
{
|
|
|
|
public class LearnedMove : PointerWrapper
|
|
|
|
{
|
|
|
|
internal LearnedMove(IntPtr ptr) : base(ptr){}
|
|
|
|
|
2020-08-08 11:57:54 +00:00
|
|
|
public LearnedMove(MoveData move, byte maxUses, MoveLearnMethod learnMethod)
|
2020-10-17 16:16:00 +00:00
|
|
|
{
|
|
|
|
Initialize(CreatePtr(move, maxUses, learnMethod));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static IntPtr CreatePtr(MoveData move, byte maxUses, MoveLearnMethod learnMethod)
|
2020-07-18 14:49:11 +00:00
|
|
|
{
|
|
|
|
var ptr = IntPtr.Zero;
|
|
|
|
LearnedAttack.Construct(ref ptr, move.Ptr, maxUses, (AttackLearnMethod) learnMethod).Assert();
|
2020-10-17 16:16:00 +00:00
|
|
|
return ptr;
|
2020-07-18 14:49:11 +00:00
|
|
|
}
|
2020-07-25 10:52:18 +00:00
|
|
|
|
|
|
|
public MoveData Move
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (_move != null) return _move;
|
|
|
|
var ptr = LearnedAttack.GetAttack(Ptr);
|
|
|
|
if (TryResolvePointer(ptr, out _move))
|
2020-08-08 12:32:27 +00:00
|
|
|
return _move!;
|
2020-08-22 14:42:56 +00:00
|
|
|
_move = Constructor.Active.ConstructMove(ptr)!;
|
2020-07-25 10:52:18 +00:00
|
|
|
return _move;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-31 12:19:21 +00:00
|
|
|
public byte MaxUses => Creaturelib.Generated.LearnedAttack.GetMaxUses(Ptr);
|
|
|
|
public byte RemainingUses => Creaturelib.Generated.LearnedAttack.GetRemainingUses(Ptr);
|
2020-07-25 10:52:18 +00:00
|
|
|
public MoveLearnMethod LearnMethod =>
|
2020-07-31 12:19:21 +00:00
|
|
|
(MoveLearnMethod) Creaturelib.Generated.LearnedAttack.GetLearnMethod(Ptr);
|
2020-07-25 10:52:18 +00:00
|
|
|
|
2020-08-08 12:32:27 +00:00
|
|
|
private MoveData? _move;
|
2021-01-15 15:53:32 +00:00
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
|
|
|
return base.ToString() + $": {Move.Name} PP: {RemainingUses}/{MaxUses}";
|
|
|
|
}
|
|
|
|
|
2020-07-18 14:49:11 +00:00
|
|
|
protected override void DeletePtr()
|
|
|
|
{
|
|
|
|
LearnedAttack.Destruct(Ptr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|