fix: enforce echo puzzle constraints and validate maps
This commit is contained in:
+14
-9
@@ -371,6 +371,7 @@
|
||||
|
||||
const STORAGE_KEY = 'echo-loop-progress-v1';
|
||||
const MAX_PULSES = 120;
|
||||
const MAX_ECHOES = 4;
|
||||
const DIRS = Object.freeze({
|
||||
up: { dx: 0, dy: -1, key: 'U', label: '上' },
|
||||
left: { dx: -1, dy: 0, key: 'L', label: '左' },
|
||||
@@ -416,12 +417,8 @@
|
||||
map: [
|
||||
'###############',
|
||||
'#S..aA........#',
|
||||
'#.###.#####.#.#',
|
||||
'#...#.....#...#',
|
||||
'###.#.###.#.#.#',
|
||||
'#b..#...B...G.#',
|
||||
'#.###########.#',
|
||||
'#.............#',
|
||||
'#######.#######',
|
||||
'#b......B..G..#',
|
||||
'###############'
|
||||
]
|
||||
},
|
||||
@@ -535,8 +532,7 @@
|
||||
const active = new Set();
|
||||
Object.entries(state.plates).forEach(([code, point]) => {
|
||||
const occupiedByEcho = state.echoes.some((echo) => echo.x === point.x && echo.y === point.y);
|
||||
const occupiedByPlayer = state.player.x === point.x && state.player.y === point.y;
|
||||
if (occupiedByEcho || occupiedByPlayer) active.add(code);
|
||||
if (occupiedByEcho) active.add(code);
|
||||
});
|
||||
return active;
|
||||
}
|
||||
@@ -611,6 +607,15 @@
|
||||
showToast('还没有可封存的路线');
|
||||
return;
|
||||
}
|
||||
if (state.echoes.length >= MAX_ECHOES) {
|
||||
showToast('记忆库已满 · 先用现有回声完成实验');
|
||||
return;
|
||||
}
|
||||
const currentPlate = tileAt(state.player.x, state.player.y);
|
||||
if (!isPlate(currentPlate)) {
|
||||
showToast('只有站在绿色节点上,才能封存回声');
|
||||
return;
|
||||
}
|
||||
const echoNumber = state.echoes.length + 1;
|
||||
state.echoes.push({ id: echoNumber, x: state.start.x, y: state.start.y, actions: [...state.actions] });
|
||||
resetEchoPositions();
|
||||
@@ -753,7 +758,7 @@
|
||||
els.echoList.appendChild(entry);
|
||||
});
|
||||
}
|
||||
els.bankCount.textContent = `${String(state.echoes.length).padStart(2, '0')} / 04`;
|
||||
els.bankCount.textContent = `${String(state.echoes.length).padStart(2, '0')} / ${String(MAX_ECHOES).padStart(2, '0')}`;
|
||||
els.echoCoord.textContent = state.echoes.length ? `${state.echoes.length} 条记忆正在从起点重播` : '尚未封存任何记忆';
|
||||
els.echoStatus.textContent = state.echoes.length ? '在线' : '空';
|
||||
els.echoStatus.className = `objective-status${state.echoes.length ? ' live' : ''}`;
|
||||
|
||||
Reference in New Issue
Block a user