feat: full_quests_path

- Added Config::full_quests_path
- Fixed quests saving in parent folder
This commit is contained in:
Alexey 2025-11-29 14:12:07 +03:00
commit 2e14614bdf
2 changed files with 21 additions and 3 deletions

View file

@ -88,6 +88,24 @@ impl Config {
}
}
/// Returns full path to quests folder
/// This path will be relative to $PWD, not to config.
///
/// # Examples
/// ```rust
/// use squad_quest::config::Config;
///
/// let path = "cfg/config.toml".into();
/// let config = Config::load(path);
///
/// let quests_path = config.full_quests_path();
/// ```
pub fn full_quests_path(&self) -> PathBuf {
let mut path = self.path.clone();
path.push(self.quests_path.clone());
path
}
/// Load [Vec]<[Quest]> from quests folder.
/// Also logs errors and counts successfully loaded quests.
///
@ -107,8 +125,7 @@ impl Config {
pub fn load_quests(&self) -> Vec<Quest> {
let mut out_vec = Vec::new();
let mut path = self.path.clone();
path.push(self.quests_path.clone());
let path = self.full_quests_path();
match fs::read_dir(path) {
Ok(iter) => {