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

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

View File

@ -7,6 +7,7 @@ project(pkmnLib)
add_compile_options(-Wall -Wextra -Werror)
# We like new stuff, so set the c++ standard to c++20.
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
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)
@ -135,26 +136,19 @@ if (WINDOWS)
endif (WINDOWS)
if (NOT WINDOWS)
set(_LINKS ${_LINKS} -ldw)
set(_LINKS ${_LINKS} -lbfd -ldl)
endif ()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if (STATICC)
set (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed")
message(STATUS "Linking C library statically")
if (NOT UNIX AND NOT APPLE OR WINDOWS)
SET(_LINKS ${_LINKS} -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()
set(_LINKS ${_LINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lm -lstdc++ -lpthread)
SET(_TESTLINKS ${_TESTLINKS} -static-libgcc -static-libstdc++ -Wl,-Bstatic -lstdc++ -lpthread)
else()
SET(_LINKS ${_LINKS} Threads::Threads)
endif()
target_link_libraries(pkmnLib PUBLIC ${_LINKS})
target_link_libraries(pkmnLib ${_LINKS})
if (TESTS)
# Create Test executable

View File

@ -10,7 +10,7 @@ function(SetupConan)
endif (STATICC)
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.libcxx=libstdc++11
-o *:shared=True

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: