mirror of
https://github.com/ZZZure/ZZZ-Plugin.git
synced 2025-12-16 13:17:32 +00:00
新增柏妮思伤害计算等
This commit is contained in:
parent
6573f1d600
commit
b51acca73e
19 changed files with 1053 additions and 164 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { aliasToID } from '../../lib/convert/char.js';
|
||||
import config from '../../../../lib/config/config.js';
|
||||
import { BuffManager } from './BuffManager.js';
|
||||
import { pluginPath } from '../../lib/path.js';
|
||||
import { elementEnum } from './BuffManager.js';
|
||||
|
|
@ -15,7 +14,15 @@ const calcFnc = {
|
|||
set: {}
|
||||
};
|
||||
async function init() {
|
||||
const isWatch = config.bot.log_level === 'debug'; // debug模式下监听文件变化
|
||||
// debug模式下监听文件变化
|
||||
const isWatch = await (async () => {
|
||||
try {
|
||||
return (await import('../../../../lib/config/config.js')).default.bot.log_level === 'debug';
|
||||
}
|
||||
catch {
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
await Promise.all(fs.readdirSync(path.join(damagePath, 'character')).filter(v => v !== '模板').map(v => importChar(v, isWatch)));
|
||||
for (const type of ['weapon', 'set']) {
|
||||
await Promise.all(fs.readdirSync(path.join(damagePath, type)).filter(v => v !== '模板.js' && !v.endsWith('_user.js') && v.endsWith('.js'))
|
||||
|
|
@ -43,11 +50,14 @@ async function importChar(charName, isWatch = false) {
|
|||
const calcFile = fs.existsSync(path.join(dir, 'calc_user.js')) ? 'calc_user.js' : 'calc.js';
|
||||
const dataPath = path.join(dir, (fs.existsSync(path.join(dir, 'data_user.json')) ? 'data_user.json' : 'data.json'));
|
||||
try {
|
||||
const calcFilePath = path.join(dir, calcFile);
|
||||
if (isWatch) {
|
||||
watchFile(path.join(dir, calcFile), () => importChar(charName));
|
||||
watchFile(calcFilePath, () => importChar(charName));
|
||||
watchFile(dataPath, () => charData[id] = JSON.parse(fs.readFileSync(dataPath, 'utf8')));
|
||||
}
|
||||
charData[id] = JSON.parse(fs.readFileSync(dataPath, 'utf8'));
|
||||
if (!fs.existsSync(calcFilePath))
|
||||
return;
|
||||
const m = await import(`./character/${charName}/${calcFile}?${Date.now()}`);
|
||||
if (!m.calc && (!m.buffs || !m.skills))
|
||||
throw new Error('伤害计算文件格式错误');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue