Add ARCHITECTURE.md (layers, flows, folder map, glossary), CONTRIBUTING.md (setup and step-by-step recipes) and a README in each main folder, with an index of docs/. Convert the 511 JavaScript headers from "// Rôle :" lines to JSDoc @file blocks, define a three-level header template in website/AGENTS.md and check the header in tests/file-headers.test.mjs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
42 lines
2.2 KiB
JavaScript
42 lines
2.2 KiB
JavaScript
/**
|
|
* @file Compte les spécialités des personnages d'équipe (simples, doubles, Équilibré), en tout et par
|
|
* collection.
|
|
*
|
|
* Usage : node scripts/team-specialties.mjs. À relancer après l'ajout d'une carte ou d'une collection
|
|
* (règles : docs/equipe-du-jour.md).
|
|
*/
|
|
|
|
import { fileURLToPath } from "node:url";
|
|
import { loadCardsCatalog } from "../services/cards/catalog.js";
|
|
import { STAT_IDS } from "../services/cards/expedition-rules.js";
|
|
import { specialtiesOf, teamCharacters } from "../services/cards/team-rules.js";
|
|
|
|
const root = fileURLToPath(new URL("..", import.meta.url));
|
|
const catalog = loadCardsCatalog(`${root}website/public/data/cards/catalog.json`);
|
|
const collectionOf = new Map(catalog.cards.map((card) => [card.id, card.collectionId]));
|
|
const labelOf = (specialties) => specialties.length ? specialties.join(" + ") : "équilibré";
|
|
const increment = (counts, key) => counts.set(key, (counts.get(key) || 0) + 1);
|
|
|
|
const total = new Map();
|
|
const byCollection = new Map();
|
|
const doubles = [];
|
|
for (const character of teamCharacters(catalog)) {
|
|
const specialties = specialtiesOf(character.profile);
|
|
const label = labelOf(specialties);
|
|
increment(total, label);
|
|
const collectionId = collectionOf.get(character.id);
|
|
if (!byCollection.has(collectionId)) byCollection.set(collectionId, new Map());
|
|
increment(byCollection.get(collectionId), label);
|
|
if (specialties.length === 2) doubles.push(`${character.id} (${collectionId}) : ${label}`);
|
|
}
|
|
|
|
const pairs = STAT_IDS.flatMap((first, index) => STAT_IDS.slice(index + 1).map((second) => `${first} + ${second}`));
|
|
const sorted = (counts) => [...counts].sort((a, b) => b[1] - a[1]).map(([label, count]) => `${label} ${count}`).join(", ");
|
|
|
|
console.log(`Personnages d'équipe : ${[...total.values()].reduce((sum, count) => sum + count, 0)}`);
|
|
console.log(`Spécialités : ${sorted(total)}`);
|
|
console.log(`\nDoubles spécialités (${doubles.length}) :`);
|
|
doubles.forEach((line) => console.log(` ${line}`));
|
|
console.log(`Paires sans aucun personnage : ${pairs.filter((pair) => !total.has(pair)).join(", ") || "aucune"}`);
|
|
console.log("\nPar collection :");
|
|
for (const [collectionId, counts] of byCollection) console.log(` ${collectionId} : ${sorted(counts)}`);
|