sokko-g/scripts/team-specialties.mjs
Shinuwa 9cf48ea0d0 Add the Broken Mirror puzzle to the Guild
A daily puzzle: a card illustration cut into pieces, rebuilt by swapping
two pieces of the same row or column within a limited number of swaps.
The normal picture is a square card in 4 x 4, drawn for each player, with
placed pieces outlined in green; the hard one is a 5 x 7 portrait shared
by everyone each day, with a result to copy. The limit is the computer's
best result (beam search) plus a margin, and every swap left adds
stardust. Two companions of the daily team can each give one help, by
specialty; a double specialty picks one when used.

The server keeps the piece positions, sends the picture already shuffled
and checks every swap. Uniform illustrations are left out, from measures
written by scripts/mirror-illustrations.mjs. The Guild gets its quest and
a Codex tile, the administration a tab (opening, rewards, margins, the
day's summary), and migration 30 its tables. New collections must plan at
least one double-specialty character, counted by
scripts/team-specialties.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-28 13:38:46 +01:00

36 lines
2.2 KiB
JavaScript

// Rôle : 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)}`);