Fixes for clearing battle after it's finished.
This commit is contained in:
10 files changed
+73
-13
No files matched your search
@@ -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")]
|
||||
|
||||
Binary file not shown.
Binary file not shown.
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"}]}
|
||||
@@ -1 +1 @@
|
||||
{"enums":[{"byteSize":4,"filename":"libCreatureLib","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"libCreatureLib","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"}},{"byteSize":1,"filename":"libCreatureLib","name":"ScriptCategory","values":{"0":"Attack","1":"Talent","2":"Status","3":"Creature","4":"Battle","5":"Side"}},{"byteSize":1,"filename":"libCreatureLib","name":"Statistic","values":{"0":"Health","1":"PhysicalAttack","2":"PhysicalDefense","3":"MagicalAttack","4":"MagicalDefense","5":"Speed"}},{"byteSize":1,"filename":"libCreatureLib","name":"Gender","values":{"0":"Male","1":"Female","2":"Genderless"}},{"byteSize":1,"filename":"libCreatureLib","name":"DamageSource","values":{"0":"AttackDamage"}},{"byteSize":1,"filename":"libCreatureLib","name":"EventDataKind","values":{"0":"Damage","1":"Heal","10":"ChangeVariant","11":"AttackUse","2":"Faint","3":"Switch","4":"TurnStart","5":"TurnEnd","6":"ExperienceGain","7":"Miss","8":"DisplayText","9":"ChangeSpecies"}},{"byteSize":1,"filename":"libCreatureLib","name":"HistoryElementKind","values":{"0":"AttackUse"}},{"byteSize":4,"filename":"libCreatureLib","name":"AttackLearnMethod","values":{"0":"Unknown","1":"Level"}},{"byteSize":1,"filename":"libCreatureLib","name":"TurnChoiceKind","values":{"0":"Pass","1":"Attack","2":"Item","3":"Switch","4":"Flee"}},{"byteSize":1,"filename":"libCreatureLib","name":"EffectParameterType","values":{"0":"None","1":"Bool","2":"Int","3":"Float","4":"String"}},{"byteSize":1,"filename":"libCreatureLib","name":"AttackCategory","values":{"0":"Physical","1":"Magical","2":"Status"}},{"byteSize":1,"filename":"libCreatureLib","name":"AttackTarget","values":{"0":"Adjacent","1":"AdjacentAlly","10":"RandomOpponent","11":"Self","2":"AdjacentAllySelf","3":"AdjacentOpponent","4":"All","5":"AllAdjacent","6":"AllAdjacentOpponent","7":"AllAlly","8":"AllOpponent","9":"Any"}},{"byteSize":1,"filename":"libCreatureLib","name":"ItemCategory","values":{"0":"MiscItem","1":"CaptureDevice","2":"Medicine","3":"Berry","4":"MoveLearner","5":"VariantChanger","6":"KeyItem","7":"Mail"}},{"byteSize":1,"filename":"libCreatureLib","name":"BattleItemCategory","values":{"0":"None","1":"Healing","2":"StatusHealing","3":"CaptureDevice","4":"MiscBattleItem"}}],"functions":[{"filename":"libCreatureLib","name":"CreatureLib_Battle_Construct","parameters":[{"name":"out","type":"Battle * &"},{"name":"library","type":"const BattleLibrary *"},{"name":"partyArr","type":"BattleParty * *"},{"name":"numberOfParties","type":"long unsigned int"},{"name":"canFlee","type":"bool"},{"name":"numberOfSides","type":"unsigned char"},{"name":"creaturesPerSide","type":"unsigned char"},{"name":"randomSeed","type":"long unsigned int"}],"returns":"unsigned char"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_Destruct","parameters":[{"name":"p","type":"const Battle *"}],"returns":"void"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetLibrary","parameters":[{"name":"p","type":"const Battle *"}],"returns":"const BattleLibrary *"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_CanUse","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"Battle *"},{"name":"turnChoice","type":"BaseTurnChoice *"}],"returns":"unsigned char"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_TrySetChoice","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"Battle *"},{"name":"turnChoice","type":"BaseTurnChoice *"}],"returns":"unsigned char"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_CanFlee","parameters":[{"name":"p","type":"const Battle *"}],"returns":"bool"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_CheckChoicesSetAndRun","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned char"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetCurrentTurn","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned int"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetCreaturesPerSide","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned int"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetCurrentTurnQueue","parameters":[{"name":"p","type":"const Battle *"}],"returns":"ChoiceQueue *"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetRandom","parameters":[{"name":"p","type":"Battle *"}],"returns":"BattleRandom *"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_CreatureInField","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"const Battle *"},{"name":"c","type":"Creature *"}],"returns":"unsigned char"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetCreature","parameters":[{"name":"out","type":"Creature * &"},{"name":"p","type":"const Battle *"},{"name":"side","type":"unsigned char"},{"name":"target","type":"unsigned char"}],"returns"Line truncated
|
||||
{"enums":[{"byteSize":4,"filename":"libCreatureLib","name":"float_denorm_style","values":{"-1":"denorm_indeterminate","0":"denorm_absent","1":"denorm_present"}},{"byteSize":4,"filename":"libCreatureLib","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"}},{"byteSize":1,"filename":"libCreatureLib","name":"ScriptCategory","values":{"0":"Attack","1":"Talent","2":"Status","3":"Creature","4":"Battle","5":"Side"}},{"byteSize":1,"filename":"libCreatureLib","name":"Statistic","values":{"0":"Health","1":"PhysicalAttack","2":"PhysicalDefense","3":"MagicalAttack","4":"MagicalDefense","5":"Speed"}},{"byteSize":1,"filename":"libCreatureLib","name":"Gender","values":{"0":"Male","1":"Female","2":"Genderless"}},{"byteSize":1,"filename":"libCreatureLib","name":"DamageSource","values":{"0":"AttackDamage"}},{"byteSize":1,"filename":"libCreatureLib","name":"EventDataKind","values":{"0":"Damage","1":"Heal","10":"ChangeVariant","11":"AttackUse","2":"Faint","3":"Switch","4":"TurnStart","5":"TurnEnd","6":"ExperienceGain","7":"Miss","8":"DisplayText","9":"ChangeSpecies"}},{"byteSize":1,"filename":"libCreatureLib","name":"HistoryElementKind","values":{"0":"AttackUse"}},{"byteSize":4,"filename":"libCreatureLib","name":"AttackLearnMethod","values":{"0":"Unknown","1":"Level"}},{"byteSize":1,"filename":"libCreatureLib","name":"TurnChoiceKind","values":{"0":"Pass","1":"Attack","2":"Item","3":"Switch","4":"Flee"}},{"byteSize":1,"filename":"libCreatureLib","name":"EffectParameterType","values":{"0":"None","1":"Bool","2":"Int","3":"Float","4":"String"}},{"byteSize":1,"filename":"libCreatureLib","name":"AttackCategory","values":{"0":"Physical","1":"Magical","2":"Status"}},{"byteSize":1,"filename":"libCreatureLib","name":"AttackTarget","values":{"0":"Adjacent","1":"AdjacentAlly","10":"RandomOpponent","11":"Self","2":"AdjacentAllySelf","3":"AdjacentOpponent","4":"All","5":"AllAdjacent","6":"AllAdjacentOpponent","7":"AllAlly","8":"AllOpponent","9":"Any"}},{"byteSize":1,"filename":"libCreatureLib","name":"ItemCategory","values":{"0":"MiscItem","1":"CaptureDevice","2":"Medicine","3":"Berry","4":"MoveLearner","5":"VariantChanger","6":"KeyItem","7":"Mail"}},{"byteSize":1,"filename":"libCreatureLib","name":"BattleItemCategory","values":{"0":"None","1":"Healing","2":"StatusHealing","3":"CaptureDevice","4":"MiscBattleItem"}}],"functions":[{"filename":"libCreatureLib","name":"CreatureLib_Battle_Construct","parameters":[{"name":"out","type":"Battle * &"},{"name":"library","type":"const BattleLibrary *"},{"name":"partyArr","type":"BattleParty * *"},{"name":"numberOfParties","type":"long unsigned int"},{"name":"canFlee","type":"bool"},{"name":"numberOfSides","type":"unsigned char"},{"name":"creaturesPerSide","type":"unsigned char"},{"name":"randomSeed","type":"long unsigned int"}],"returns":"unsigned char"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_Destruct","parameters":[{"name":"p","type":"const Battle *"}],"returns":"void"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetLibrary","parameters":[{"name":"p","type":"const Battle *"}],"returns":"const BattleLibrary *"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_CanUse","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"Battle *"},{"name":"turnChoice","type":"BaseTurnChoice *"}],"returns":"unsigned char"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_TrySetChoice","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"Battle *"},{"name":"turnChoice","type":"BaseTurnChoice *"}],"returns":"unsigned char"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_CanFlee","parameters":[{"name":"p","type":"const Battle *"}],"returns":"bool"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_CheckChoicesSetAndRun","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned char"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetCurrentTurn","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned int"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetCreaturesPerSide","parameters":[{"name":"p","type":"Battle *"}],"returns":"unsigned int"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetCurrentTurnQueue","parameters":[{"name":"p","type":"const Battle *"}],"returns":"ChoiceQueue *"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetRandom","parameters":[{"name":"p","type":"Battle *"}],"returns":"BattleRandom *"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_CreatureInField","parameters":[{"name":"out","type":"bool &"},{"name":"p","type":"const Battle *"},{"name":"c","type":"Creature *"}],"returns":"unsigned char"},{"filename":"libCreatureLib","name":"CreatureLib_Battle_GetCreature","parameters":[{"name":"out","type":"Creature * &"},{"name":"p","type":"const Battle *"},{"name":"side","type":"unsigned char"},{"name":"target","type":"unsigned char"}],"returns"Line truncated
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user