This commit is contained in:
Guillem George 2026-02-27 22:32:40 +01:00
parent 8ea5e9a40d
commit 50a77ac91d
6 changed files with 133 additions and 10 deletions

25
.clangd Normal file
View file

@ -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]

16
libzork/CMakeLists.txt Normal file
View file

@ -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/)

View file

@ -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)

View file

@ -1,6 +1,7 @@
#include "story/node_impl.hh" #include "story/node_impl.hh"
#include <fstream> #include <fstream>
#include <vector>
#include "exceptions.hh" #include "exceptions.hh"
@ -8,25 +9,37 @@ namespace libzork::story
{ {
const std::string& NodeImpl::get_name() const const std::string& NodeImpl::get_name() const
{ {
throw NotImplemented(); return name_;
} }
const std::string& NodeImpl::get_text() const const std::string& NodeImpl::get_text() const
{ {
throw NotImplemented(); return text_;
} }
const Node* NodeImpl::get_choice(size_t index, bool check_conditions) const const Node* NodeImpl::get_choice(size_t index, bool check_conditions) const
{ {
(void)check_conditions; if (choices_.size() >= index || !check_conditions)
(void)index; return nullptr;
throw NotImplemented();
// TODO handle check_conditions
return choices_.at(index);
} }
std::vector<std::string> NodeImpl::list_choices(bool check_conditions) const std::vector<std::string> NodeImpl::list_choices(bool check_conditions) const
{ {
(void)check_conditions; auto res = std::vector<std::string>();
throw NotImplemented(); 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( void NodeImpl::add_choice(
@ -34,11 +47,9 @@ namespace libzork::story
std::vector<std::unique_ptr<vars::Condition>> conditions, std::vector<std::unique_ptr<vars::Condition>> conditions,
std::vector<std::unique_ptr<vars::Action>> actions) std::vector<std::unique_ptr<vars::Action>> actions)
{ {
(void)other; // TODO handle conditions and actions
(void)text;
(void)conditions; (void)conditions;
(void)actions; (void)actions;
throw NotImplemented();
} }
const NodeImpl& to_impl(const Node& node) const NodeImpl& to_impl(const Node& node)

View file

@ -2,6 +2,8 @@
#define NODE_IMPL_HH #define NODE_IMPL_HH
#include <libzork/story/node.hh> #include <libzork/story/node.hh>
#include <string>
#include <vector>
namespace libzork::story namespace libzork::story
{ {
@ -22,6 +24,11 @@ namespace libzork::story
const Node* other, const std::string& text, const Node* other, const std::string& text,
std::vector<std::unique_ptr<vars::Condition>> conditions = {}, std::vector<std::unique_ptr<vars::Condition>> conditions = {},
std::vector<std::unique_ptr<vars::Action>> actions = {}) override; std::vector<std::unique_ptr<vars::Action>> actions = {}) override;
private:
std::string name_;
std::string text_;
std::vector<Choice*> choices_; // TODO
}; };
const NodeImpl& to_impl(const Node& node); const NodeImpl& to_impl(const Node& node);

29
lsp.md Normal file
View file

@ -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 -- <build commands>
```
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)