Fixes for some things that can be null, adds functions for LearnedMove uses
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
0486c9cdfb
commit
61e48a705a
|
@ -155,9 +155,9 @@ namespace PkmnLibSharp.Battling
|
|||
Creaturelib.Generated.Battle.ForceRecall(Ptr, side, index).Assert();
|
||||
}
|
||||
|
||||
public void SwitchPokemon(byte side, byte index, Pokemon newPokemon)
|
||||
public void SwitchPokemon(byte side, byte index, Pokemon? newPokemon)
|
||||
{
|
||||
Creaturelib.Generated.Battle.SwitchCreature(Ptr, side, index, newPokemon.Ptr).Assert();
|
||||
Creaturelib.Generated.Battle.SwitchCreature(Ptr, side, index, newPokemon?.Ptr ?? IntPtr.Zero).Assert();
|
||||
}
|
||||
|
||||
public bool CanSlotBeFilled(byte side, byte index)
|
||||
|
|
|
@ -44,10 +44,12 @@ namespace PkmnLibSharp.Battling
|
|||
Creaturelib.Generated.BattleSide.SetCreature(Ptr, pokemon.Ptr, index);
|
||||
}
|
||||
|
||||
public Pokemon GetPokemon(byte index)
|
||||
public Pokemon? GetPokemon(byte index)
|
||||
{
|
||||
var ptr = IntPtr.Zero;
|
||||
Creaturelib.Generated.BattleSide.GetCreature(ref ptr, Ptr, index);
|
||||
if (ptr == IntPtr.Zero)
|
||||
return null;
|
||||
if (TryResolvePointer(ptr, out Pokemon? pokemon))
|
||||
return pokemon!;
|
||||
return Constructor.Active.ConstructPokemon(ptr)!;
|
||||
|
|
|
@ -42,6 +42,22 @@ namespace PkmnLibSharp.Battling
|
|||
|
||||
private MoveData? _move;
|
||||
|
||||
public void DecreaseUses(byte amount)
|
||||
{
|
||||
LearnedAttack.DecreaseUses(Ptr, amount);
|
||||
}
|
||||
|
||||
public void RestoreUses(byte amount)
|
||||
{
|
||||
LearnedAttack.RestoreUses(Ptr, amount);
|
||||
}
|
||||
|
||||
public void RestoreAllUses()
|
||||
{
|
||||
LearnedAttack.RestoreAllUses(Ptr);
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return base.ToString() + $": {Move.Name} PP: {RemainingUses}/{MaxUses}";
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace PkmnLibSharp.Battling
|
|||
|
||||
protected static IntPtr CreatePtr(BattleLibrary library, Species species, Forme forme, byte level,
|
||||
uint experience, uint uid, Gender gender, byte coloring, Item? heldItem, string? nickname,
|
||||
bool hiddenAbility, byte abilityIndex, IReadOnlyCollection<LearnedMove> moves, StatisticSet<byte> ivs,
|
||||
bool hiddenAbility, byte abilityIndex, IReadOnlyCollection<LearnedMove?> moves, StatisticSet<byte> ivs,
|
||||
StatisticSet<byte> evs, Nature nature, bool allowedExperienceGain, bool isEgg)
|
||||
{
|
||||
var movesArr = moves.Select(x => x?.Ptr ?? IntPtr.Zero).ToArray();
|
||||
|
|
BIN
PkmnLibSharp/Native/Linux/libArbutils.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Linux/libArbutils.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/Linux/libCreatureLib.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Linux/libCreatureLib.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/Linux/libpkmnLib.so (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Linux/libpkmnLib.so (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/Windows/libArbutils.dll (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Windows/libArbutils.dll (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/Windows/libCreatureLib.dll (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Windows/libCreatureLib.dll (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/Windows/libangelscript.dll (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Windows/libangelscript.dll (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/Windows/libpkmnLib.dll (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Windows/libpkmnLib.dll (Stored with Git LFS)
Binary file not shown.
BIN
PkmnLibSharp/Native/Windows/libpkmnlib_ai.dll (Stored with Git LFS)
BIN
PkmnLibSharp/Native/Windows/libpkmnlib_ai.dll (Stored with Git LFS)
Binary file not shown.
Loading…
Reference in New Issue