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:
parent
0ef213cf4f
commit
8bb1d53d70
46 changed files with 4752 additions and 213 deletions
|
|
@ -1,5 +1,6 @@
|
|||
// Rôle : charge et valide le catalogue public, ses finitions et effets Sokko TCG.
|
||||
import { readFileSync } from "node:fs";
|
||||
import { STAT_IDS } from "./expedition-rules.js";
|
||||
|
||||
const RARITY_IDS = new Set(["common", "rare", "epic", "legendary", "mythic"]);
|
||||
const PARTICLE_SHAPE_KINDS = new Set(["sparks", "snowflakes"]);
|
||||
|
|
@ -13,6 +14,9 @@ export const FULL_ART_FORMAT = "full-art";
|
|||
export const MATCH_HOLO_PALETTE_ID = "match-holo";
|
||||
const CARD_IMAGE_PATTERN = /^\/static\/img\/cards\/[a-z0-9-]+\/(?:common|rare|epic|legendary)\/[a-z0-9_]+\.webp$/;
|
||||
const PACK_BACK_IMAGE_PATTERN = /^\/static\/img\/cards\/[a-z0-9-]+\/back\.webp$/;
|
||||
// Étiquettes d'expédition : vocabulaire fermé, par famille (personnage, lieu, thème, objet).
|
||||
export const EXPEDITION_TAG_PATTERN = /^(personnage|lieu|theme|objet):[a-z0-9-]+$/;
|
||||
const MAX_CARD_TAGS = 8;
|
||||
|
||||
function requireUnique(items, label) {
|
||||
const ids = new Set();
|
||||
|
|
@ -24,6 +28,35 @@ function requireUnique(items, label) {
|
|||
return ids;
|
||||
}
|
||||
|
||||
// Profil d'expédition : la part de la Puissance donnée à chaque stat, en entiers dont la somme vaut 100.
|
||||
export function validExpeditionProfile(profile) {
|
||||
if (!profile || typeof profile !== "object" || Array.isArray(profile) || Object.keys(profile).length !== STAT_IDS.length) return false;
|
||||
if (STAT_IDS.some((stat) => !Number.isInteger(profile[stat]) || profile[stat] < 0 || profile[stat] > 100)) return false;
|
||||
return STAT_IDS.reduce((sum, stat) => sum + profile[stat], 0) === 100;
|
||||
}
|
||||
|
||||
function validateExpeditionTags(tags) {
|
||||
if (!Array.isArray(tags) || !tags.length) throw new TypeError("Cards catalog expeditionTags must be a non-empty array.");
|
||||
const ids = requireUnique(tags, "expeditionTags");
|
||||
for (const tag of tags) {
|
||||
if (!EXPEDITION_TAG_PATTERN.test(tag.id) || typeof tag.label !== "string" || !tag.label || tag.label.length > 40) {
|
||||
throw new TypeError(`Invalid expedition tag ${tag.id}: family:name id and a 1 to 40 character label.`);
|
||||
}
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
function validateCardExpedition(card, tagIds) {
|
||||
const expedition = card.expedition;
|
||||
if (!expedition || !Array.isArray(expedition.tags) || !expedition.tags.length || expedition.tags.length > MAX_CARD_TAGS) {
|
||||
throw new TypeError(`Card ${card.id} needs 1 to ${MAX_CARD_TAGS} expedition tags.`);
|
||||
}
|
||||
if (new Set(expedition.tags).size !== expedition.tags.length) throw new TypeError(`Card ${card.id} repeats an expedition tag.`);
|
||||
const unknown = expedition.tags.find((tag) => !tagIds.has(tag));
|
||||
if (unknown) throw new TypeError(`Card ${card.id} uses unknown expedition tag ${unknown}.`);
|
||||
if (expedition.profile != null && !validExpeditionProfile(expedition.profile)) throw new TypeError(`Card ${card.id} expedition profile must give integer shares of the four stats summing to 100.`);
|
||||
}
|
||||
|
||||
export function validateCardsCatalog(catalog) {
|
||||
if (!catalog || catalog.version !== 1) throw new TypeError("Cards catalog version must be 1.");
|
||||
for (const key of ["rarities", "effectPresets", "effectPalettes", "particleShapes", "particlePalettes", "particlePresets", "openingEffects", "finishes", "collections", "cards", "editions"]) {
|
||||
|
|
@ -40,6 +73,7 @@ export function validateCardsCatalog(catalog) {
|
|||
const collectionIds = requireUnique(catalog.collections, "collections");
|
||||
const cardIds = requireUnique(catalog.cards, "cards");
|
||||
requireUnique(catalog.editions, "editions");
|
||||
const expeditionTagIds = validateExpeditionTags(catalog.expeditionTags);
|
||||
if ([...RARITY_IDS].some((id) => !rarityIds.has(id))) throw new TypeError("Cards catalog must declare all supported rarities.");
|
||||
// Poids recommandés, proposés par l'administration pour réinitialiser les taux de tirage d'un paquet.
|
||||
validateRarityWeights(Object.fromEntries(catalog.rarities.map((rarity) => [rarity.id, rarity.recommendedWeight])), rarityIds, "recommended weights");
|
||||
|
|
@ -116,6 +150,7 @@ export function validateCardsCatalog(catalog) {
|
|||
|| !COLOR_PATTERN.test(collection.back?.secondary)) {
|
||||
throw new TypeError(`Invalid pack presentation for collection ${collection.id}.`);
|
||||
}
|
||||
if (!validExpeditionProfile(collection.expedition?.profile)) throw new TypeError(`Collection ${collection.id} needs an expedition profile giving integer shares of the four stats summing to 100.`);
|
||||
}
|
||||
|
||||
for (const card of catalog.cards) {
|
||||
|
|
@ -130,6 +165,7 @@ export function validateCardsCatalog(catalog) {
|
|||
throw new TypeError(`Card ${card.id} ${cutoutKey === "cutoutImage" ? "cutout" : "full cutout"} image must be its ${label} suffixed with __cutout.`);
|
||||
}
|
||||
}
|
||||
validateCardExpedition(card, expeditionTagIds);
|
||||
}
|
||||
|
||||
for (const edition of catalog.editions) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue