Refuse layered finishes without their files and lighten idle particle cards
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 22m53s
Validate and deploy Sokko G / deploy (push) Successful in 14s

The catalog now marks the prismatic parallax as a layered effect, and the
service refuses to create a variation or change its finish to it when the card
lacks the cutout and backdrop for that format; existing variations stay as they
are. A test keeps the interface and the server in agreement for every card and
finish. Particle cards no longer hold canvas pixels at rest, build their motif
sprites on first use from a cache shared by all cards, and fade remaining
twinkles and fireflies within half a second once the pointer leaves.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-22 18:06:20 +01:00
parent 6737a89a1c
commit 3b2dae0168
11 changed files with 202 additions and 27 deletions

View file

@ -83,6 +83,23 @@ export function publishedFlare(catalog, stored) {
};
}
// Fichiers d'illustration qu'une finition demande à une carte : l'illustration pleine pour le format pleine illustration, et
// pour un effet à calques (`layers`, la Parallaxe prismatique) le héros détouré et le décor dans ce format. Renvoie les
// suffixes manquants (`__full`, `__cutout`, `__full__backdrop`…), vide si la carte peut porter la finition.
const FORMAT_FILES = {
[STANDARD_FORMAT]: { suffix: "", image: "image", cutout: "cutoutImage", backdrop: "backdropImage" },
[FULL_ART_FORMAT]: { suffix: "__full", image: "fullImage", cutout: "fullCutoutImage", backdrop: "fullBackdropImage" }
};
export function missingFinishFiles(catalog, card, finishId) {
const finish = catalog.finishes.find((item) => item.id === finishId);
const files = FORMAT_FILES[finish?.formatId || STANDARD_FORMAT];
if (!files) return [];
if (!card?.[files.image]) return [files.suffix || "image"];
if (!catalog.effectPresets.find((preset) => preset.id === finish?.effectPresetId)?.layers) return [];
return [[files.cutout, "__cutout"], [files.backdrop, "__backdrop"]].filter(([field]) => !card[field]).map(([, name]) => `${files.suffix}${name}`);
}
const EDITION_FLARE_FIELDS = ["flareId", "flareMotifId", "flarePaletteId", "flareScope", ...Object.values(FLARE_TUNING_FIELDS)];
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$/;
@ -199,6 +216,7 @@ export function validateCardsCatalog(catalog) {
for (const preset of catalog.effectPresets) {
if (!preset.label || preset.kind !== "holographic") throw new TypeError(`Invalid holographic effect preset ${preset.id}.`);
if (preset.level != null && !validTuningScale(preset.level)) throw new TypeError(`Holographic effect preset ${preset.id} level needs a label and ${EFFECT_TUNING_STEPS} level labels.`);
if (preset.layers != null && typeof preset.layers !== "boolean") throw new TypeError(`Holographic effect preset ${preset.id} layers flag must be a boolean.`);
}
if (!validTuningScale(catalog.effectIntensity)) throw new TypeError(`Cards catalog effectIntensity needs a label and ${EFFECT_TUNING_STEPS} level labels.`);
validateFlares(catalog);

View file

@ -2,7 +2,7 @@
import { createHash, randomBytes, randomInt, randomUUID } from "node:crypto";
import { normalizeReward } from "./rewards.js";
import { MASS_RECYCLE_RARITIES, planRecycling, spareQuantity, validateShopSetting } from "./stardust.js";
import { DEFAULT_EFFECT_TUNING, DEFAULT_FLARE_SCOPE, FULL_ART_FORMAT, isEffectTuning, normalizeFlare, buildPublishedCatalog, collectionDrawableEditions, createCatalogIndex, holographicFinishIds, isMythicEditionIdOf, legendaryParentEdition, MATCH_HOLO_PALETTE_ID, mythicEditionId, publicCatalog, validateRarityWeights } from "./catalog.js";
import { DEFAULT_EFFECT_TUNING, DEFAULT_FLARE_SCOPE, FULL_ART_FORMAT, isEffectTuning, missingFinishFiles, normalizeFlare, buildPublishedCatalog, collectionDrawableEditions, createCatalogIndex, holographicFinishIds, isMythicEditionIdOf, legendaryParentEdition, MATCH_HOLO_PALETTE_ID, mythicEditionId, publicCatalog, validateRarityWeights } from "./catalog.js";
import { computeStreak, DAILY_REPEAT_WINDOW_DAYS, dailyCandidates, dailyDayKey, dailyZoom, drawDailyPuzzle, guessHint, isDayKey, MAX_DAILY_GUESSES, nextDailyAt, shiftDayKey } from "./daily.js";
import { calculateRecharge, pinnedRecharge, drawPack, drawShopPack, MAX_RECHARGE_INTERVAL_MS, MAX_RESERVE_OPENINGS, MIN_RECHARGE_INTERVAL_MS, spendOpening } from "./game-rules.js";
import { DEFAULT_DESTINATIONS_PATH, loadExpeditionDestinations } from "./expedition-content.js";
@ -54,6 +54,12 @@ function flareOfRow(row) {
return { id: row.flare_id, motifId: row.flare_motif_id, paletteId: row.flare_palette_id, scope: row.flare_scope, intensity: row.flare_intensity, level: row.flare_level, count: row.flare_count };
}
// « Il manque les fichiers __cutout et __backdrop de cette carte pour cette finition. »
function missingFilesMessage(files) {
const list = files.length > 1 ? `${files.slice(0, -1).join(", ")} et ${files.at(-1)}` : files[0];
return `Il manque ${files.length > 1 ? "les fichiers" : "le fichier"} ${list} de cette carte pour cette finition.`;
}
const FLARE_ERROR_MESSAGES = {
FLARE_UNKNOWN: "Cette animation de particules n’existe pas.",
FLARE_MOTIF_INVALID: "Choisissez un motif proposé par cette animation.",
@ -252,6 +258,11 @@ export class CardsService {
if (!Array.isArray(finishIds) || finishIds.some((id) => typeof id !== "string" || !holographic.has(id))) fail(400, "FINISH_INVALID", "Choisissez uniquement des finitions holographiques.");
const needsFullImage = (id) => versioned.finishes.find((item) => item.id === id)?.formatId === FULL_ART_FORMAT;
if (!card.fullImage && finishIds.some(needsFullImage)) fail(400, "FULL_IMAGE_REQUIRED", "Cette carte n’a pas d’illustration pleine.");
// Une nouvelle variation à calques (Parallaxe prismatique) exige le héros détouré et le décor de la carte ; les variations
// déjà enregistrées restent telles quelles, même si leurs fichiers manquent.
const existing = new Set(this.db.prepare("SELECT finish_id FROM mythic_variations WHERE card_id = ?").all(cardId).map((row) => row.finish_id));
const missing = finishIds.filter((id) => !existing.has(id)).map((id) => missingFinishFiles(versioned, card, id)).find((files) => files.length);
if (missing) fail(400, "LAYERS_REQUIRED", missingFilesMessage(missing));
const openingStyle = this.validateOpeningStyle(opening);
const wanted = new Set(finishIds);
const now = this.now();
@ -307,6 +318,8 @@ export class CardsService {
const finish = versioned.finishes.find((item) => item.id === finishId);
if (!finish || !holographicFinishIds(versioned).has(finishId)) fail(400, "FINISH_INVALID", "Choisissez une finition holographique.");
if (finish.formatId === FULL_ART_FORMAT && !card.fullImage) fail(400, "FULL_IMAGE_REQUIRED", "Cette carte n’a pas d’illustration pleine.");
const missing = missingFinishFiles(versioned, card, finishId);
if (missing.length) fail(400, "LAYERS_REQUIRED", missingFilesMessage(missing));
if (row.finish_id === finishId) fail(400, "FINISH_UNCHANGED", "La variation a déjà cette finition.");
if (this.db.prepare("SELECT 1 FROM mythic_variations WHERE card_id = ? AND finish_id = ?").get(row.card_id, finishId)) {
fail(409, "FINISH_TAKEN", "Cette carte a déjà une variation avec cette finition.");