Adds Angelscript functions for getting a battle side, and swapping positions on it.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2021-03-26 15:28:24 +01:00
parent 9f973c53df
commit 4ade8f0dca
4 changed files with 26 additions and 13 deletions

View File

@@ -1,11 +1,13 @@
#include "RegisterBattleClass.hpp"
#include <CreatureLib/Battling/Models/Battle.hpp>
#include <CreatureLib/Battling/Models/BattleSide.hpp>
#include "../../../../Battling/Battle/Battle.hpp"
#include "../HelperFile.hpp"
void RegisterBattleClass::Register(asIScriptEngine* engine) {
RegisterChoiceQueue(engine);
RegisterBattleRandom(engine);
RegisterBattleSide(engine);
RegisterBattle(engine);
}
@@ -44,6 +46,19 @@ void RegisterBattleClass::RegisterBattleRandom(asIScriptEngine* engine) {
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Battle, CreatureLib::Battling::ChoiceQueue, GetCurrentTurnQueue);
CreatureLib::Battling::BattleSide* GetBattleSideWrapper(PkmnLib::Battling::Battle* battle, u8 index) {
return battle->GetSides()[index];
}
void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) {
int r = engine->RegisterObjectType("BattleSide", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
r = engine->RegisterObjectMethod("BattleSide", "bool SwapPositions(uint8 a, uint8 b)",
asMETHODPR(CreatureLib::Battling::BattleSide, SwapPositions, (u8 a, u8 b), bool),
asCALL_THISCALL);
Ensure(r >= 0);
}
void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
[[maybe_unused]] int r = engine->RegisterObjectType("Battle", 0, asOBJ_REF | asOBJ_NOCOUNT);
Ensure(r >= 0);
@@ -82,4 +97,7 @@ void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
"Battle", "const constString& GetWeatherName() const",
asMETHODPR(PkmnLib::Battling::Battle, GetWeatherName, (), const ArbUt::StringView&), asCALL_THISCALL);
Ensure(r >= 0);
r = engine->RegisterObjectMethod("Battle", "BattleSide@ GetBattleSide(uint8 index)",
asFUNCTION(GetBattleSideWrapper), asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);
}

View File

@@ -5,6 +5,7 @@
class RegisterBattleClass {
static void RegisterChoiceQueue(asIScriptEngine* engine);
static void RegisterBattle(asIScriptEngine* engine);
static void RegisterBattleSide(asIScriptEngine* engine);
static void RegisterBattleRandom(asIScriptEngine* engine);
public: