aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoic Guegan <manzerbredes@mailbox.org>2023-01-19 15:51:12 +0100
committerLoic Guegan <manzerbredes@mailbox.org>2023-01-19 15:51:12 +0100
commit81f06cb209d9d3f092e3ed0ef2e2dbc6b288f1de (patch)
treee610487345e8f8ea78571d262946e978b7ae6247
parentda8857549304590d8d32e643a22617318add542a (diff)
Integrate Chess Move Interface
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--.gitmodules3
-rw-r--r--CMakeLists.txt13
m---------libs/chess-move-interface0
-rw-r--r--src/HalfMove.cpp16
-rw-r--r--src/HalfMove.hpp4
-rw-r--r--tests/CMakeLists.txt8
7 files changed, 38 insertions, 8 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 014eeb4..709f835 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -3,4 +3,4 @@ archlinux:
before_script:
- pacman -Sy cmake --noconfirm --needed
script:
- - mkdir build && cd build && cmake ../ && make && ctest
+ - mkdir build && cd build && cmake ../ -DCOMPILE_TESTS:BOOL:ON && make && ctest
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..704f939
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "libs/chess-move-interface"]
+ path = libs/chess-move-interface
+ url = git@gitlab.com:manzerbredes/chess-move-interface.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 64447e9..fd5cddf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,9 +12,16 @@ configure_file(src/PGN.hpp ${PGNP_INCLUDE_DIR}/pgnp.hpp COPYONLY)
configure_file(src/HalfMove.hpp ${PGNP_INCLUDE_DIR} COPYONLY)
configure_file(src/LargeFileStream.hpp ${PGNP_INCLUDE_DIR} COPYONLY)
configure_file(src/Types.hpp ${PGNP_INCLUDE_DIR} COPYONLY)
-
include_directories(${PGNP_INCLUDE_DIR})
+# ChessMoveInterface
+add_subdirectory(libs/chess-move-interface)
+include_directories(${CMI_INCLUDE_DIR})
+
# Unit tests
-enable_testing()
-add_subdirectory(./tests)
+set(COMPILE_TESTS OFF CACHE BOOL "Should unit tests be compiled")
+if(COMPILE_TESTS)
+ enable_testing()
+ add_subdirectory(./tests)
+endif()
+
diff --git a/libs/chess-move-interface b/libs/chess-move-interface
new file mode 160000
+Subproject 3a4af94254d21e51ae260ad71fcc605ebb7e734
diff --git a/src/HalfMove.cpp b/src/HalfMove.cpp
index 81d9a67..c1e4667 100644
--- a/src/HalfMove.cpp
+++ b/src/HalfMove.cpp
@@ -78,4 +78,20 @@ HalfMove *HalfMove::GetHalfMoveAt(int distance) {
return (tmp);
}
+CMI::HalfMove *HalfMove::GetAsCMI(){
+ CMI::HalfMove *m=new CMI::HalfMove();
+ m->SetSAN(move);
+ m->SetNumber(count);
+ m->SetIsBlack(isBlack);
+ m->SetComment(comment);
+ m->SetNAG(NAG);
+ if(MainLine!=NULL){
+ m->SetMainline(MainLine->GetAsCMI());
+ }
+ for (HalfMove *var : variations) {
+ m->AddVariation(var->GetAsCMI());
+ }
+ return m;
+}
+
} // namespace pgnp \ No newline at end of file
diff --git a/src/HalfMove.hpp b/src/HalfMove.hpp
index 45eb96c..c836a3e 100644
--- a/src/HalfMove.hpp
+++ b/src/HalfMove.hpp
@@ -5,6 +5,8 @@
#include <string>
#include <vector>
+#include "CMI.hpp"
+
namespace pgnp {
/**
@@ -40,6 +42,8 @@ public:
void Copy(HalfMove *copy);
/// @brief Get HalfMove located x down the MainLine
HalfMove *GetHalfMoveAt(int);
+ /// @brief Get CMI version of HalfMove
+ CMI::HalfMove *GetAsCMI();
};
struct HalfMoveOutOfRange : public std::exception {
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 4b0d167..c31bdf9 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -8,17 +8,17 @@ add_library(pgnp_catch3 SHARED ./catch3/catch_amalgamated.cpp)
# Add tests
add_executable(pgnp_valid valid.cpp)
-target_link_libraries(pgnp_valid pgnp pgnp_catch3)
+target_link_libraries(pgnp_valid pgnp pgnp_catch3 ChessMoveInterface)
add_test(PGNP_Valid_PGN_Set pgnp_valid)
add_executable(pgnp_str str.cpp)
-target_link_libraries(pgnp_str pgnp pgnp_catch3)
+target_link_libraries(pgnp_str pgnp pgnp_catch3 ChessMoveInterface)
add_test(PGNP_STR_Compliant_Set pgnp_str)
add_executable(pgnp_combined combined.cpp)
-target_link_libraries(pgnp_combined pgnp pgnp_catch3)
+target_link_libraries(pgnp_combined pgnp pgnp_catch3 ChessMoveInterface)
add_test(PGNP_Combined_Set pgnp_combined)
add_executable(from_string from_string.cpp)
-target_link_libraries(from_string pgnp pgnp_catch3)
+target_link_libraries(from_string pgnp pgnp_catch3 ChessMoveInterface)
add_test(PGNP_FromString_Set from_string)