更新离线关卡编辑器,加入单关导入和抓猪关卡转换工具
This commit is contained in:
@@ -511,8 +511,7 @@ $('import-file').onchange = guarded(async event => {
|
||||
let imported;
|
||||
try { imported = JSON.parse(await file.text()); } catch { throw new Error('导入文件不是有效的 JSON'); }
|
||||
if (state.mode !== mode || state.level.displayLevel !== number || state.revision !== revision || layoutText(state.level) !== initialLayout) throw new Error('关卡已切换或修改,请重新导入');
|
||||
if (!Array.isArray(imported.characters) || !Array.isArray(imported.aoes) || !Number.isInteger(imported.width) || !Number.isInteger(imported.height)) throw new Error('导入文件缺少棋盘尺寸或对象列表');
|
||||
const candidate = { ...state.level, width: imported.width, height: imported.height, characters: imported.characters, aoes: imported.aoes };
|
||||
const candidate = { ...state.level, ...MainlineWorkspace.importLayout(imported) };
|
||||
const result = await api('/api/validate', { level: candidate });
|
||||
if (state.mode !== mode || state.level.displayLevel !== number || state.revision !== revision || layoutText(state.level) !== initialLayout) throw new Error('关卡已切换或修改,请重新导入');
|
||||
if (result.issues.length) throw new Error('导入校验失败:' + result.issues[0].message);
|
||||
|
||||
Reference in New Issue
Block a user