Wrapper for BattleSide functions.

This commit is contained in:
Deukhoofd 2020-08-22 14:20:08 +02:00
parent 8080e921bc
commit 59fbe5edaa
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 38 additions and 1 deletions

View File

@ -1,4 +1,5 @@
using System; using System;
using PkmnLibSharp.Battling.ChoiceTurn;
using PkmnLibSharp.Utilities; using PkmnLibSharp.Utilities;
namespace PkmnLibSharp.Battling namespace PkmnLibSharp.Battling
@ -8,6 +9,18 @@ namespace PkmnLibSharp.Battling
internal BattleSide(IntPtr ptr) : base(ptr){} internal BattleSide(IntPtr ptr) : base(ptr){}
public byte SideIndex => Creaturelib.Generated.BattleSide.GetSideIndex(Ptr); public byte SideIndex => Creaturelib.Generated.BattleSide.GetSideIndex(Ptr);
public bool AllChoicesSet => Creaturelib.Generated.BattleSide.AllChoicesSet(Ptr) == 1;
public bool IsDefeated => Creaturelib.Generated.BattleSide.IsDefeated(Ptr) == 1;
public bool HasFled => Creaturelib.Generated.BattleSide.HasFled(Ptr) == 1;
public bool AllPossibleSlotsFilled
{
get
{
byte b = 0;
Creaturelib.Generated.BattleSide.AllPossibleSlotsFilled(ref b, Ptr).Assert();
return b == 1;
}
}
public byte IndexOf(Pokemon pokemon) public byte IndexOf(Pokemon pokemon)
{ {
@ -16,6 +29,30 @@ namespace PkmnLibSharp.Battling
return b; return b;
} }
public void SetChoice(BaseTurnChoice choice)
{
Creaturelib.Generated.BattleSide.SetChoice(Ptr, choice.Ptr).Assert();
}
public void ResetChoice()
{
Creaturelib.Generated.BattleSide.ResetChoices(Ptr);
}
public void SetPokemon(Pokemon pokemon, byte index)
{
Creaturelib.Generated.BattleSide.SetCreature(Ptr, pokemon.Ptr, index);
}
public Pokemon GetPokemon(byte index)
{
var ptr = IntPtr.Zero;
Creaturelib.Generated.BattleSide.GetCreature(ref ptr, Ptr, index);
if (TryResolvePointer(ptr, out Pokemon? pokemon))
return pokemon!;
return new Pokemon(ptr);
}
protected override void DeletePtr() protected override void DeletePtr()
{ {
Creaturelib.Generated.BattleSide.Destruct(Ptr); Creaturelib.Generated.BattleSide.Destruct(Ptr);