This commit is contained in:
s
2026-06-30 10:56:41 +02:00
parent d49189c6e3
commit 1a5afcfd6d
11 changed files with 7927 additions and 0 deletions

44
tools/merge-dropstats.js Normal file
View File

@@ -0,0 +1,44 @@
#!/usr/bin/env node
// Fusionne plusieurs fichiers dropstats.json en un seul fichier combiné.
// Usage : node merge-dropstats.js sortie.json fichier1.json fichier2.json [...]
// ou : node merge-dropstats.js sortie.json dossier-contenant-les-jsons/*.json
const fs = require('fs');
const path = require('path');
const { emptyDropStats, mergeDropStatsInto, summarize } = require('../lib/dropstats');
const args = process.argv.slice(2);
if (args.length < 2) {
console.error('Usage: node merge-dropstats.js <sortie.json> <fichier1.json> [fichier2.json ...]');
console.error('Exemple: node merge-dropstats.js fusion.json alice.json bob.json charlie.json');
process.exit(1);
}
const [outputPath, ...inputPaths] = args;
const result = emptyDropStats();
let filesOk = 0;
console.log(`Fusion de ${inputPaths.length} fichier(s)...\n`);
for (const inputPath of inputPaths) {
try {
const raw = fs.readFileSync(inputPath, 'utf8');
const data = JSON.parse(raw);
const added = mergeDropStatsInto(result, data);
filesOk++;
console.log(`${path.basename(inputPath)} — +${added} kills`);
} catch (e) {
console.error(`${path.basename(inputPath)} — erreur : ${e.message}`);
}
}
result.updatedAt = new Date().toISOString();
fs.writeFileSync(outputPath, JSON.stringify(result, null, 2));
const stats = summarize(result);
console.log('');
console.log(`Fichiers fusionnés : ${filesOk}/${inputPaths.length}`);
console.log(`Mobs suivis : ${stats.totalMobs}`);
console.log(`Kills cumulés : ${stats.totalKills}`);
console.log(`Combinaisons : ${stats.totalCombos}`);
console.log(`Écrit dans : ${path.resolve(outputPath)}`);