feat: initial commit for TheFarmer project
This commit is contained in:
37
211/server/tools/list_crops.js
Normal file
37
211/server/tools/list_crops.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const plantPath = path.join(__dirname, '../gameConfig/Plant.json');
|
||||
|
||||
try {
|
||||
const data = fs.readFileSync(plantPath, 'utf8');
|
||||
const plants = JSON.parse(data);
|
||||
|
||||
let content = `# 农作物列表 (共 ${plants.length} 种)\n\n`;
|
||||
content += `| ID | 名称 | 等级 | 季数 | 产量 | 生长(小时) | 阶段详情 |\n`;
|
||||
content += `|---|---|---|---|---|---|---|\n`;
|
||||
|
||||
plants.sort((a, b) => a.land_level_need - b.land_level_need || a.id - b.id);
|
||||
|
||||
plants.forEach(p => {
|
||||
let totalTime = 0;
|
||||
if (p.grow_phases) {
|
||||
const parts = p.grow_phases.split(';');
|
||||
parts.forEach(part => {
|
||||
if (part) {
|
||||
const [stage, time] = part.split(':');
|
||||
if (time) totalTime += parseInt(time);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const hours = (totalTime / 3600).toFixed(1);
|
||||
content += `| ${p.id} | ${p.name} | ${p.land_level_need} | ${p.seasons} | ${p.fruit ? p.fruit.count : '?'} | ${hours}h | ${p.grow_phases} |\n`;
|
||||
});
|
||||
|
||||
fs.writeFileSync(path.join(__dirname, 'crop_list.md'), content);
|
||||
console.log('列表已生成: server/tools/crop_list.md');
|
||||
|
||||
} catch (err) {
|
||||
console.error('读取失败:', err);
|
||||
}
|
||||
Reference in New Issue
Block a user