- 玩法一 数字一笔:规则库、求解器、26 关、竖屏触摸 Web 原型、测试 - 玩法二 连连气球:连消畅玩版核心、Web 原型、Cocos 球槽组件与导出脚本 - 玩法三 六边一笔:规则库、求解器、10 关 + 转墙实验包、Web 原型、测试 - 产品文档、UI 设计规范、各玩法 GDD / HANDOFF - 文档移除全部外部参考作引用;删除玩法二 v0 旧稿
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import { test } from 'node:test';
|
|
import { MemoryStore, Progress, STORAGE_KEY } from '../src/progress';
|
|
|
|
const ids = ['1-1', '1-2', '1-3'];
|
|
|
|
test('线性解锁与继续', () => {
|
|
const p = new Progress(new MemoryStore());
|
|
assert.equal(p.isUnlocked(ids, 0), true);
|
|
assert.equal(p.isUnlocked(ids, 1), false);
|
|
p.markCleared('1-1');
|
|
assert.equal(p.isUnlocked(ids, 1), true);
|
|
assert.equal(p.firstUncleared(ids), '1-2');
|
|
p.markCleared('1-2');
|
|
p.markCleared('1-3');
|
|
assert.equal(p.firstUncleared(ids), '1-3');
|
|
});
|
|
|
|
test('存档桶是本玩法的,可恢复,含偏好', () => {
|
|
const store = new MemoryStore();
|
|
const p = new Progress(store);
|
|
p.markCleared('1-1');
|
|
p.setCurrent('1-2');
|
|
p.setPrefs({ sound: false });
|
|
assert.equal(STORAGE_KEY, 'mode:03-hex-walls');
|
|
assert.ok(store.get(STORAGE_KEY));
|
|
const p2 = new Progress(store);
|
|
assert.equal(p2.isCleared('1-1'), true);
|
|
assert.equal(p2.currentId, '1-2');
|
|
assert.equal(p2.prefs.sound, false);
|
|
assert.equal(p2.prefs.haptics, true);
|
|
p2.resetAll();
|
|
assert.equal(new Progress(store).clearedCount(), 0);
|
|
});
|
|
|
|
test('坏存档不炸', () => {
|
|
const store = new MemoryStore();
|
|
store.set(STORAGE_KEY, '{not json');
|
|
const p = new Progress(store);
|
|
assert.equal(p.clearedCount(), 0);
|
|
});
|