This commit is contained in:
2026-07-11 00:14:41 +02:00
parent 87dd8e1190
commit c9e463bb9a
15 changed files with 183 additions and 51 deletions
+7 -4
View File
@@ -29,14 +29,17 @@ pub struct Story {
}
impl Story {
pub fn load(path: &str, kv: &Store) -> Self {
/// Lädt und parst ein Ink-Skript. Fehlende oder kaputte Datei liefert
/// `Err(msg)` statt zu panicken — ein Tippfehler in einem `start_ink`-Tag
/// darf das laufende Spiel nicht crashen; der Aufrufer meldet den Fehler.
pub fn load(path: &str, kv: &Store) -> Result<Self, String> {
let src = read_to_string(path)
.unwrap_or_else(|e| panic!("ink load {}: {}", path, e));
.map_err(|e| format!("ink load {path}: {e}"))?;
let inner = BladeStory::new(&src)
.unwrap_or_else(|e| panic!("ink parse {}: {:?}", path, e));
.map_err(|e| format!("ink parse {path}: {e:?}"))?;
let mut s = Self { inner, tags: Vec::new() };
s.sync_from_kv(kv);
s
Ok(s)
}
pub fn take_tags(&mut self) -> Vec<String> { std::mem::take(&mut self.tags) }