const fs = require('fs')
const key = "UpstarConfig"
const values = [0, 1387, 10, 500, 10000, 5, 0] // 等级,物品ID,属性调整,元宝花费,升级概率
const interval = [1, 0, 15, 50, -450, 10, 1]
const num = 21
const start = () => {
    const template = `"S1": {
      "consume": [
        {
          "id": 4,
          "type": 4,
          "count": S4
        },
        {
          "id": 845,
          "type": 0,
          "count": S6
        },
        {
          "id": 852,
          "type": 0,
          "count": S3
        }
      ],
      "id": S2,
      "level": S1,
      "attribute": [
        {
          "value": S7,
          "type": 9
        },
        {
          "value": S7,
          "type": 11
        },
        {
          "value": S7,
          "type": 13
        },
        {
          "value": S7,
          "type": 15
        },
        {
          "value": S7,
          "type": 17
        },
        {
          "value": S7,
          "type": 19
        }
      ],
      "rate": S5
    }`
    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()