mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-06-14 02:40:45 +08:00
fix: auto-repair malformed memory scope regions
This commit is contained in:
@@ -8,7 +8,11 @@ import {
|
||||
findLatestNode,
|
||||
serializeGraph,
|
||||
} from "../graph/graph.js";
|
||||
import { normalizeMemoryScope } from "../graph/memory-scope.js";
|
||||
import {
|
||||
buildRegionLine,
|
||||
getScopeRegionTokens,
|
||||
normalizeMemoryScope,
|
||||
} from "../graph/memory-scope.js";
|
||||
import {
|
||||
normalizeStoryTime,
|
||||
normalizeStoryTimeSpan,
|
||||
@@ -73,6 +77,61 @@ assert.equal(
|
||||
"已规范的 scope 对象应直接复用",
|
||||
);
|
||||
|
||||
const malformedSecondaryScope = normalizeMemoryScope({
|
||||
layer: "objective",
|
||||
regionPrimary: "王都/钟楼",
|
||||
regionSecondary: "旧城区, 集市 / 下水道 / 钟楼",
|
||||
});
|
||||
assert.equal(malformedSecondaryScope.regionPrimary, "钟楼");
|
||||
assert.deepEqual(malformedSecondaryScope.regionPath, ["王都", "钟楼"]);
|
||||
assert.deepEqual(malformedSecondaryScope.regionSecondary, [
|
||||
"旧城区",
|
||||
"集市",
|
||||
"下水道",
|
||||
]);
|
||||
assert.deepEqual(getScopeRegionTokens(malformedSecondaryScope), [
|
||||
"钟楼",
|
||||
"王都",
|
||||
"旧城区",
|
||||
"集市",
|
||||
"下水道",
|
||||
]);
|
||||
assert.match(buildRegionLine(malformedSecondaryScope), /次级地区/);
|
||||
|
||||
const accessorBackedScope = {};
|
||||
Object.defineProperty(accessorBackedScope, "layer", {
|
||||
get() {
|
||||
return "objective";
|
||||
},
|
||||
enumerable: true,
|
||||
});
|
||||
Object.defineProperty(accessorBackedScope, "regionPrimary", {
|
||||
get() {
|
||||
return "钟楼";
|
||||
},
|
||||
enumerable: true,
|
||||
});
|
||||
Object.defineProperty(accessorBackedScope, "regionPath", {
|
||||
get() {
|
||||
return "王都 > 钟楼";
|
||||
},
|
||||
enumerable: true,
|
||||
});
|
||||
Object.defineProperty(accessorBackedScope, "regionSecondary", {
|
||||
get() {
|
||||
return { label: "旧城区 / 集市" };
|
||||
},
|
||||
enumerable: true,
|
||||
});
|
||||
const normalizedAccessorScope = normalizeMemoryScope(accessorBackedScope);
|
||||
assert.notEqual(
|
||||
normalizedAccessorScope,
|
||||
accessorBackedScope,
|
||||
"带 accessor 的 scope 不应复用原对象",
|
||||
);
|
||||
assert.deepEqual(normalizedAccessorScope.regionPath, ["王都", "钟楼"]);
|
||||
assert.deepEqual(normalizedAccessorScope.regionSecondary, ["旧城区", "集市"]);
|
||||
|
||||
const normalizedStoryTime = {
|
||||
segmentId: "tl-1",
|
||||
label: "第二天清晨",
|
||||
|
||||
Reference in New Issue
Block a user