Adds Angelscript functions for getting a battle side, and swapping positions on it.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
9f973c53df
commit
4ade8f0dca
|
@ -7,6 +7,7 @@ project(pkmnLib)
|
||||||
add_compile_options(-Wall -Wextra -Werror)
|
add_compile_options(-Wall -Wextra -Werror)
|
||||||
# We like new stuff, so set the c++ standard to c++20.
|
# We like new stuff, so set the c++ standard to c++20.
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||||
|
|
||||||
option(WINDOWS "Whether the build target is Windows or not." OFF)
|
option(WINDOWS "Whether the build target is Windows or not." OFF)
|
||||||
option(SHARED "Whether we should build a shared library, instead of a static one." OFF)
|
option(SHARED "Whether we should build a shared library, instead of a static one." OFF)
|
||||||
|
@ -135,26 +136,19 @@ if (WINDOWS)
|
||||||
endif (WINDOWS)
|
endif (WINDOWS)
|
||||||
|
|
||||||
if (NOT WINDOWS)
|
if (NOT WINDOWS)
|
||||||
set(_LINKS ${_LINKS} -ldw)
|
set(_LINKS ${_LINKS} -lbfd -ldl)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
||||||
find_package(Threads REQUIRED)
|
|
||||||
|
|
||||||
if (STATICC)
|
if (STATICC)
|
||||||
|
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
|
||||||
message(STATUS "Linking C library statically")
|
message(STATUS "Linking C library statically")
|
||||||
if (NOT UNIX AND NOT APPLE OR WINDOWS)
|
set(_LINKS ${_LINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lm -lstdc++ -lpthread)
|
||||||
SET(_LINKS ${_LINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)
|
SET(_TESTLINKS ${_TESTLINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)
|
||||||
SET(_TESTLINKS ${_TESTLINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)
|
|
||||||
else()
|
|
||||||
SET(_LINKS ${_LINKS} Threads::Threads -static-libgcc -static-libstdc++)
|
|
||||||
SET(_TESTLINKS ${_TESTLINKS} Threads::Threads -static-libgcc -static-libstdc++)
|
|
||||||
endif()
|
|
||||||
else()
|
else()
|
||||||
SET(_LINKS ${_LINKS} Threads::Threads)
|
SET(_LINKS ${_LINKS} Threads::Threads)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_link_libraries(pkmnLib PUBLIC ${_LINKS})
|
target_link_libraries(pkmnLib ${_LINKS})
|
||||||
|
|
||||||
if (TESTS)
|
if (TESTS)
|
||||||
# Create Test executable
|
# Create Test executable
|
||||||
|
|
|
@ -10,7 +10,7 @@ function(SetupConan)
|
||||||
endif (STATICC)
|
endif (STATICC)
|
||||||
|
|
||||||
if (NOT WINDOWS)
|
if (NOT WINDOWS)
|
||||||
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated
|
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build=missing
|
||||||
-s compiler=clang
|
-s compiler=clang
|
||||||
-s compiler.libcxx=libstdc++11
|
-s compiler.libcxx=libstdc++11
|
||||||
-o *:shared=True
|
-o *:shared=True
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
#include "RegisterBattleClass.hpp"
|
#include "RegisterBattleClass.hpp"
|
||||||
#include <CreatureLib/Battling/Models/Battle.hpp>
|
#include <CreatureLib/Battling/Models/Battle.hpp>
|
||||||
|
#include <CreatureLib/Battling/Models/BattleSide.hpp>
|
||||||
#include "../../../../Battling/Battle/Battle.hpp"
|
#include "../../../../Battling/Battle/Battle.hpp"
|
||||||
#include "../HelperFile.hpp"
|
#include "../HelperFile.hpp"
|
||||||
|
|
||||||
void RegisterBattleClass::Register(asIScriptEngine* engine) {
|
void RegisterBattleClass::Register(asIScriptEngine* engine) {
|
||||||
RegisterChoiceQueue(engine);
|
RegisterChoiceQueue(engine);
|
||||||
RegisterBattleRandom(engine);
|
RegisterBattleRandom(engine);
|
||||||
|
RegisterBattleSide(engine);
|
||||||
RegisterBattle(engine);
|
RegisterBattle(engine);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,6 +46,19 @@ void RegisterBattleClass::RegisterBattleRandom(asIScriptEngine* engine) {
|
||||||
|
|
||||||
BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Battle, CreatureLib::Battling::ChoiceQueue, GetCurrentTurnQueue);
|
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) {
|
void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("Battle", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
[[maybe_unused]] int r = engine->RegisterObjectType("Battle", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
@ -82,4 +97,7 @@ void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {
|
||||||
"Battle", "const constString& GetWeatherName() const",
|
"Battle", "const constString& GetWeatherName() const",
|
||||||
asMETHODPR(PkmnLib::Battling::Battle, GetWeatherName, (), const ArbUt::StringView&), asCALL_THISCALL);
|
asMETHODPR(PkmnLib::Battling::Battle, GetWeatherName, (), const ArbUt::StringView&), asCALL_THISCALL);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("Battle", "BattleSide@ GetBattleSide(uint8 index)",
|
||||||
|
asFUNCTION(GetBattleSideWrapper), asCALL_CDECL_OBJFIRST);
|
||||||
|
Ensure(r >= 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
class RegisterBattleClass {
|
class RegisterBattleClass {
|
||||||
static void RegisterChoiceQueue(asIScriptEngine* engine);
|
static void RegisterChoiceQueue(asIScriptEngine* engine);
|
||||||
static void RegisterBattle(asIScriptEngine* engine);
|
static void RegisterBattle(asIScriptEngine* engine);
|
||||||
|
static void RegisterBattleSide(asIScriptEngine* engine);
|
||||||
static void RegisterBattleRandom(asIScriptEngine* engine);
|
static void RegisterBattleRandom(asIScriptEngine* engine);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue