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>
This commit is contained in:
Shinuwa 2026-11-15 14:29:05 +01:00
parent 0ef213cf4f
commit 8bb1d53d70
46 changed files with 4752 additions and 213 deletions

View file

@ -4,6 +4,7 @@ import { readFile } from "node:fs/promises";
import { join, resolve } from "node:path";
import { CardsDatabase } from "./database.js";
import { loadCardsCatalog, publicCatalog } from "./catalog.js";
import { DEFAULT_DESTINATIONS_PATH, loadExpeditionDestinations } from "./expedition-content.js";
import { CardsService, DEV_DISCORD_ID } from "./service.js";
import { bool, createRateLimiter, json } from "../http.js";
@ -104,6 +105,7 @@ export function createCardsApiHandler({
allowProductionDevAuth = false,
databasePath = env.CARDS_DB_PATH || join(projectRoot, ".local", "nebula-cards.sqlite"),
catalogPath = join(projectRoot, "website", "public", "data", "cards", "catalog.json"),
destinationsPath = DEFAULT_DESTINATIONS_PATH,
now = Date.now,
random,
fetchImpl = fetch,
@ -127,7 +129,8 @@ export function createCardsApiHandler({
if (env.NODE_ENV === "production" && !privacyController) throw new TypeError("CARDS_PRIVACY_CONTROLLER is required when Sokko TCG is enabled in production.");
const catalog = loadCardsCatalog(catalogPath);
database = new CardsDatabase(databasePath);
service = new CardsService({ database, catalog, now, random, devPerks });
const destinations = loadExpeditionDestinations(destinationsPath, catalog);
service = new CardsService({ database, catalog, now, random, devPerks, destinations });
}
const secureCookies = env.NODE_ENV === "production" || String(env.CARDS_PUBLIC_ORIGIN || "").startsWith("https://");
const adminIds = new Set(String(env.CARDS_ADMIN_DISCORD_IDS || "").split(",").map((item) => item.trim()).filter(Boolean));
@ -295,6 +298,34 @@ export function createCardsApiHandler({
json(res, 200, service.guessDaily(session.player.id, { day: body.day, cardId: body.cardId }));
return true;
}
if (req.method === "GET" && url.pathname === "/api/cards/expeditions") {
json(res, 200, service.expeditions.getExpeditions(session.player.id));
return true;
}
if (req.method === "POST" && url.pathname === "/api/cards/expeditions/preview") {
rateLimit(req, "expedition-preview", 120);
json(res, 200, service.expeditions.preview(session.player.id, await readBody(req)));
return true;
}
if (req.method === "POST" && url.pathname === "/api/cards/expeditions") {
rateLimit(req, "expedition-start", 30);
json(res, 201, service.expeditions.startSolo(session.player.id, await readBody(req), String(req.headers["idempotency-key"] || "")));
return true;
}
const expeditionClaim = routeMatch(url.pathname, /^\/api\/cards\/expeditions\/([^/]+)\/claim$/);
if (req.method === "POST" && expeditionClaim) {
json(res, 200, service.expeditions.claim(session.player.id, expeditionClaim[0]));
return true;
}
if (req.method === "PUT" && url.pathname === "/api/cards/admin/expeditions/settings") {
json(res, 200, service.expeditions.updateSettings(session.player.id, (await readBody(req)).settings));
return true;
}
const expeditionCancel = routeMatch(url.pathname, /^\/api\/cards\/admin\/expeditions\/([^/]+)\/cancel$/);
if (req.method === "POST" && expeditionCancel) {
json(res, 200, service.expeditions.cancel(session.player.id, expeditionCancel[0]));
return true;
}
if (req.method === "GET" && url.pathname === "/api/cards/admin/dashboard") {
json(res, 200, service.getAdminDashboard(session.player.id));
return true;