From facfd27d6285eb859713bc403e8a0f7c62e229ef Mon Sep 17 00:00:00 2001 From: aixianling Date: Fri, 17 Jan 2025 14:48:48 +0800 Subject: [PATCH] =?UTF-8?q?feat(config):=20=E6=9B=B4=E6=96=B0=E5=9B=9B?= =?UTF-8?q?=E8=B1=A1=E4=B8=B9=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=E5=8C=96=20JSON=20=E8=BD=AC=20Lua=20=E8=84=9A?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 RecyclingSettingConfig.json 中更新 7 品证明回收设置,增加四象丹 - 在 StdItems.json 中为四象青龙丹、白虎丹、朱雀丹、玄武丹添加 itemlevel 字段 - 优化 json2lua.js 脚本,增加配置范围并改进 JSON 对象处理方式 --- configs/RecyclingSettingConfig.json | 2 +- configs/StdItems.json | 4 ++++ json2lua.js | 7 ++++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/configs/RecyclingSettingConfig.json b/configs/RecyclingSettingConfig.json index 4099a48..8e8bbe5 100644 --- a/configs/RecyclingSettingConfig.json +++ b/configs/RecyclingSettingConfig.json @@ -714,7 +714,7 @@ "tips": "一键回收7品证明,需要绿卡会员", "Titletips": "绿卡会员可开启该道具一键回收", "value": 0, - "name": "7品证明", + "name": "7品证明和四象丹", "showQuality": 2, "optionid": 49, "itemlevel": 91, diff --git a/configs/StdItems.json b/configs/StdItems.json index 295a0e1..48bf50b 100644 --- a/configs/StdItems.json +++ b/configs/StdItems.json @@ -47792,6 +47792,7 @@ "name": "四象青龙丹", "dealPrice": 10, "dropBroadcast": 0, + "itemlevel": 91, "itemlvl": 3, "shape": 0, "existScenes": [ @@ -47838,6 +47839,7 @@ "name": "四象白虎丹", "dealPrice": 10, "dropBroadcast": 0, + "itemlevel": 91, "itemlvl": 3, "shape": 0, "existScenes": [ @@ -47885,6 +47887,7 @@ "name": "四象朱雀丹", "dealPrice": 10, "dropBroadcast": 0, + "itemlevel": 91, "itemlvl": 3, "shape": 0, "existScenes": [ @@ -47932,6 +47935,7 @@ "name": "四象玄武丹", "dealPrice": 10, "dropBroadcast": 0, + "itemlevel": 91, "itemlvl": 3, "shape": 0, "existScenes": [ diff --git a/json2lua.js b/json2lua.js index d7b46dc..f18fa0f 100644 --- a/json2lua.js +++ b/json2lua.js @@ -2,10 +2,11 @@ const { log } = require('console'); const fs = require('fs') const path = require('path'); const folderPath = "./configs" +const scope = ["StdItems", "ItemMergeConfig", "MergeConfig", "MergeTotal", "RecyclingSettingConfig", "UpstarConfig", "Monster"] function jsonToLua(jsonObj, indent = '', linefeed = '\n') { let luaStr = ''; const strKey = key => isNaN(key) ? `${key}` : `[${key}]`; - for (let key in jsonObj) { + Object.keys(jsonObj).sort().forEach(key => { let value = jsonObj[key]; key = strKey(key) if (typeof value === 'object' && value !== null && !Array.isArray(value)) { @@ -35,14 +36,14 @@ function jsonToLua(jsonObj, indent = '', linefeed = '\n') { luaStr += `${indent}${key} = ${value},${linefeed}`; } } - } + }) return luaStr; } const start = () => { const files = fs.readdirSync(folderPath); // 过滤出所有的 JSON 文件 - const jsonFiles = files.filter(file => path.extname(file) === '.json').filter(file => ["StdItems","ItemMergeConfig","MergeConfig","MergeTotal","RecyclingSettingConfig","UpstarConfig"].map(e => `${e}.json`).includes(file)); + const jsonFiles = files.filter(file => path.extname(file) === '.json').filter(file => scope.map(e => `${e}.json`).includes(file)); jsonFiles.forEach(file => { const json = JSON.parse(fs.readFileSync(path.join(folderPath, file), 'utf8')) const filename = path.basename(file, path.extname(file));