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

@ -260,7 +260,7 @@ test("finishes are generated: standard plus one per holographic effect and seven
assert.equal("finishes" in rawCatalog, false);
const preset = catalog.effectPresets.find((effect) => effect.id === "spectral-prism");
assert.equal(preset.kind, "holographic");
assert.deepEqual(catalog.finishes.map((finish) => finish.id), ["standard", ...["", "full-art-"].flatMap((format) => ["spectral-prism", "diffraction-sheen", "prismatic-backdrop"].flatMap((effect) => ["rainbow", "solar", "dusk", "crimson", "nature", "aurora", "winter", "cosmic", "darkness"].map((palette) => `${format}${effect}-${palette}`)))]);
assert.deepEqual(catalog.finishes.map((finish) => finish.id), ["standard", ...["", "full-art-"].flatMap((format) => ["spectral-prism", "diffraction-sheen", "prismatic-backdrop", "shattered-ice"].flatMap((effect) => ["rainbow", "solar", "dusk", "crimson", "nature", "aurora", "winter", "cosmic", "darkness"].map((palette) => `${format}${effect}-${palette}`)))]);
assert.deepEqual(catalog.finishes[0], { id: "standard", label: "Standard", effectPresetId: null, paletteId: null, formatId: "standard" });
assert.ok(catalog.finishes.every((finish) => !("particlePresetId" in finish)));
assert.ok(catalog.effectPalettes.every((palette) => palette.colors.length === 7 && new Set(palette.colors).size === 7));
@ -273,7 +273,7 @@ test("finishes are generated: standard plus one per holographic effect and seven
withNewEffect.effectPresets.push({ id: "effect-x", kind: "holographic", label: "Effet X" });
withNewEffect.effectPalettes.push({ id: "ember", label: "Braise", colors: ["#7f1d1d", "#b91c1c", "#ef4444", "#f97316", "#fb923c", "#fdba74", "#fff7ed"], highlight: "#ffffff" });
const generated = prepareVersionedCatalog(withNewEffect).finishes;
assert.equal(generated.length, 1 + 2 * 4 * 10);
assert.equal(generated.length, 1 + 2 * 5 * 10);
assert.deepEqual(generated.find((finish) => finish.id === "effect-x-ember"), { id: "effect-x-ember", label: "Effet X — Braise", effectPresetId: "effect-x", paletteId: "ember", formatId: "standard" });
const invalidPalette = structuredClone(rawCatalog);
@ -1205,6 +1205,65 @@ test("changing a mythic finish keeps its id, the players' copies and their exped
database.close();
});
test("a mythic variation tunes its palette intensity and its effect level, kept across finish changes", () => {
const now = 1_800_000_000_000;
const database = new CardsDatabase(":memory:");
const service = new CardsService({ database, catalog: baseCatalog, now: () => now, random: () => 0 });
const admin = service.upsertPlayer({ discordId: "tuning-admin", displayName: "Admin", isAdmin: true });
const player = service.upsertPlayer({ discordId: "tuning-player", displayName: "Player" });
service.setCardMythicConfig(admin.id, "mythic-card-pull", { finishIds: ["prismatic-backdrop-solar", "diffraction-sheen-solar"] });
const parallax = "mythic-card-pull-prismatic-backdrop-solar";
const diffraction = "mythic-card-pull-diffraction-sheen-solar";
const editionOf = (catalog, id) => catalog.editions.find((edition) => edition.id === id);
// Une variation neuve garde le palier central, 3 : rien n'est publié, le rendu de référence s'applique.
assert.deepEqual([editionOf(service.catalog, parallax).holoIntensity, editionOf(service.catalog, parallax).holoLevel], [undefined, undefined]);
assert.throws(() => service.setMythicTuning(player.id, parallax, { intensity: 5, level: 5 }), /administrateur/);
assert.throws(() => service.setMythicTuning(admin.id, "unknown-mythic", { intensity: 5, level: 5 }), /introuvable/);
assert.throws(() => service.setMythicTuning(admin.id, parallax, { intensity: 6, level: 5 }), /intensité/);
assert.throws(() => service.setMythicTuning(admin.id, parallax, { intensity: "5", level: 5 }), /intensité/);
assert.throws(() => service.setMythicTuning(admin.id, parallax, { intensity: 5, level: 0 }), /palier/);
// Le Reflet diffractif ne déclare pas de palier propre : seule son intensité se règle.
assert.throws(() => service.setMythicTuning(admin.id, diffraction, { intensity: 5, level: 1 }), /pas de palier/);
assert.throws(() => service.setMythicTuning(admin.id, parallax, { intensity: 3, level: 3 }), /déjà ces réglages/);
const tuned = editionOf(service.setMythicTuning(admin.id, parallax, { intensity: 1, level: 5 }).catalog, parallax);
assert.deepEqual([tuned.holoIntensity, tuned.holoLevel], [1, 5]);
assert.equal(editionOf(service.setMythicTuning(admin.id, diffraction, { intensity: 4, level: 3 }).catalog, diffraction).holoIntensity, 4);
const audit = database.db.prepare("SELECT entity_id, details_json FROM audit_log WHERE event_type = 'catalog_mythic_tuning_changed' ORDER BY rowid").get();
assert.deepEqual([audit.entity_id, JSON.parse(audit.details_json)], ["mythic-card-pull", { editionId: parallax, intensity: 1, level: 5 }]);
// Vers un effet sans palier propre, l'intensité reste et le palier n'est plus publié ; il revient avec un effet qui en a un.
service.setMythicFinish(admin.id, parallax, "diffraction-sheen-cosmic");
assert.deepEqual([editionOf(service.catalog, parallax).holoIntensity, editionOf(service.catalog, parallax).holoLevel], [1, undefined]);
service.setMythicFinish(admin.id, parallax, "shattered-ice-cosmic");
assert.equal(editionOf(service.catalog, parallax).holoLevel, 5);
// Les réglages survivent au redémarrage ; la base refuse un palier hors de 1 à 5.
const reloaded = new CardsService({ database, catalog: baseCatalog, now: () => now });
assert.deepEqual([editionOf(reloaded.catalog, parallax).holoIntensity, editionOf(reloaded.catalog, parallax).holoLevel], [1, 5]);
assert.throws(() => database.db.prepare("UPDATE mythic_variations SET holo_level = 6 WHERE edition_id = ?").run(parallax), /CHECK/);
database.close();
});
test("holographic effect levels and intensities are declared by the catalog and checked on editions", () => {
assert.deepEqual(rawCatalog.effectIntensity.levels, ["Très douce", "Douce", "Normale", "Intense", "Très intense"]);
assert.deepEqual(rawCatalog.effectPresets.filter((preset) => preset.level).map((preset) => preset.id), ["spectral-prism", "prismatic-backdrop", "shattered-ice"]);
const withoutIntensity = structuredClone(rawCatalog);
delete withoutIntensity.effectIntensity;
assert.throws(() => prepareVersionedCatalog(withoutIntensity), /effectIntensity/);
const brokenLevel = structuredClone(rawCatalog);
brokenLevel.effectPresets.find((preset) => preset.id === "prismatic-backdrop").level.levels.pop();
assert.throws(() => prepareVersionedCatalog(brokenLevel), /level needs a label/);
const variation = (extra) => ({ editionId: "mythic-card-pull-x", cardId: "mythic-card-pull", finishId: "diffraction-sheen-solar", status: "active", ...extra });
// Un palier d'effet n'est publié que si l'effet de la finition en déclare un.
const published = buildPublishedCatalog(baseCatalog, { variations: [variation({ intensity: 5, level: 1 })] });
const edition = published.editions.find((item) => item.id === "mythic-card-pull-x");
assert.deepEqual([edition.holoIntensity, edition.holoLevel], [5, undefined]);
const tunedEdition = structuredClone(published);
tunedEdition.editions.find((item) => item.id === "mythic-card-pull-x").holoLevel = 1;
assert.throws(() => validateCardsCatalog(tunedEdition), /level its effect does not declare/);
});
test("pack availability and drop rates live in the database and apply immediately", () => {
assert.equal("dropTables" in rawCatalog, false);
assert.ok(rawCatalog.collections.every((collection) => !("active" in collection) && !("dropWeights" in collection)));