sokko-g/scripts/reset-card-progress.mjs
Shinuwa 3590df5e1e
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 25m4s
Validate and deploy Sokko G / deploy (push) Successful in 18s
Let players compare card stats in the collection, rebalance card profiles with a full refunded reset of upgrades, and fix best boosts that sometimes fired in the previous zone
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-04 23:17:23 +01:00

37 lines
2.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* @file Reset complet des améliorations des cartes des Expéditions, avec remboursement (Éclats, doublons, Parchemins d'oubli,
* expérience de terrain convertie en Éclats) : simulation par défaut, application avec une sauvegarde préalable.
*
* Usage : node scripts/reset-card-progress.mjs <base> | <base> --apply --backup <copie>. Sans --apply, affiche ce que
* chaque joueur récupérerait sans rien écrire. Avec --apply, sauvegarde d'abord la base vers <copie>, puis applique.
* @see services/cards/progress-reset.js
*/
import { join, resolve } from "node:path";
import { backupCardsDatabase } from "../services/cards/backup.js";
import { loadCardsCatalog } from "../services/cards/catalog.js";
import { CardsDatabase } from "../services/cards/database.js";
import { applyProgressReset } from "../services/cards/progress-reset.js";
import { CardsService } from "../services/cards/service.js";
const args = process.argv.slice(2);
const database = args[0];
const apply = args.includes("--apply");
const backupIndex = args.indexOf("--backup");
const backup = backupIndex > 0 ? args[backupIndex + 1] : null;
if (!database || database.startsWith("--") || (apply && !backup)) {
console.error("Usage: node scripts/reset-card-progress.mjs <database> [--apply --backup <backup path>]");
process.exit(1);
}
if (apply) {
await backupCardsDatabase(resolve(database), resolve(backup));
console.log(`Backup written to ${resolve(backup)}`);
}
const service = new CardsService({ database: new CardsDatabase(resolve(database)), catalog: loadCardsCatalog(join(import.meta.dirname, "..", "website", "public", "data", "cards", "catalog.json")) });
const report = applyProgressReset(service, { apply });
for (const entry of report) {
const copies = entry.duplicates.reduce((sum, item) => sum + item.count, 0);
console.log(`${entry.name}: ${entry.cards} carte(s) remise(s) à zéro · ${entry.eclats} Éclats payés + ${entry.xpEclats} Éclats d'expérience · ${copies} doublon(s) · ${entry.oblivion} Parchemin(s) d'oubli · ${entry.unequipped} équipement(s) retiré(s)`);
for (const item of entry.duplicates) console.log(` ${item.count} × ${item.editionId}`);
}
console.log(report.length ? (apply ? "Reset applied." : "Dry run: nothing written. Add --apply --backup <path> to apply.") : "No card progress to reset.");