From 9dc8553cf06efc6444c0ddaa27068f7c472a4913 Mon Sep 17 00:00:00 2001 From: Aluxes <39981645+AshenAshes@users.noreply.github.com> Date: Sat, 22 Jun 2024 06:28:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=98=9F=E9=93=81=E6=94=AF=E6=8C=81=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=87=AA=E5=AE=9A=E4=B9=89=E8=AF=84=E5=88=86=E8=A7=84?= =?UTF-8?q?=E5=88=99=E5=92=8C=E4=BC=A4=E5=AE=B3=E8=AE=A1=E7=AE=97=EF=BC=8C?= =?UTF-8?q?=E5=9C=A8=E5=AF=B9=E5=BA=94=E8=A7=92=E8=89=B2=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E4=B8=8B=E6=96=B0=E5=BB=BAartis=5Fuser.js=E5=92=8Ccalc=5Fuser.?= =?UTF-8?q?js=E5=8D=B3=E5=8F=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/character/CharCfg.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/models/character/CharCfg.js b/models/character/CharCfg.js index 430c470e..aedeac77 100644 --- a/models/character/CharCfg.js +++ b/models/character/CharCfg.js @@ -3,11 +3,12 @@ import lodash from 'lodash' import fs from 'node:fs' import { miaoPath } from '#miao.path' -const charPath = `${miaoPath}/resources/meta-gs/character` let cfgMap = { char: {}, - async init () { - let chars = fs.readdirSync(charPath) + game: 'gs', + async init (game = 'gs') { + this.game = game + let chars = fs.readdirSync(`${miaoPath}/resources/meta-${game}/character`) for (let char of chars) { cfgMap.char[char] = {} let curr = cfgMap.char[char] @@ -26,17 +27,20 @@ let cfgMap = { } }, exists (char, file) { - return fs.existsSync(`${charPath}/${char}/${file}.js`) + return fs.existsSync(`${miaoPath}/resources/meta-${this.game}/character/${char}/${file}.js`) }, async getCfg (char, file, module = '') { - let cfg = await Data.importModule(`resources/meta-gs/character/${char}/${file}.js`, 'miao') + let cfg = await Data.importModule(`resources/meta-${this.game}/character/${char}/${file}.js`, 'miao') if (module) { return cfg[module] } return cfg } } -await cfgMap.init() +await cfgMap.init('gs') +let cfgMapGs = { ...cfgMap } +await cfgMap.init('sr') +let cfgMapSr = { ...cfgMap } /** * 角色相关配置 @@ -59,7 +63,12 @@ let CharCfg = { } }, getArtisCfg (char) { - return cfgMap.char[char.isTraveler ? '旅行者' : char.name]?.artis || false + if (char.game !== 'sr') { + let charName = char.isTraveler ? `旅行者/${char.elem}` : char.name + return cfgMapGs.char[charName]?.artis || false + } else { + return cfgMapSr.char[char.name]?.artis || false + } } } export default CharCfg