Files
kidgo/tools/save-diag.mjs
T
2026-10-20 22:21:26 +08:00

32 lines
1.5 KiB
JavaScript

// 诊断:每个存档点的放置环境(脚下是什么 / 重生点是否致命 / 是否在路径上)
const handlers = {};
const addL = (t, fn) => { (handlers[t] = handlers[t] || []).push(fn); };
globalThis.addEventListener = addL;
globalThis.window = { addEventListener: addL };
const { LEVELS } = await import('../js/levels/index.js');
const { Level } = await import('../js/level.js');
const { Player } = await import('../js/player.js');
const { Input } = await import('../js/input.js');
const { T } = await import('../js/level.js');
const NAME = { 0: '空', 1: '块', 2: '草', 3: '砖', 4: '金属', 5: '冰', 6: '水', 7: '单向', 8: '即死', 9: '消失', 10: '上刺', 11: '下刺', 12: '左刺', 13: '右刺' };
for (const d of LEVELS) {
const L = new Level(d);
const P = new Player(L);
const saves = L.entities.filter(e => e.type === 'save');
if (!saves.length) { console.log(`${d.id.padEnd(3)} ${d.name.padEnd(16)} ⚠ 无存档点`); continue; }
const lines = [];
for (const s of saves) {
const below = L.tileAt(s.tx, s.ty + 1);
const above = L.tileAt(s.tx, s.ty - 1);
// 重生点
const rx = s.x + s.w / 2 - P.w / 2, ry = s.y + s.h - P.h;
const deadly = L.deadlyRect(rx, ry, P.w, P.h);
const solid = L.solidRect(rx, ry, P.w, P.h);
lines.push(`(${s.tx},${s.ty}) 脚=${NAME[below] || below} 头=${NAME[above] || above}${deadly ? ' ❌重生即死' : ''}${solid ? ' ❌卡墙里' : ''}`);
}
console.log(`${d.id.padEnd(3)} ${d.name.padEnd(16)} ${saves.length} 个: ${lines.join(' | ')}`);
}