Skip to content

Commit

Permalink
修复第一个点不是传送点的pathing文件
Browse files Browse the repository at this point in the history
  • Loading branch information
huiyadanli committed Oct 26, 2024
1 parent 11a1ce9 commit aa9772f
Show file tree
Hide file tree
Showing 26 changed files with 1,481 additions and 1,429 deletions.
52 changes: 52 additions & 0 deletions build/other/firstPosTp.js
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('处理完成');
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"id": 1,
"x": 3595.5517578125,
"y": 3254.333251953125,
"type": "path",
"type": "teleport",
"move_mode": "walk",
"action": ""
},
Expand Down
104 changes: 52 additions & 52 deletions repo/pathing/小灯草/小灯草-晨曦酒庄-蒙德4个.json
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": ""
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"id": 1,
"x": 4984.80078125,
"y": 4463.00048828125,
"type": "path",
"type": "teleport",
"move_mode": "walk",
"action": ""
},
Expand Down Expand Up @@ -73,4 +73,4 @@
"action": ""
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"id": 1,
"x": 1043.1806640625,
"y": -558.06298828125,
"type": "path",
"type": "teleport",
"move_mode": "walk",
"action": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"id": 1,
"x": 2703.53955078125,
"y": -761.19091796875,
"type": "path",
"type": "teleport",
"move_mode": "walk",
"action": ""
},
Expand Down
Loading

0 comments on commit aa9772f

Please sign in to comment.