From 83b6f31dac3b7da159ee7797db380a5d0de0d097 Mon Sep 17 00:00:00 2001 From: Guillem George Date: Sat, 28 Feb 2026 14:18:21 +0100 Subject: [PATCH] =?UTF-8?q?=C3=A7a=20build?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libzork/libzork/CMakeLists.txt | 18 ++++++++++++++++++ libzork/libzork/src/store/store_impl.cc | 5 ++--- libzork/libzork/src/store/store_impl.hh | 3 +++ libzork/libzork/src/story/choice.cc | 11 ++++++----- libzork/libzork/src/story/choice.hh | 18 +++++++++--------- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/libzork/libzork/CMakeLists.txt b/libzork/libzork/CMakeLists.txt index d6f37a3..b61e838 100644 --- a/libzork/libzork/CMakeLists.txt +++ b/libzork/libzork/CMakeLists.txt @@ -33,3 +33,21 @@ set_target_properties(zork PROPERTIES CXX_STANDARD 20 zork PROPERTIES CXX_STANDARD_REQUIRED ON zork PROPERTIES CXX_EXTENSIONS OFF) target_compile_options(zork PUBLIC -Wall -Wextra -Werror -pedantic -std=c++20 -Wold-style-cast) + +set(CMAKE_BINARY_DIR build/) + + +# Import yaml-cpp +include(FetchContent) + +FetchContent_Declare( + yaml-cpp + GIT_REPOSITORY https://github.com/jbeder/yaml-cpp.git + # GIT_TAG +) +FetchContent_MakeAvailable(yaml-cpp) + +target_link_libraries(zork PUBLIC yaml-cpp::yaml-cpp) + +target_link_options(zork PUBLIC -Wl,--no-undefined) + diff --git a/libzork/libzork/src/store/store_impl.cc b/libzork/libzork/src/store/store_impl.cc index 6b8f5ab..3abcb55 100644 --- a/libzork/libzork/src/store/store_impl.cc +++ b/libzork/libzork/src/store/store_impl.cc @@ -7,13 +7,12 @@ namespace libzork::store const story::Node* StoreImpl::get_active_node() const { - throw NotImplemented(); + return active_node_; } void StoreImpl::set_active_node(const story::Node* node) { - (void)node; - throw NotImplemented(); + active_node_ = node; } bool StoreImpl::has_variable(const std::string& name) const diff --git a/libzork/libzork/src/store/store_impl.hh b/libzork/libzork/src/store/store_impl.hh index b3cffa1..360a601 100644 --- a/libzork/libzork/src/store/store_impl.hh +++ b/libzork/libzork/src/store/store_impl.hh @@ -18,6 +18,9 @@ namespace libzork::store int get_variable(const std::string& name) const override; void set_variable(const std::string& name, int value) override; std::map get_inventory() const override; + + private: + const story::Node* active_node_ = nullptr; }; } // namespace libzork::store diff --git a/libzork/libzork/src/story/choice.cc b/libzork/libzork/src/story/choice.cc index 5d50c2a..9994c0c 100644 --- a/libzork/libzork/src/story/choice.cc +++ b/libzork/libzork/src/story/choice.cc @@ -3,9 +3,10 @@ namespace libzork::story { - Choice::Choice(Node* node, std::string& text, - std::vector>& conditions, - std::vector>& actions) + Choice::Choice( + const Node* node, const std::string& text, + const std::vector>& conditions, + const std::vector>& actions) : node_{ node } , text_{ text } { @@ -13,11 +14,11 @@ namespace libzork::story (void)actions; } - std::string& Choice::get_text() + const std::string& Choice::get_text() { return text_; } - Node* Choice::get_node() + const Node* Choice::get_node() { return node_; } diff --git a/libzork/libzork/src/story/choice.hh b/libzork/libzork/src/story/choice.hh index 30dd9cd..f080bf6 100644 --- a/libzork/libzork/src/story/choice.hh +++ b/libzork/libzork/src/story/choice.hh @@ -13,19 +13,19 @@ namespace libzork::story { public: Choice() = default; - Choice(Node* node, std::string& text, - std::vector>& conditions, - std::vector>& actions); + Choice(const Node* node, const std::string& text, + const std::vector>& conditions, + const std::vector>& actions); ~Choice() = default; - std::string& get_text(); - Node* get_node(); + const std::string& get_text(); + const Node* get_node(); private: - Node* node_; - std::string text_; - std::vector> conditions_; - std::vector> actions_; + const Node* node_; + const std::string text_; + const std::vector> conditions_; + const std::vector> actions_; }; } // namespace libzork::story