星铁支持用户自定义评分规则和伤害计算,在对应角色目录下新建artis_user.js和calc_user.js即可

This commit is contained in:
Aluxes 2024-06-22 06:28:47 +08:00
parent 70d5d1089f
commit 9dc8553cf0
No known key found for this signature in database
GPG Key ID: 6696152F9C003087

View File

@ -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