const fs = require('fs') const key = "SpecialRing.config" const values = [71, 100, 500] // 登记,伤害加倍,元宝花费 const interval = [1, 50, 50] const num = 130 const start = () => { const template = `"S1": { "attr": [ { "value": S2, "type": 75 }, { "value": 585, "type": 76 }, { "value": 1115, "type": 77 }, { "value": 70, "type": 21 }, { "value": 70, "type": 23 }, { "value": 70, "type": 25 }, { "value": 70, "type": 27 }, { "value": 3400, "type": 79 } ], "lv": S1, "cost": [ { "id": 1022, "type": 0, "count": 1600 }, { "id":4, "type": 4, "count": S3 } ], "pos": 5 }` const getStr = (index) => { let str = template values.forEach((v, i) => { const reg = new RegExp(`S${i + 1}`, 'g') str = str.replace(reg, v + index * interval[i]) }) return str } const content = Array(num).fill(1).map((e, i) => `${getStr(i)}`).join(',') fs.writeFileSync(`./dist/${key}.txt`, content) } start()