Last active
December 10, 2022 16:23
-
-
Save Tsuk1ko/8c6c9dd11a3b26cdf19c05383621af4e to your computer and use it in GitHub Desktop.
云崽喵喵插件默认伤害修改插件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
import plugin from '../../lib/plugins/plugin.js'; | |
let moded = false; | |
const modList = [ | |
{ | |
name: '班尼特', | |
key: 'defDmgIdx', | |
val: 2, | |
}, | |
{ | |
name: '迪奥娜', | |
key: 'defDmgIdx', | |
val: 1, | |
}, | |
{ | |
name: '枫原万叶', | |
key: 'defDmgIdx', | |
val: 3, | |
}, | |
{ | |
name: '九条裟罗', | |
key: 'defDmgIdx', | |
val: 0, | |
}, | |
{ | |
name: '妮露', | |
key: 'defDmgIdx', | |
val: 3, | |
}, | |
{ | |
name: '行秋', | |
key: 'defDmgIdx', | |
val: 1, | |
}, | |
{ | |
name: '夜兰', | |
key: 'defDmgIdx', | |
val: 3, | |
}, | |
]; | |
function getCalcPath(name) { | |
return `./plugins/miao-plugin/resources/meta/character/${name}/calc.js`; | |
} | |
function applyMod() { | |
modList.forEach(({ name, key, val }) => { | |
const filePath = getCalcPath(name); | |
const content = fs.readFileSync(filePath).toString(); | |
const reg = new RegExp(`export const ${key} =.*`); | |
const newContent = reg.test(content) | |
? content.replace(reg, `export const ${key} = ${val}`) | |
: `export const ${key} = ${val}\n${content}`; | |
if (content === newContent) return; | |
fs.writeFileSync(filePath, newContent); | |
console.log(`[喵喵魔改] ${name} 修改成功`); | |
}); | |
moded = true; | |
console.log('[喵喵魔改] 修改完成'); | |
} | |
export class MiaoMod extends plugin { | |
constructor() { | |
super({ | |
name: '喵喵魔改', | |
dsc: '修改喵喵插件不合理的默认伤害选取', | |
}); | |
if (moded) return; | |
applyMod(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment