fix: startChapter only overwrites specified defaultVars, no longer clears all variables

This commit is contained in:
2026-06-13 01:34:41 +08:00
parent e949a84171
commit 16293eb11c

View File

@@ -384,9 +384,9 @@ export class Engine {
private initChapterState(chapter: { defaultVariables?: Record<string, number> }) {
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 = []