50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using System;
|
|
using Creaturelib.Generated;
|
|
using PkmnLibSharp.Battling.ChoiceTurn;
|
|
using PkmnLibSharp.Utilities;
|
|
using BaseTurnChoice = PkmnLibSharp.Battling.ChoiceTurn.BaseTurnChoice;
|
|
|
|
namespace PkmnLibSharp.Battling
|
|
{
|
|
public class MiscLibrary : PointerWrapper
|
|
{
|
|
internal MiscLibrary(IntPtr ptr) : base(ptr)
|
|
{
|
|
}
|
|
public MiscLibrary() : base(Pkmnlib.Generated.MiscLibrary.Construct())
|
|
{
|
|
}
|
|
|
|
public bool IsCritical(IntPtr move, Pokemon target, byte hitNumber)
|
|
{
|
|
byte b = 0;
|
|
Creaturelib.Generated.MiscLibrary.IsCritical(ref b, Ptr, move, target.Ptr, hitNumber).Assert();
|
|
return b == MarshalHelper.True;
|
|
}
|
|
|
|
public bool CanFlee(IntPtr switchChoice)
|
|
{
|
|
byte b = 0;
|
|
Creaturelib.Generated.MiscLibrary.CanFlee(ref b, Ptr, switchChoice).Assert();
|
|
return b == MarshalHelper.True;
|
|
}
|
|
|
|
public BaseTurnChoice ReplacementMove(Pokemon user, byte sideTarget, byte creatureTarget)
|
|
{
|
|
var b = IntPtr.Zero;
|
|
Creaturelib.Generated.MiscLibrary.ReplacementAttack(ref b, Ptr, user.Ptr, sideTarget, creatureTarget)
|
|
.Assert();
|
|
if (TryResolvePointer(b, out BaseTurnChoice? choice))
|
|
{
|
|
return choice!;
|
|
}
|
|
return new MoveTurnChoice(b);
|
|
}
|
|
|
|
|
|
protected override void DeletePtr()
|
|
{
|
|
Pkmnlib.Generated.MiscLibrary.Destruct(Ptr);
|
|
}
|
|
}
|
|
} |