Document how server.mjs keeps the site up when an API is misconfigured and reports it on /api/health, the cache and CSP policy, the share API's synchronous reservation, the trust placed in X-Forwarded-For, the hooks main.jsx wires once, and how to run each script. The deploy script header now recalls that CI runs the copy installed on the server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
41 lines
2.2 KiB
JavaScript
41 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, après l'ajout d'une carte ou d'une collection.
|
|
* @see 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)}`);
|