From 903ce71ad74325dc01138eec517d265c477a6f62 Mon Sep 17 00:00:00 2001 From: Ansolve Date: Thu, 4 Jan 2024 18:12:39 +0800 Subject: [PATCH] refactor: info improve. --- noname/init/import.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/noname/init/import.js b/noname/init/import.js index 5125c92e1..80135a91c 100644 --- a/noname/init/import.js +++ b/noname/init/import.js @@ -2,21 +2,25 @@ import { Game as game } from '../game/index.js'; /** * @param {string} name - 卡牌包名 + * @returns {Promise} */ export const importCardPack = generateImportFunction('card', (name) => `../../card/${name}.js`) /** * @param {string} name - 武将包名 + * @returns {Promise} */ export const importCharacterPack = generateImportFunction('character', (name) => `../../character/${name}.js`) /** * @param {string} name - 扩展名 + * @returns {Promise} */ export const importExtension = generateImportFunction('extension', (name) => `../../extension/${name}/extension.js`) /** - * @param {string} name - 模式名 + * @param {string} name - 模式名 + * @returns {Promise} */ export const importMode = generateImportFunction('mode', (name) => `../../mode/${name}.js`) @@ -28,11 +32,11 @@ export const importMode = generateImportFunction('mode', (name) => `../../mode/$ * @returns {(name: string) => Promise} */ function generateImportFunction(type, pathParser) { - return async function (name) { + return async (name) => { try { const modeContent = await import(pathParser(name)); if (!modeContent.type) return; - if (modeContent.type !== type) throw new Error(`Loaded Content doesnt conform to "${type}"`); + if (modeContent.type !== type) throw new Error(`Loaded Content doesn't conform to "${type}" but "${modeContent.type}".`); await game.import(type, modeContent.default); } catch (e) { console.error(e);