Fixes for clearing battle after it's finished.
This commit is contained in:
parent
e9a3a70c13
commit
ed7e655783
|
@ -124,6 +124,11 @@ namespace PkmnLibSharp.Battling
|
|||
return b == 1;
|
||||
}
|
||||
|
||||
public void EndBattle()
|
||||
{
|
||||
Creaturelib.Generated.Battle.EndBattle(Ptr).Assert();
|
||||
}
|
||||
|
||||
public void CheckChoicesSetAndRun()
|
||||
{
|
||||
Creaturelib.Generated.Battle.CheckChoicesSetAndRun(Ptr);
|
||||
|
@ -228,5 +233,11 @@ namespace PkmnLibSharp.Battling
|
|||
{
|
||||
Pkmnlib.Generated.Battle.Destruct(Ptr);
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Creaturelib.Generated.Battle.ClearBattle(Ptr);
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -359,9 +359,9 @@ namespace PkmnLibSharp.Battling
|
|||
{
|
||||
Creaturelib.Generated.Creature.Damage(Ptr, damage, (Creaturelib.DamageSource) source);
|
||||
}
|
||||
public void Heal(uint damage, bool canRevive)
|
||||
public void Heal(uint amount, bool canRevive)
|
||||
{
|
||||
Creaturelib.Generated.Creature.Heal(Ptr, damage, canRevive.ToNative());
|
||||
Creaturelib.Generated.Creature.Heal(Ptr, amount, canRevive.ToNative()).Assert();
|
||||
}
|
||||
public void RestoreAllPP()
|
||||
{
|
||||
|
|
|
@ -10,10 +10,10 @@ namespace Arbutils.Generated
|
|||
[DllImport("libArbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_C_GetLastException")]
|
||||
internal static extern IntPtr GetLastException();
|
||||
|
||||
/// <param name="">Function *</param>
|
||||
/// <param name="callback">Function *</param>
|
||||
/// <returns>void</returns>
|
||||
[DllImport("libArbutils", CallingConvention = CallingConvention.Cdecl, EntryPoint= "Arbutils_C_SetSignalCallback")]
|
||||
internal static extern void SetSignalCallback(IntPtr _);
|
||||
internal static extern void SetSignalCallback(IntPtr callback);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -197,6 +197,16 @@ namespace Creaturelib.Generated
|
|||
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_GetHistory")]
|
||||
internal static extern IntPtr GetHistory(IntPtr p);
|
||||
|
||||
/// <param name="p">Battle *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_EndBattle")]
|
||||
internal static extern byte EndBattle(IntPtr p);
|
||||
|
||||
/// <param name="p">Battle *</param>
|
||||
/// <returns>unsigned char</returns>
|
||||
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_ClearBattle")]
|
||||
internal static extern byte ClearBattle(IntPtr p);
|
||||
|
||||
/// <param name="p">const Battle *</param>
|
||||
/// <returns>long int</returns>
|
||||
[DllImport("libCreatureLib", CallingConvention = CallingConvention.Cdecl, EntryPoint= "CreatureLib_Battle_GetLastTurnTimeMicroseconds")]
|
||||
|
|
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.
|
@ -1 +1 @@
|
|||
{"enums":[{"byteSize":4,"filename":"libArbutils","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"libArbutils","name":"float_round_style","values":{"-1":"round_indeterminate","0":"round_toward_zero","1":"round_to_nearest","2":"round_toward_infinity","3":"round_toward_neg_infinity"}}],"functions":[{"filename":"libArbutils","name":"Arbutils_C_GetLastException","parameters":[],"returns":"const char *"},{"filename":"libArbutils","name":"Arbutils_C_SetSignalCallback","parameters":[{"name":"","type":"Function *"}],"returns":"void"},{"filename":"libArbutils","name":"Arbutils_Random_Construct","parameters":[],"returns":"Random *"},{"filename":"libArbutils","name":"Arbutils_Random_ConstructWithSeed","parameters":[{"name":"seed","type":"long unsigned int"}],"returns":"Random *"},{"filename":"libArbutils","name":"Arbutils_Random_Destruct","parameters":[{"name":"p","type":"Random *"}],"returns":"void"},{"filename":"libArbutils","name":"Arbutils_Random_GetFloat","parameters":[{"name":"p","type":"Random *"}],"returns":"float"},{"filename":"libArbutils","name":"Arbutils_Random_GetDouble","parameters":[{"name":"p","type":"Random *"}],"returns":"double"},{"filename":"libArbutils","name":"Arbutils_Random_Get","parameters":[{"name":"p","type":"Random *"}],"returns":"int"},{"filename":"libArbutils","name":"Arbutils_Random_GetWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"int"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsigned","parameters":[{"name":"p","type":"Random *"}],"returns":"unsigned int"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsignedWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsignedInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"unsigned int"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetSeed","parameters":[{"name":"p","type":"Random *"}],"returns":"long unsigned int"}]}
|
||||
{"enums":[{"byteSize":4,"filename":"libArbutils","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"libArbutils","name":"float_round_style","values":{"-1":"round_indeterminate","0":"round_toward_zero","1":"round_to_nearest","2":"round_toward_infinity","3":"round_toward_neg_infinity"}}],"functions":[{"filename":"libArbutils","name":"Arbutils_C_GetLastException","parameters":[],"returns":"const char *"},{"filename":"libArbutils","name":"Arbutils_C_SetSignalCallback","parameters":[{"name":"callback","type":"Function *"}],"returns":"void"},{"filename":"libArbutils","name":"Arbutils_Random_Construct","parameters":[],"returns":"Random *"},{"filename":"libArbutils","name":"Arbutils_Random_ConstructWithSeed","parameters":[{"name":"seed","type":"long unsigned int"}],"returns":"Random *"},{"filename":"libArbutils","name":"Arbutils_Random_Destruct","parameters":[{"name":"p","type":"Random *"}],"returns":"void"},{"filename":"libArbutils","name":"Arbutils_Random_GetFloat","parameters":[{"name":"p","type":"Random *"}],"returns":"float"},{"filename":"libArbutils","name":"Arbutils_Random_GetDouble","parameters":[{"name":"p","type":"Random *"}],"returns":"double"},{"filename":"libArbutils","name":"Arbutils_Random_Get","parameters":[{"name":"p","type":"Random *"}],"returns":"int"},{"filename":"libArbutils","name":"Arbutils_Random_GetWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"int"},{"name":"max","type":"int"},{"name":"out","type":"int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsigned","parameters":[{"name":"p","type":"Random *"}],"returns":"unsigned int"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsignedWithMax","parameters":[{"name":"p","type":"Random *"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetUnsignedInLimits","parameters":[{"name":"p","type":"Random *"},{"name":"min","type":"unsigned int"},{"name":"max","type":"unsigned int"},{"name":"out","type":"unsigned int &"}],"returns":"unsigned char"},{"filename":"libArbutils","name":"Arbutils_Random_GetSeed","parameters":[{"name":"p","type":"Random *"}],"returns":"long unsigned int"}]}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -77,7 +77,6 @@ namespace PkmnLibSharpTests.Battling.BattleTests
|
|||
|
||||
battle.Dispose();
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void EventListener()
|
||||
|
@ -120,6 +119,46 @@ namespace PkmnLibSharpTests.Battling.BattleTests
|
|||
|
||||
battle.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HealAfterBattle()
|
||||
{
|
||||
var lib = BattleLibraryHelper.GetLibrary();
|
||||
var p1 = BuildTestParty(lib);
|
||||
var mon1 = p1.GetAtIndex(0);
|
||||
var p2 = BuildTestParty(lib);
|
||||
var mon2 = p2.GetAtIndex(0);
|
||||
var battle =
|
||||
new BattleBuilder(lib, true, 2, 1)
|
||||
.WithPartyOnPositions(p1, new BattlePosition(0, 0))
|
||||
.WithPartyOnPositions(p2, new BattlePosition(1, 0))
|
||||
.Build();
|
||||
|
||||
var evts = new List<EventData>();
|
||||
var eventListener = new BattleEventListener(evt =>
|
||||
{
|
||||
evts.Add(evt);
|
||||
return Task.CompletedTask;
|
||||
});
|
||||
battle.RegisterEventListener(eventListener);
|
||||
|
||||
battle.SwitchPokemon(0, 0, p1.GetAtIndex(0));
|
||||
battle.SwitchPokemon(1, 0, p2.GetAtIndex(0));
|
||||
Assert.AreEqual(0, battle.CurrentTurn);
|
||||
|
||||
var moveTurn1 = new MoveTurnChoice(p1.GetAtIndex(0), p1.GetAtIndex(0).Moves[0], 1, 0 );
|
||||
var moveTurn2 = new MoveTurnChoice(p2.GetAtIndex(0), p2.GetAtIndex(0).Moves[0], 0, 0 );
|
||||
|
||||
Assert.That(battle.TrySetChoice(moveTurn1));
|
||||
Assert.That(battle.TrySetChoice(moveTurn2));
|
||||
|
||||
Assert.AreEqual(battle.CurrentTurn, 1);
|
||||
|
||||
battle.Dispose();
|
||||
|
||||
mon1.Heal(1000, true);
|
||||
mon2.Heal(1000, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue