diff --git a/PkmnLibSharp/Battling/Battle/BattleSide.cs b/PkmnLibSharp/Battling/Battle/BattleSide.cs index 86b0d06..4727d15 100644 --- a/PkmnLibSharp/Battling/Battle/BattleSide.cs +++ b/PkmnLibSharp/Battling/Battle/BattleSide.cs @@ -1,4 +1,5 @@ using System; +using PkmnLibSharp.Battling.ChoiceTurn; using PkmnLibSharp.Utilities; namespace PkmnLibSharp.Battling @@ -8,6 +9,18 @@ namespace PkmnLibSharp.Battling internal BattleSide(IntPtr ptr) : base(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) { @@ -15,7 +28,31 @@ namespace PkmnLibSharp.Battling Creaturelib.Generated.BattleSide.GetCreatureIndex(ref b, Ptr, pokemon.Ptr).Assert(); 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() { Creaturelib.Generated.BattleSide.Destruct(Ptr);