Fixes GetPokemonIndex on BattleSide, adds unit test for it.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2021-03-28 16:16:47 +02:00
parent a8e71ddd0b
commit 515446bf20
2 changed files with 88 additions and 3 deletions

View File

@@ -2,6 +2,7 @@
#include <CreatureLib/Battling/Models/Battle.hpp>
#include <CreatureLib/Battling/Models/BattleSide.hpp>
#include "../../../../Battling/Battle/Battle.hpp"
#include "../../../../Battling/Pokemon/Pokemon.hpp"
#include "../../AngelScriptScript.hpp"
#include "../HelperFile.hpp"
@@ -56,6 +57,10 @@ static asIScriptObject* AddVolatileWrapper(PkmnLib::Battling::Battle* obj, const
return scriptObject->GetRawAngelscriptObject();
}
static u8 GetPokemonIndexWrapper(CreatureLib::Battling::BattleSide* obj, PkmnLib::Battling::Pokemon* pokemon) {
return obj->GetCreatureIndex(pokemon);
}
void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) {
int r = engine->RegisterObjectMethod(
"BattleSide", "bool SwapPositions(uint8 a, uint8 b)",
@@ -65,9 +70,7 @@ void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) {
asMETHOD(CreatureLib::Battling::BattleSide, GetSideIndex), asCALL_THISCALL);
Ensure(r >= 0);
r = engine->RegisterObjectMethod("BattleSide", "uint8 GetPokemonIndex(const Pokemon@ pokemon) const",
asMETHODPR(CreatureLib::Battling::BattleSide, GetCreatureIndex,
(const ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>& c), u8),
asCALL_THISCALL);
asFUNCTION(GetPokemonIndexWrapper), asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);
}