Initial layout work for allowing multiple script providers, but defaulting to AngelScript.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
eb743083de
commit
2a39467899
|
@ -8,6 +8,11 @@ project(pkmnLib)
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
if (NOT SCRIPT_PROVIDER)
|
||||||
|
message(WARNING "Script provider was not set, using angelscript as default.")
|
||||||
|
set(SCRIPT_PROVIDER "angelscript")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (WINDOWS)
|
if (WINDOWS)
|
||||||
SET(CMAKE_SYSTEM_NAME Windows)
|
SET(CMAKE_SYSTEM_NAME Windows)
|
||||||
ADD_DEFINITIONS(-D WINDOWS=1)
|
ADD_DEFINITIONS(-D WINDOWS=1)
|
||||||
|
@ -22,6 +27,8 @@ message(STATUS "Using:
|
||||||
\t CXX ABI ${CMAKE_CXX_COMPILER_ABI}
|
\t CXX ABI ${CMAKE_CXX_COMPILER_ABI}
|
||||||
\t C++ Version ${CMAKE_CXX_STANDARD}")
|
\t C++ Version ${CMAKE_CXX_STANDARD}")
|
||||||
|
|
||||||
|
message(STATUS "Script Provider: ${SCRIPT_PROVIDER}")
|
||||||
|
|
||||||
if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||||
message(WARNING "The file conanbuildinfo.cmake doesn't exist, running conan install.")
|
message(WARNING "The file conanbuildinfo.cmake doesn't exist, running conan install.")
|
||||||
string(REPLACE "." ";" VERSION_LIST "${CMAKE_C_COMPILER_VERSION}")
|
string(REPLACE "." ";" VERSION_LIST "${CMAKE_C_COMPILER_VERSION}")
|
||||||
|
@ -47,11 +54,22 @@ foreach (_conanLib ${CONAN_LIBS})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Create Core library with files in src/Core
|
# Create Core library with files in src/Core
|
||||||
file(GLOB_RECURSE CORE_SRC_FILES "src/*.cpp" "src/*.hpp")
|
file(GLOB_RECURSE CORE_SRC_FILES "src/Battling/*.cpp" "src/Battling/*.hpp" "src/Library/*.cpp" "src/Library/*.hpp")
|
||||||
add_library(pkmnLib SHARED ${CORE_SRC_FILES})
|
add_library(pkmnLib SHARED ${CORE_SRC_FILES})
|
||||||
|
|
||||||
SET(_LINKS ${CONAN_LIBS})
|
SET(_LINKS CreatureLibCore CreatureLibLibrary CreatureLibBattling)
|
||||||
SET(_TESTLINKS pkmnLib ${CONAN_LIBS})
|
SET(_TESTLINKS pkmnLib CreatureLibCore CreatureLibLibrary CreatureLibBattling)
|
||||||
|
|
||||||
|
if (SCRIPT_PROVIDER STREQUAL "angelscript")
|
||||||
|
message(STATUS "Creating angelscript implementation.")
|
||||||
|
file(GLOB_RECURSE ANGELSCRIPT_SRC_FILES "src/AngelScript/*.cpp" "src/AngelScript/*.hpp")
|
||||||
|
add_library(pkmnLib-angelscript SHARED ${ANGELSCRIPT_SRC_FILES})
|
||||||
|
SET(SCRIPT_PROVIDER_LIB_NAME "pkmnLib-angelscript")
|
||||||
|
|
||||||
|
target_link_libraries(pkmnLib-angelscript PUBLIC ${_LINKS} angelscript)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (WINDOWS)
|
if (WINDOWS)
|
||||||
message(STATUS "Using Windows build.")
|
message(STATUS "Using Windows build.")
|
||||||
|
@ -69,7 +87,7 @@ if (NOT DEFINED CONAN_EXPORTED)
|
||||||
# Create Test executable
|
# Create Test executable
|
||||||
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
||||||
add_executable(pkmnLibTests ${TEST_FILES} extern/catch.hpp)
|
add_executable(pkmnLibTests ${TEST_FILES} extern/catch.hpp)
|
||||||
target_link_libraries(pkmnLibTests PUBLIC ${_TESTLINKS})
|
target_link_libraries(pkmnLibTests PUBLIC ${_TESTLINKS} ${SCRIPT_PROVIDER_LIB_NAME})
|
||||||
|
|
||||||
# Add a definition for the test library
|
# Add a definition for the test library
|
||||||
target_compile_definitions(pkmnLibTests PRIVATE TESTS_BUILD)
|
target_compile_definitions(pkmnLibTests PRIVATE TESTS_BUILD)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
#include "AngelScriptScript.hpp"
|
|
@ -0,0 +1,6 @@
|
||||||
|
#ifndef PKMNLIB_ANGELSCRIPTSCRIPT_HPP
|
||||||
|
#define PKMNLIB_ANGELSCRIPTSCRIPT_HPP
|
||||||
|
|
||||||
|
class AngelScriptScript {};
|
||||||
|
|
||||||
|
#endif // PKMNLIB_ANGELSCRIPTSCRIPT_HPP
|
|
@ -0,0 +1,11 @@
|
||||||
|
#include "../Battling/Library/PokemonScriptResolver.hpp"
|
||||||
|
using namespace PkmnLib::Battling;
|
||||||
|
|
||||||
|
void PokemonScriptResolver::Initialize(const PkmnLib::Battling::BattleLibrary* library){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatureLib::Battling::Script* PokemonScriptResolver::LoadScript(ScriptCategory category, const std::string& scriptName){
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
#ifndef PKMNLIB_POKEMONSCRIPTRESOLVER_HPP
|
||||||
|
#define PKMNLIB_POKEMONSCRIPTRESOLVER_HPP
|
||||||
|
|
||||||
|
#include <Battling/ScriptHandling/ScriptResolver.hpp>
|
||||||
|
#include "../../Battling/Library/BattleLibrary.hpp"
|
||||||
|
namespace PkmnLib::Battling {
|
||||||
|
class PokemonScriptResolver : public CreatureLib::Battling::ScriptResolver {
|
||||||
|
public:
|
||||||
|
~PokemonScriptResolver() override = default;
|
||||||
|
void Initialize(const PkmnLib::Battling::BattleLibrary* library);
|
||||||
|
CreatureLib::Battling::Script* LoadScript(ScriptCategory category, const std::string& scriptName) override;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // PKMNLIB_POKEMONSCRIPTRESOLVER_HPP
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <Library/GrowthRates/LookupGrowthRate.hpp>
|
#include <Library/GrowthRates/LookupGrowthRate.hpp>
|
||||||
#include "../../src/Battling/Library/BattleLibrary.hpp"
|
#include "../../src/Battling/Library/BattleLibrary.hpp"
|
||||||
|
#include "../../src/Battling/Library/PokemonScriptResolver.hpp"
|
||||||
#include "../../src/Library/Moves/MoveLibrary.hpp"
|
#include "../../src/Library/Moves/MoveLibrary.hpp"
|
||||||
#include "../../src/Library/PokemonLibrary.hpp"
|
#include "../../src/Library/PokemonLibrary.hpp"
|
||||||
#include "../../src/Library/Statistic.hpp"
|
#include "../../src/Library/Statistic.hpp"
|
||||||
|
@ -20,10 +21,13 @@ public:
|
||||||
|
|
||||||
static PkmnLib::Battling::BattleLibrary* BuildLibrary() {
|
static PkmnLib::Battling::BattleLibrary* BuildLibrary() {
|
||||||
auto statCalc = new PkmnLib::Battling::StatCalculator();
|
auto statCalc = new PkmnLib::Battling::StatCalculator();
|
||||||
return new PkmnLib::Battling::BattleLibrary(
|
auto scriptResolver = new PkmnLib::Battling::PokemonScriptResolver();
|
||||||
|
auto lib = new PkmnLib::Battling::BattleLibrary(
|
||||||
BuildStaticLibrary(), statCalc, new CreatureLib::Battling::DamageLibrary(),
|
BuildStaticLibrary(), statCalc, new CreatureLib::Battling::DamageLibrary(),
|
||||||
new CreatureLib::Battling::ExperienceLibrary(), new CreatureLib::Battling::ScriptResolver(),
|
new CreatureLib::Battling::ExperienceLibrary(), scriptResolver,
|
||||||
new CreatureLib::Battling::MiscLibrary());
|
new CreatureLib::Battling::MiscLibrary());
|
||||||
|
scriptResolver->Initialize(lib);
|
||||||
|
return lib;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PkmnLib::Library::PokemonLibrary* BuildStaticLibrary() {
|
static PkmnLib::Library::PokemonLibrary* BuildStaticLibrary() {
|
||||||
|
|
Loading…
Reference in New Issue