sokko-g/tests/nebula-cards-expedition-balance.test.mjs
Shinuwa 8bb1d53d70 Add solo Expeditions, the second Guilde des Veilleurs quest of Sokko TCG
- Every catalog card carries expedition tags and every collection a stat profile, validated at load; twelve destinations live server-side so hidden ones stay secret.
- Pure rules compute card power, per-slot requirements, roles, dangers, the long-trip malus, the score (one more star never raises it) and loot proportional to the chosen duration.
- A simulator script and a balance test guard the design thresholds; agent docs and a new-card skill explain how to tag new cards.
- Migration 8 adds Éclats d'étoile, expedition settings stored as one validated JSON, daily destinations, expeditions, members and slots, and rebuilds gift_packs so a pack can come from an expedition.
- Players launch a solo expedition from the Guild, see an exact preview, and claim their loot when it returns; the card sheet shows cards away on an expedition.
- Administration › Guilde tunes every value with server-side bounds, toggles destinations and cancels running expeditions; expeditions stay closed until an administrator opens them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 14:29:05 +01:00

43 lines
2.6 KiB
JavaScript

// Rôle : garde l'équilibre des Expéditions Sokko TCG avec le simulateur (seuils du document de conception).
// En cas d'échec après un ajout de cartes ou un changement de réglages : lancer `node scripts/simulate-expeditions.mjs` pour le détail.
import assert from "node:assert/strict";
import { test } from "node:test";
import { loadCardsCatalog } from "../services/cards/catalog.js";
import { loadExpeditionDestinations } from "../services/cards/expedition-content.js";
import { DEFAULT_EXPEDITION_SETTINGS, mergeExpeditionSettings } from "../services/cards/expedition-settings.js";
import { simulate } from "../services/cards/expedition-simulation.js";
const catalog = loadCardsCatalog("website/public/data/cards/catalog.json");
const destinations = loadExpeditionDestinations("services/cards/content/expedition-destinations.json", catalog);
const settings = mergeExpeditionSettings(DEFAULT_EXPEDITION_SETTINGS, destinations.map((destination) => destination.id));
const report = simulate(catalog, destinations, settings);
const row = (level, rarity, stars) => report.byRarity.find((item) => item.level === level && item.rarity === rarity && item.stars === stars);
test("every rare or better card reaches Réussite at 2 stars somewhere at level 0", () => {
const weak = report.cardBest.filter((card) => card.scorePct < settings.score.successPct);
assert.deepEqual(weak.map((card) => `${card.cardId} (${card.rarity}) ${card.scorePct.toFixed(0)} %`), []);
});
test("expected loot per hour is the same for every duration", () => {
for (const { stars, tier, perHour } of report.lootPerHour) {
assert.ok(perHour.every((value) => Math.abs(value - perHour[0]) < 1e-9), `${stars} ★ ${tier}`);
}
});
test("a rare and a mythic end within 5 % of each other at the cap", () => {
const { rare, mythic } = report.rareVsMythicAtMax;
assert.ok(Math.abs(rare - mythic) / mythic <= 0.05);
});
test("rarer cards never score lower than commoner ones at the same level and stars", () => {
const order = ["rare", "epic", "legendary", "mythic"];
for (let stars = 1; stars <= 5; stars += 1) {
const medians = order.map((rarity) => row("niveau 0", rarity, stars).median);
for (let index = 1; index < medians.length; index += 1) assert.ok(medians[index] >= medians[index - 1], `${order[index]} ${stars} ★`);
}
});
test("4 stars stay out of reach for level 0 rares but open to capped cards", () => {
assert.ok(row("niveau 0", "rare", 4).max < settings.score.successPct, "a level 0 rare pair reaches Réussite at 4 stars");
assert.ok(report.triumphShareAt4 >= 0.5, `only ${(report.triumphShareAt4 * 100).toFixed(0)} % of destinations allow a capped rare pair to triumph at 4 stars`);
});