miao-plugin/resources/meta-sr/weapon/index.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

import { Data, Meta } from '#miao'
import lodash from 'lodash'
2023-10-25 19:03:33 +00:00
import { abbr, aliasCfg } from './alias.js'
const types = '存护,丰饶,毁灭,同谐,虚无,巡猎,智识'.split(',')
let data = Data.readJSON('/resources/meta-sr/weapon/data.json', 'miao')
2023-10-23 14:14:09 +00:00
const meta = Meta.create('sr', 'weapon')
meta.addData(data)
2023-10-23 14:14:09 +00:00
meta.addAlias(aliasCfg)
meta.addAbbr(abbr)
const weaponBuffs = {}
let loadBuffs = async function () {
for (let type of types) {
let calc = await Data.importDefault(`/resources/meta-sr/weapon/${type}/calc.js`, 'miao')
if (lodash.isFunction(calc)) {
calc = calc((idx, key) => {
return {
isStatic: true,
idx,
key
}
}, (title, key, idx) => {
2023-05-23 19:30:30 +00:00
if (lodash.isPlainObject(key)) {
return (tables) => {
let data = {}
lodash.forEach(key, (idx, k) => {
data[k] = tables[idx]
})
return {
title,
data
}
}
} else {
return {
title,
idx,
key
}
2023-05-21 18:13:38 +00:00
}
})
}
lodash.forEach(calc, (ds, key) => {
2023-10-23 14:14:09 +00:00
let id = meta.getId(key)
if (id) {
weaponBuffs[id] = ds
}
})
}
}
await loadBuffs()
meta.addMeta({ weaponBuffs })