From 904af9902221c72fab5a46909352c08c12fcd87e Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 22 Feb 2020 15:22:13 +0100 Subject: [PATCH] Update to newest version of CreatureLib, added ChoiceQueue in AngelScript. --- conanfile.py | 2 +- .../Battling/RegisterBattleClass.cpp | 18 ++++++++++++++++++ .../Battling/RegisterBattleClass.hpp | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/conanfile.py b/conanfile.py index 0cb2bb3..3942fa4 100644 --- a/conanfile.py +++ b/conanfile.py @@ -45,7 +45,7 @@ class PkmnLibConan(ConanFile): self.options["AngelScript"].link_std_statically = True def requirements(self): - self.requires("CreatureLib/d4fd7282f5fe52acafae0098168a66e4a613bffd@creaturelib/master") + self.requires("CreatureLib/32584ac4067d5997d4f8bfaa33dbfc407b19fb05@creaturelib/master") if self.options.script_handler == "angelscript": self.requires("AngelScript/2.34@AngelScript/Deukhoofd") else: diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp index 6c7eb62..1194e6f 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp @@ -4,9 +4,24 @@ #include void RegisterBattleClass::Register(asIScriptEngine* engine) { + RegisterChoiceQueue(engine); RegisterBattleRandom(engine); RegisterBattle(engine); } + +void RegisterBattleClass::RegisterChoiceQueue(asIScriptEngine* engine) { + [[maybe_unused]] int r = engine->RegisterObjectType("ChoiceQueue", 0, asOBJ_REF | asOBJ_NOCOUNT); + assert(r >= 0); + r = engine->RegisterObjectMethod("ChoiceQueue", "bool MovePokemonChoiceNext(Pokemon@ target)", + asMETHOD(CreatureLib::Battling::ChoiceQueue, MoveCreatureChoiceNext), + asCALL_THISCALL); + assert(r >= 0); + r = engine->RegisterObjectMethod("ChoiceQueue", "BaseTurnChoice Peek() const", + asMETHOD(CreatureLib::Battling::ChoiceQueue, Peek), + asCALL_THISCALL); + assert(r >= 0); +} + void RegisterBattleClass::RegisterBattleRandom(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("BattleRandom", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0); @@ -43,4 +58,7 @@ void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) { r = engine->RegisterObjectMethod("Battle", "BattleRandom@ get_Random() const property", asMETHOD(CreatureLib::Battling::Battle, GetRandom), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("Battle", "ChoiceQueue@ get_TurnQueue() const property", + asMETHOD(CreatureLib::Battling::Battle, GetCurrentTurnQueue), asCALL_THISCALL); + assert(r >= 0); } diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.hpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.hpp index 342250c..54d5050 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.hpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.hpp @@ -3,6 +3,7 @@ #include class RegisterBattleClass { + static void RegisterChoiceQueue(asIScriptEngine* engine); static void RegisterBattle(asIScriptEngine* engine); static void RegisterBattleRandom(asIScriptEngine* engine); public: