Add the shattered ice effect and five-step tunings for mythic variations
All checks were successful
Validate and deploy Sokko G / validate (push) Successful in 22m39s
Validate and deploy Sokko G / deploy (push) Successful in 14s

« Glace brisée » joins the holographic effects: a seamless shard mosaic in four
facet groups that each light up near their own tilt, with glinting cracks; in
the standard layout it covers the frame and text and stays under the artwork.
Its masks come from scripts/generate-shattered-ice-textures.mjs.

Each mythic variation now tunes its palette intensity and, when the effect
declares one, its own level (prism speed, parallax amplitude, shard size), from
1 to 5 with 3 as the reference render. Tunings are stored on mythic_variations,
set with range sliders when a variation is created or later in the mythic
editor, logged in the history and previewed in the Visual Lab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Shinuwa 2026-11-21 22:40:24 +01:00
parent efdb5c558c
commit 808adadc0c
23 changed files with 463 additions and 31 deletions

View file

@ -492,6 +492,12 @@ export function createCardsApiHandler({
json(res, 200, service.setCardMythicConfig(session.player.id, cardMythic[0], { finishIds: body.finishIds, opening: { particleShapeId: body.opening?.particleShapeId ?? null, particlePaletteId: body.opening?.particlePaletteId ?? null } }));
return true;
}
const mythicTuning = routeMatch(url.pathname, /^\/api\/cards\/admin\/catalog\/mythics\/([^/]+)\/tuning$/);
if (req.method === "PUT" && mythicTuning) {
const body = await readBody(req);
json(res, 200, service.setMythicTuning(session.player.id, mythicTuning[0], { intensity: body.intensity, level: body.level }));
return true;
}
const mythicFinish = routeMatch(url.pathname, /^\/api\/cards\/admin\/catalog\/mythics\/([^/]+)\/finish$/);
if (req.method === "PUT" && mythicFinish) {
json(res, 200, service.setMythicFinish(session.player.id, mythicFinish[0], (await readBody(req)).finishId));

View file

@ -13,6 +13,13 @@ const STANDARD_FORMAT = "standard";
export const FULL_ART_FORMAT = "full-art";
// Palette d'ouverture spéciale : reprend les couleurs de la palette holographique de la variation.
export const MATCH_HOLO_PALETTE_ID = "match-holo";
// Paliers d'une variation mythique, de 1 à 5 : l'intensité de la palette, commune à tous les effets, et le palier propre à
// l'effet (vitesse, amplitude…) quand il en déclare un. Le palier central, 3, est la valeur par défaut et le rendu de référence.
export const EFFECT_TUNING_STEPS = 5;
export const DEFAULT_EFFECT_TUNING = 3;
export const isEffectTuning = (value) => Number.isInteger(value) && value >= 1 && value <= EFFECT_TUNING_STEPS;
const validTuningScale = (scale) => typeof scale?.label === "string" && scale.label.length > 0 && Array.isArray(scale.levels)
&& scale.levels.length === EFFECT_TUNING_STEPS && scale.levels.every((label) => typeof label === "string" && label.length > 0);
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).
@ -127,7 +134,9 @@ 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 (!validTuningScale(catalog.effectIntensity)) throw new TypeError(`Cards catalog effectIntensity needs a label and ${EFFECT_TUNING_STEPS} level labels.`);
if (catalog.cardFormats?.[0]?.id !== STANDARD_FORMAT || catalog.cardFormats.some((format) => !format.label) || !catalog.cardFormats.some((format) => format.id === FULL_ART_FORMAT)) {
throw new TypeError("Cards catalog must declare the standard and full-art formats.");
}
@ -237,6 +246,12 @@ export function validateCardsCatalog(catalog) {
if (!RARITY_IDS.has(edition.rarity)) throw new TypeError(`Unknown rarity for edition ${edition.id}.`);
if (!Array.isArray(edition.finishIds) || edition.finishIds.some((id) => !finishIds.has(id))) throw new TypeError(`Unknown finish for edition ${edition.id}.`);
if (edition.retired != null && typeof edition.retired !== "boolean") throw new TypeError(`Edition ${edition.id} retired flag must be a boolean.`);
if (edition.holoIntensity != null || edition.holoLevel != null) {
const preset = catalog.effectPresets.find((item) => item.id === catalog.finishes.find((finish) => finish.id === edition.finishIds[0])?.effectPresetId);
if (!preset) throw new TypeError(`Edition ${edition.id} can only be tuned with a holographic finish.`);
if (edition.holoIntensity != null && !isEffectTuning(edition.holoIntensity)) throw new TypeError(`Edition ${edition.id} has an unknown holographic intensity.`);
if (edition.holoLevel != null && (!preset.level || !isEffectTuning(edition.holoLevel))) throw new TypeError(`Edition ${edition.id} has a level its effect does not declare.`);
}
if (destinationCards.some((card) => card.id === edition.cardId) && edition.rarity !== "rare") throw new TypeError(`Destination card edition ${edition.id} must be rare.`);
if (edition.promotional && edition.legendaryEditionId) throw new TypeError(`Promotional edition ${edition.id} cannot require a legendary parent.`);
if (edition.rarity === "mythic" && !edition.promotional) {
@ -394,7 +409,8 @@ export function isMythicEditionIdOf(editionId, cardId) {
}
// Construit le catalogue publié : catalogue versionné + variations mythiques et réglages d'ouverture enregistrés en base.
// `variations` : [{ editionId, cardId, finishId, status: "active" | "retired" }]
// `variations` : [{ editionId, cardId, finishId, status: "active" | "retired", intensity?, level? }] ; un palier central ou absent
// n'est pas publié, et le palier d'effet seulement si l'effet de la finition en déclare un.
// `openingSettings` : [{ scope: "collection" | "card", targetId, particleShapeId | null, particlePaletteId | null }]
// `collectionStates` : [{ collectionId, active }] ; une collection sans état est inactive.
// `dropRates` : [{ collectionId, rarityWeights }] ; publiés sur chaque collection dans `dropWeights`.
@ -410,6 +426,7 @@ export function buildPublishedCatalog(versionedCatalog, { variations = [], openi
if (!collection.dropWeights) throw new TypeError(`Active collection ${collection.id} needs drop rates.`);
}
const holographic = holographicFinishIds(catalog);
const effectOf = (finishId) => catalog.effectPresets.find((preset) => preset.id === catalog.finishes.find((finish) => finish.id === finishId)?.effectPresetId);
const knownIds = new Set(catalog.editions.map((edition) => edition.id));
const cardFinishes = new Set();
const mythics = variations.map((variation) => {
@ -428,7 +445,9 @@ export function buildPublishedCatalog(versionedCatalog, { variations = [], openi
finishIds: [variation.finishId],
promotional: false,
legendaryEditionId: parent.id,
...(variation.status === "retired" ? { retired: true } : {})
...(variation.status === "retired" ? { retired: true } : {}),
...(isEffectTuning(variation.intensity) && variation.intensity !== DEFAULT_EFFECT_TUNING ? { holoIntensity: variation.intensity } : {}),
...(isEffectTuning(variation.level) && variation.level !== DEFAULT_EFFECT_TUNING && effectOf(variation.finishId)?.level ? { holoLevel: variation.level } : {})
};
});
// Chaque variation suit sa carte légendaire, dans l'ordre des finitions.

View file

@ -487,6 +487,12 @@ export const MIGRATIONS = [
// l'identifiant ne garantit donc plus qu'une carte a une seule variation par finition, cet index le fait.
`
CREATE UNIQUE INDEX mythic_variations_card_finish_idx ON mythic_variations(card_id, finish_id);
`,
// Paliers d'une variation mythique, de 1 à 5 : intensité de la palette et palier propre à l'effet (vitesse, amplitude…). Le
// palier central, 3, ne change rien au rendu : les variations existantes gardent exactement leur apparence.
`
ALTER TABLE mythic_variations ADD COLUMN holo_intensity INTEGER NOT NULL DEFAULT 3 CHECK (holo_intensity BETWEEN 1 AND 5);
ALTER TABLE mythic_variations ADD COLUMN holo_level INTEGER NOT NULL DEFAULT 3 CHECK (holo_level BETWEEN 1 AND 5);
`
];

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 { FULL_ART_FORMAT, buildPublishedCatalog, collectionDrawableEditions, createCatalogIndex, holographicFinishIds, isMythicEditionIdOf, legendaryParentEdition, MATCH_HOLO_PALETTE_ID, mythicEditionId, publicCatalog, validateRarityWeights } from "./catalog.js";
import { DEFAULT_EFFECT_TUNING, FULL_ART_FORMAT, isEffectTuning, 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";
@ -153,8 +153,8 @@ export class CardsService {
const collectionIds = new Set(versioned.collections.map((collection) => collection.id));
const shapeIds = new Set(versioned.particleShapes.map((shape) => shape.id));
const paletteIds = new Set([...versioned.particlePalettes.map((palette) => palette.id), MATCH_HOLO_PALETTE_ID]);
const variations = this.db.prepare("SELECT edition_id, card_id, finish_id, status FROM mythic_variations").all()
.map((row) => ({ editionId: row.edition_id, cardId: row.card_id, finishId: row.finish_id, status: row.status }))
const variations = this.db.prepare("SELECT edition_id, card_id, finish_id, status, holo_intensity, holo_level FROM mythic_variations").all()
.map((row) => ({ editionId: row.edition_id, cardId: row.card_id, finishId: row.finish_id, status: row.status, intensity: row.holo_intensity, level: row.holo_level }))
.filter((row) => holographic.has(row.finishId) && legendaryParentEdition(versioned, row.cardId) && isMythicEditionIdOf(row.editionId, row.cardId));
const openingSettings = this.db.prepare("SELECT scope, target_id, particle_shape_id, particle_palette_id FROM mythic_opening_settings ORDER BY scope, target_id").all()
.map((row) => ({
@ -305,6 +305,26 @@ export class CardsService {
return { catalog: publicCatalog(this.catalog) };
}
// Règle les paliers d'une variation : intensité de la palette et palier propre à son effet, s'il en déclare un. Les joueurs qui
// la possèdent voient aussitôt le nouveau réglage, sans autre changement.
setMythicTuning(playerId, editionId, { intensity, level } = {}) {
this.requireAdmin(playerId);
const versioned = this.versionedCatalog;
const row = this.db.prepare("SELECT card_id, finish_id, holo_intensity, holo_level FROM mythic_variations WHERE edition_id = ?").get(editionId);
if (!row || !versioned.cards.some((item) => item.id === row.card_id)) fail(404, "MYTHIC_NOT_FOUND", "Variation mythique introuvable.");
const preset = versioned.effectPresets.find((item) => item.id === versioned.finishes.find((finish) => finish.id === row.finish_id)?.effectPresetId);
if (!isEffectTuning(intensity)) fail(400, "INTENSITY_INVALID", "Choisissez une intensité de palette entre 1 et 5.");
if (!isEffectTuning(level)) fail(400, "LEVEL_INVALID", "Choisissez un palier d’effet entre 1 et 5.");
if (!preset?.level && level !== DEFAULT_EFFECT_TUNING) fail(400, "LEVEL_UNAVAILABLE", "Cet effet n’a pas de palier réglable.");
if (row.holo_intensity === intensity && row.holo_level === level) fail(400, "TUNING_UNCHANGED", "La variation a déjà ces réglages.");
this.database.transaction(() => {
this.db.prepare("UPDATE mythic_variations SET holo_intensity = ?, holo_level = ?, updated_at = ?, updated_by = ? WHERE edition_id = ?").run(intensity, level, this.now(), playerId, editionId);
this.audit(playerId, "catalog_mythic_tuning_changed", row.card_id, { editionId, intensity, level });
this.reloadCatalog();
});
return { catalog: publicCatalog(this.catalog) };
}
requireCollection(collectionId) {
if (!this.versionedCatalog.collections.some((collection) => collection.id === collectionId)) fail(404, "COLLECTION_NOT_FOUND", "Collection introuvable.");
}