From 16293eb11c906b89646131ceaf09c5bd70fba5a5 Mon Sep 17 00:00:00 2001 From: cocos02 Date: Sat, 13 Jun 2026 01:34:41 +0800 Subject: [PATCH] fix: startChapter only overwrites specified defaultVars, no longer clears all variables --- engine/core/Engine.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/engine/core/Engine.ts b/engine/core/Engine.ts index 8554f1f..f127d42 100644 --- a/engine/core/Engine.ts +++ b/engine/core/Engine.ts @@ -384,9 +384,9 @@ export class Engine { private initChapterState(chapter: { defaultVariables?: Record }) { if (chapter.defaultVariables) { - this.stateManager.variables = { ...chapter.defaultVariables } - } else { - this.stateManager.init({}) + for (const [key, val] of Object.entries(chapter.defaultVariables)) { + this.stateManager.variables[key] = val + } } this.stateManager.flags = new Set() this.stateManager.history = []