-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11a1ce9
commit aa9772f
Showing
26 changed files
with
1,481 additions
and
1,429 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
|
||
// 定义pathing目录的路径 | ||
const pathingDir = path.resolve(__dirname, '..', '..', 'repo', 'pathing'); | ||
|
||
// 递归读取目录下的所有JSON文件 | ||
function readJsonFilesRecursively(dir) { | ||
const files = fs.readdirSync(dir, { withFileTypes: true }); | ||
|
||
files.forEach(file => { | ||
const filePath = path.join(dir, file.name); | ||
|
||
if (file.isDirectory()) { | ||
readJsonFilesRecursively(filePath); | ||
} else if (path.extname(file.name).toLowerCase() === '.json') { | ||
processJsonFile(filePath); | ||
} | ||
}); | ||
} | ||
|
||
// 处理单个JSON文件 | ||
function processJsonFile(filePath) { | ||
try { | ||
const data = fs.readFileSync(filePath, 'utf8'); | ||
const jsonData = JSON.parse(data); | ||
|
||
// 检查并修改第一个position的type | ||
if (jsonData.positions && jsonData.positions.length > 0) { | ||
const firstPosition = jsonData.positions[0]; | ||
if (firstPosition.type !== 'teleport') { | ||
firstPosition.type = 'teleport'; | ||
console.log(`文件 ${filePath} 中的第一个position的type已更改为teleport`); | ||
|
||
// 将修改后的数据写回文件 | ||
fs.writeFileSync(filePath, JSON.stringify(jsonData, null, 2), 'utf8'); | ||
console.log(`文件 ${filePath} 已成功更新`); | ||
} else { | ||
console.log(`文件 ${filePath} 中的第一个position的type已经是teleport`); | ||
} | ||
} else { | ||
console.log(`文件 ${filePath} 中没有positions数组或数组为空`); | ||
} | ||
} catch (err) { | ||
console.error(`处理文件 ${filePath} 时出错:`, err); | ||
} | ||
} | ||
|
||
// 开始递归读取文件 | ||
console.log(`开始处理 ${pathingDir} 目录下的所有JSON文件`); | ||
readJsonFilesRecursively(pathingDir); | ||
console.log('处理完成'); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,54 @@ | ||
{ | ||
"info":{ | ||
"bgi_version":"0.34.5", | ||
"version":"1.0", | ||
"name":"小灯草-晨曦酒庄-蒙德4个", | ||
"description":"", | ||
"type":"collect", | ||
"author":"不瘦五十斤不改名" | ||
}, | ||
"positions":[ | ||
{ | ||
"x":-201.20703125, | ||
"y":1861.82958984375, | ||
"type":"path", | ||
"move_mode":"walk", | ||
"action":"" | ||
}, | ||
{ | ||
"x":-125.4638671875, | ||
"y":1875.52197265625, | ||
"type":"path", | ||
"move_mode":"walk", | ||
"action":"" | ||
}, | ||
{ | ||
"x":-120.5341796875, | ||
"y":1876.8720703125, | ||
"type":"path", | ||
"move_mode":"walk", | ||
"action":"" | ||
}, | ||
{ | ||
"x":-116.94921875, | ||
"y":1873.3349609375, | ||
"type":"path", | ||
"move_mode":"walk", | ||
"action":"" | ||
}, | ||
{ | ||
"x":-117.626953125, | ||
"y":1870.197265625, | ||
"type":"path", | ||
"move_mode":"walk", | ||
"action":"" | ||
}, | ||
{ | ||
"x":-119.4970703125, | ||
"y":1869.9794921875, | ||
"type":"path", | ||
"move_mode":"walk", | ||
"action":"" | ||
} | ||
] | ||
"info": { | ||
"bgi_version": "0.34.5", | ||
"version": "1.0", | ||
"name": "小灯草-晨曦酒庄-蒙德4个", | ||
"description": "", | ||
"type": "collect", | ||
"author": "不瘦五十斤不改名" | ||
}, | ||
"positions": [ | ||
{ | ||
"x": -201.20703125, | ||
"y": 1861.82958984375, | ||
"type": "teleport", | ||
"move_mode": "walk", | ||
"action": "" | ||
}, | ||
{ | ||
"x": -125.4638671875, | ||
"y": 1875.52197265625, | ||
"type": "path", | ||
"move_mode": "walk", | ||
"action": "" | ||
}, | ||
{ | ||
"x": -120.5341796875, | ||
"y": 1876.8720703125, | ||
"type": "path", | ||
"move_mode": "walk", | ||
"action": "" | ||
}, | ||
{ | ||
"x": -116.94921875, | ||
"y": 1873.3349609375, | ||
"type": "path", | ||
"move_mode": "walk", | ||
"action": "" | ||
}, | ||
{ | ||
"x": -117.626953125, | ||
"y": 1870.197265625, | ||
"type": "path", | ||
"move_mode": "walk", | ||
"action": "" | ||
}, | ||
{ | ||
"x": -119.4970703125, | ||
"y": 1869.9794921875, | ||
"type": "path", | ||
"move_mode": "walk", | ||
"action": "" | ||
} | ||
] | ||
} |
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
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
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
Oops, something went wrong.