Fix wrapper for MiscLibrary ReplacementMove

This commit is contained in:
Deukhoofd 2020-09-01 12:20:54 +02:00
parent a90fb3e481
commit 2ba7dbf6a3
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 12 additions and 2 deletions

View File

@ -1,3 +1,4 @@
using System;
using PkmnLibSharp.Utilities; using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Battling.ChoiceTurn namespace PkmnLibSharp.Battling.ChoiceTurn
@ -8,6 +9,8 @@ namespace PkmnLibSharp.Battling.ChoiceTurn
: base(Creaturelib.Generated.AttackTurnChoice.Construct(user.Ptr, move.Ptr, targetSide, targetIndex)) : base(Creaturelib.Generated.AttackTurnChoice.Construct(user.Ptr, move.Ptr, targetSide, targetIndex))
{ {
} }
internal MoveTurnChoice(IntPtr ptr) : base(ptr){}
public LearnedMove Move public LearnedMove Move
{ {

View File

@ -1,5 +1,8 @@
using System; using System;
using Creaturelib.Generated;
using PkmnLibSharp.Battling.ChoiceTurn;
using PkmnLibSharp.Utilities; using PkmnLibSharp.Utilities;
using BaseTurnChoice = PkmnLibSharp.Battling.ChoiceTurn.BaseTurnChoice;
namespace PkmnLibSharp.Battling namespace PkmnLibSharp.Battling
{ {
@ -26,12 +29,16 @@ namespace PkmnLibSharp.Battling
return b == MarshalHelper.True; return b == MarshalHelper.True;
} }
public IntPtr ReplacementAttack(Pokemon user, byte sideTarget, byte creatureTarget) public BaseTurnChoice ReplacementMove(Pokemon user, byte sideTarget, byte creatureTarget)
{ {
var b = IntPtr.Zero; var b = IntPtr.Zero;
Creaturelib.Generated.MiscLibrary.ReplacementAttack(ref b, Ptr, user.Ptr, sideTarget, creatureTarget) Creaturelib.Generated.MiscLibrary.ReplacementAttack(ref b, Ptr, user.Ptr, sideTarget, creatureTarget)
.Assert(); .Assert();
return b; if (TryResolvePointer(b, out BaseTurnChoice? choice))
{
return choice!;
}
return new MoveTurnChoice(b);
} }