const fs = require("fs"); const ringType = 6; const tpls = { SpecialRing: { key: "SpecialRing", desc: "戒指种类,登记,伤害加倍,元宝花费", values: [ringType, 51, 10, 10], interval: [0, 1, 10, 10], num: 150, template: { 4: `"S2": { "attr": [ { "value": S3, "type": 75 }, { "value": 428, "type": 76 }, { "value": 536, "type": 77 }, { "value": 55, "type": 21 }, { "value": 55, "type": 23 }, { "value": 55, "type": 25 }, { "value": 55, "type": 27 }, { "value": 5000, "type": 83 } ], "lv": S2, "cost": [ { "id": 4, "type": 4, "count": S4 }, { "id": 1018, "type": 0, "count": 1000 } ], "pos": S1 }`, 5: `"S2": { "attr": [ { "value": S3, "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": S2, "cost": [ { "id": 1022, "type": 0, "count": 1600 }, { "id": 4, "type": 4, "count": S4 } ], "pos": S1 }`, 6: `"S2": { "attr": [ { "value": 1000, "type": 5 }, { "value": 100, "type": 76 }, { "value": 100, "type": 77 }, { "value": 2500, "type": 64 }, { "value": S3, "type": 75 } ], "lv": S2, "cost": [ { "id": 1037, "type": 0, "count": 180 }, { "id": 4, "type": 4, "count": S4 } ], "pos": S1 }`, }[ringType], }, }; const scope = [ // "UpstarConfig", "SpecialRing", ].filter(Boolean); const start = () => { const configs = scope.map((key) => { return tpls[key]; }); configs.forEach((file) => { const { key, values, interval, num, template } = file; 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();