diff --git a/.clangd b/.clangd new file mode 100644 index 0000000..87353fc --- /dev/null +++ b/.clangd @@ -0,0 +1,25 @@ +CompileFlags: + # General flags for all files + Add: [-Wall] + +# Configuration block for C++ files +--- +If: + PathMatch: .*/.cc +CompileFlags: + CompilationDatabase: "cmake" + # Add: [ + # # path to your include folder + # -I/usr/shar/include, + # # or path to your header file + # # --include=E:\path\to\your\file\file.h, + # # you can include other clang flags (clang NOT clangd!) + # -std=c++20, + # ] + +# Configuration block for C files (optional) +--- +If: + PathMatch: .*/.c +CompileFlags: + Add: [-std=c11] diff --git a/libzork/CMakeLists.txt b/libzork/CMakeLists.txt new file mode 100644 index 0000000..2ba1605 --- /dev/null +++ b/libzork/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 3.21.2) + +project(zorkxplorer) + +add_subdirectory(libzork) + +add_executable(zorkxplorer src/options.cc src/main.cc ) + +target_link_libraries(zorkxplorer PRIVATE zork) + +set_target_properties(zorkxplorer PROPERTIES CXX_STANDARD 20 + zorkxplorer PROPERTIES CXX_STANDARD_REQUIRED ON + zorkxplorer PROPERTIES CXX_EXTENSIONS OFF) +target_compile_options(zorkxplorer PUBLIC -Wall -Wextra -Werror -pedantic -std=c++20 -Wold-style-cast) + +set(CMAKE_BINARY_DIR build/) diff --git a/libzork/libzork/CMakeLists.txt b/libzork/libzork/CMakeLists.txt new file mode 100644 index 0000000..d6f37a3 --- /dev/null +++ b/libzork/libzork/CMakeLists.txt @@ -0,0 +1,35 @@ +cmake_minimum_required(VERSION 3.21.2) + +project(zork) + +set(SOURCES + src/exceptions.cc + src/runner/html_impl.cc + src/runner/html.cc + src/runner/smart_impl.cc + src/runner/smart.cc + src/runner/choice_impl.cc + src/runner/choice.cc + src/runner/interactive.cc + src/runner/runner.cc + src/vars/condition_impl.cc + src/vars/condition.cc + src/vars/action_impl.cc + src/vars/action.cc + src/store/store_impl.cc + src/store/store.cc + src/story/node_impl.cc + src/story/story_impl.cc + src/story/story.cc + src/story/node.cc + src/story/choice.cc) + +add_library(zork SHARED ${SOURCES}) + +target_include_directories(zork PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include") +target_include_directories(zork PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") + +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) diff --git a/libzork/libzork/src/story/node_impl.cc b/libzork/libzork/src/story/node_impl.cc index 11b8041..391871b 100644 --- a/libzork/libzork/src/story/node_impl.cc +++ b/libzork/libzork/src/story/node_impl.cc @@ -1,6 +1,7 @@ #include "story/node_impl.hh" #include +#include #include "exceptions.hh" @@ -8,25 +9,37 @@ namespace libzork::story { const std::string& NodeImpl::get_name() const { - throw NotImplemented(); + return name_; } const std::string& NodeImpl::get_text() const { - throw NotImplemented(); + return text_; } const Node* NodeImpl::get_choice(size_t index, bool check_conditions) const { - (void)check_conditions; - (void)index; - throw NotImplemented(); + if (choices_.size() >= index || !check_conditions) + return nullptr; + + // TODO handle check_conditions + + return choices_.at(index); } std::vector NodeImpl::list_choices(bool check_conditions) const { - (void)check_conditions; - throw NotImplemented(); + auto res = std::vector(); + if (!check_conditions) + return res; + + res.reserve(choices_.size()); + for (size_t i = 0; i < choices_.size(); i++) + { + res.push_back(choices_[i]->get_text()); + } + + return res; } void NodeImpl::add_choice( @@ -34,11 +47,9 @@ namespace libzork::story std::vector> conditions, std::vector> actions) { - (void)other; - (void)text; + // TODO handle conditions and actions (void)conditions; (void)actions; - throw NotImplemented(); } const NodeImpl& to_impl(const Node& node) diff --git a/libzork/libzork/src/story/node_impl.hh b/libzork/libzork/src/story/node_impl.hh index 6c58eb7..46d3496 100644 --- a/libzork/libzork/src/story/node_impl.hh +++ b/libzork/libzork/src/story/node_impl.hh @@ -2,6 +2,8 @@ #define NODE_IMPL_HH #include +#include +#include namespace libzork::story { @@ -22,6 +24,11 @@ namespace libzork::story const Node* other, const std::string& text, std::vector> conditions = {}, std::vector> actions = {}) override; + + private: + std::string name_; + std::string text_; + std::vector choices_; // TODO }; const NodeImpl& to_impl(const Node& node); diff --git a/lsp.md b/lsp.md new file mode 100644 index 0000000..1f1115c --- /dev/null +++ b/lsp.md @@ -0,0 +1,29 @@ +# LSP + +## QUEL ENFER + +bon le lsp casse les couilles, y a plusieurs moyens de régler ce problème (mais aucun ne marche) + +par exemple y a ça qui génère le `compile_commands.json` qui est censé aider le lsp +```sh +cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 +``` + +[Bear](https://github.com/rizsotto/Bear) peut le faire aussi +```sh +bear -- +``` + +ou alors y a la fichier .clangd + +**Mais pour l'instant rien ne marche !!** +Donc on va faire avec en attendant + +## Docs + +- [Some nice gist](https://gist.github.com/Strus/042a92a00070a943053006bf46912ae9) +- [Clangd official documentation](https://clangd.llvm.org/installation) + +## Update + +**ÇA MARCHE** (jsp si c'est grace au clangd ou la commande cmake mais oklm)