Implements additional functionality for Pokemon class, such as Status and helper function to restore PP.
This commit is contained in:
parent
1acd32b986
commit
26f8722fee
|
@ -9,6 +9,11 @@ namespace PkmnLibSharp.Battling
|
|||
{
|
||||
public class Battle : PointerWrapper
|
||||
{
|
||||
internal Battle(IntPtr ptr) : base(ptr)
|
||||
{
|
||||
Initialize(ptr);
|
||||
}
|
||||
|
||||
public Battle(BattleLibrary library, BattleParty[] parties, bool canFlee, byte numberOfSides, byte pokemonPerSide,
|
||||
ulong randomSeed)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using PkmnLibSharp.Utilities;
|
||||
|
||||
namespace PkmnLibSharp.Battling
|
||||
|
@ -5,10 +6,11 @@ namespace PkmnLibSharp.Battling
|
|||
public class BattleSide : PointerWrapper
|
||||
{
|
||||
public BattleSide(){}
|
||||
internal BattleSide(IntPtr ptr) : base(ptr){}
|
||||
|
||||
protected override void DeletePtr()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
Creaturelib.Generated.BattleSide.Destruct(Ptr);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -111,10 +111,30 @@ namespace PkmnLibSharp.Battling
|
|||
return ptr.PtrString();
|
||||
}
|
||||
}
|
||||
// TODO: Change to wrapped
|
||||
public IntPtr Battle => Creaturelib.Generated.Creature.GetBattle(Ptr);
|
||||
// TODO: Change to wrapped
|
||||
public IntPtr BattleSide => Creaturelib.Generated.Creature.GetBattleSide(Ptr);
|
||||
public Battle Battle
|
||||
{
|
||||
get
|
||||
{
|
||||
var ptr = Creaturelib.Generated.Creature.GetBattle(Ptr);
|
||||
if (_battle != null && _battle.Ptr == ptr) return _battle;
|
||||
if (TryResolvePointer(ptr, out _battle))
|
||||
return _battle;
|
||||
_battle = new Battle(ptr);
|
||||
return _battle;
|
||||
}
|
||||
}
|
||||
public BattleSide BattleSide
|
||||
{
|
||||
get
|
||||
{
|
||||
var ptr = Creaturelib.Generated.Creature.GetBattleSide(Ptr);
|
||||
if (_battleSide != null && _battleSide.Ptr == ptr) return _battleSide;
|
||||
if (TryResolvePointer(ptr, out _battleSide))
|
||||
return _battleSide;
|
||||
_battleSide = new BattleSide(ptr);
|
||||
return _battleSide;
|
||||
}
|
||||
}
|
||||
public bool IsOnBattleField => Creaturelib.Generated.Creature.IsOnBattleField(Ptr) == 1;
|
||||
public Item HeldItem
|
||||
{
|
||||
|
@ -208,6 +228,8 @@ namespace PkmnLibSharp.Battling
|
|||
}
|
||||
}
|
||||
|
||||
public string StatusName => Pkmnlib.Generated.Pokemon.GetStatusName(Ptr).PtrString();
|
||||
|
||||
public void ChangeForme(Forme forme)
|
||||
{
|
||||
_forme = null;
|
||||
|
@ -245,6 +267,10 @@ namespace PkmnLibSharp.Battling
|
|||
{
|
||||
Creaturelib.Generated.Creature.Heal(Ptr, damage, canRevive.ToNative());
|
||||
}
|
||||
public void RestoreAllPP()
|
||||
{
|
||||
Creaturelib.Generated.Creature.RestoreAllAttackUses(Ptr);
|
||||
}
|
||||
public void OverrideActiveAbility(string ability)
|
||||
{
|
||||
Creaturelib.Generated.Creature.OverrideActiveTalent(Ptr, ability.ToPtr()).Assert();
|
||||
|
@ -304,6 +330,15 @@ namespace PkmnLibSharp.Battling
|
|||
return Pkmnlib.Generated.Pokemon.GetEffortValue(Ptr, (Pkmnlib.Statistic) stat);
|
||||
}
|
||||
|
||||
public void SetStatus(string name)
|
||||
{
|
||||
Pkmnlib.Generated.Pokemon.SetStatus(Ptr, name.ToPtr());
|
||||
}
|
||||
public void ClearStatus()
|
||||
{
|
||||
Pkmnlib.Generated.Pokemon.ClearStatus(Ptr);
|
||||
}
|
||||
|
||||
private Species _displaySpecies;
|
||||
private Forme _displayForme;
|
||||
private Species _species;
|
||||
|
@ -311,6 +346,8 @@ namespace PkmnLibSharp.Battling
|
|||
private string _nickname;
|
||||
private ReadOnlyNativePtrArray<LearnedMove> _moves;
|
||||
private Nature _nature;
|
||||
private Battle _battle;
|
||||
private BattleSide _battleSide;
|
||||
|
||||
protected override void DeletePtr()
|
||||
{
|
||||
|
|
|
@ -163,6 +163,11 @@ namespace Creaturelib.Generated
|
|||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_Heal")]
|
||||
internal static extern byte Heal(IntPtr p, uint health, byte canRevive);
|
||||
|
||||
/// <param name="p">Creature *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("CreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Creature_RestoreAllAttackUses")]
|
||||
internal static extern byte RestoreAllAttackUses(IntPtr p);
|
||||
|
||||
/// <param name="p">const Creature *</param>
|
||||
/// <param name="out">const char * &</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
|
|
|
@ -7,5 +7,6 @@ namespace Pkmnlib
|
|||
internal enum PkmnEventDataKind : byte
|
||||
{
|
||||
WeatherChange = 128,
|
||||
StatusChange = 129,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Pkmnlib
|
|||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
internal enum PkmnScriptCategory : byte
|
||||
{
|
||||
Weather = 6,
|
||||
Weather = 128,
|
||||
Status = 129,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,5 +64,21 @@ namespace Pkmnlib.Generated
|
|||
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_Pokemon_GetEffortValue")]
|
||||
internal static extern byte GetEffortValue(IntPtr p, Statistic stat);
|
||||
|
||||
/// <param name="p">Pokemon *</param>
|
||||
/// <param name="name">const char *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_Pokemon_SetStatus")]
|
||||
internal static extern byte SetStatus(IntPtr p, IntPtr name);
|
||||
|
||||
/// <param name="p">Pokemon *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_Pokemon_ClearStatus")]
|
||||
internal static extern byte ClearStatus(IntPtr p);
|
||||
|
||||
/// <param name="p">Pokemon *</param>
|
||||
/// <returns>const char *</returns>
|
||||
[DllImport("pkmnLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "PkmnLib_Pokemon_GetStatusName")]
|
||||
internal static extern IntPtr GetStatusName(IntPtr p);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
BIN
PkmnLibSharp/Native/libArbutils.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/libArbutils.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/libCreatureLib.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/libCreatureLib.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/libpkmnLib.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/libpkmnLib.so (Stored with Git LFS)
Binary file not shown.
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue